babylon.module.d.ts 5.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277
  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. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32825. virtual?: boolean;
  32826. }
  32827. /**
  32828. * Represents a scene to be rendered by the engine.
  32829. * @see http://doc.babylonjs.com/features/scene
  32830. */
  32831. export class Scene extends AbstractScene implements IAnimatable {
  32832. private static _uniqueIdCounter;
  32833. /** The fog is deactivated */
  32834. static readonly FOGMODE_NONE: number;
  32835. /** The fog density is following an exponential function */
  32836. static readonly FOGMODE_EXP: number;
  32837. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32838. static readonly FOGMODE_EXP2: number;
  32839. /** The fog density is following a linear function. */
  32840. static readonly FOGMODE_LINEAR: number;
  32841. /**
  32842. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32843. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32844. */
  32845. static MinDeltaTime: number;
  32846. /**
  32847. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32849. */
  32850. static MaxDeltaTime: number;
  32851. /**
  32852. * Factory used to create the default material.
  32853. * @param name The name of the material to create
  32854. * @param scene The scene to create the material for
  32855. * @returns The default material
  32856. */
  32857. static DefaultMaterialFactory(scene: Scene): Material;
  32858. /**
  32859. * Factory used to create the a collision coordinator.
  32860. * @returns The collision coordinator
  32861. */
  32862. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32863. /** @hidden */
  32864. _inputManager: InputManager;
  32865. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32866. cameraToUseForPointers: Nullable<Camera>;
  32867. /** @hidden */
  32868. readonly _isScene: boolean;
  32869. /**
  32870. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32871. */
  32872. autoClear: boolean;
  32873. /**
  32874. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32875. */
  32876. autoClearDepthAndStencil: boolean;
  32877. /**
  32878. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32879. */
  32880. clearColor: Color4;
  32881. /**
  32882. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32883. */
  32884. ambientColor: Color3;
  32885. /**
  32886. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32887. * It should only be one of the following (if not the default embedded one):
  32888. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32889. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32890. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32891. * The material properties need to be setup according to the type of texture in use.
  32892. */
  32893. environmentBRDFTexture: BaseTexture;
  32894. /** @hidden */
  32895. protected _environmentTexture: Nullable<BaseTexture>;
  32896. /**
  32897. * Texture used in all pbr material as the reflection texture.
  32898. * As in the majority of the scene they are the same (exception for multi room and so on),
  32899. * this is easier to reference from here than from all the materials.
  32900. */
  32901. /**
  32902. * Texture used in all pbr material as the reflection texture.
  32903. * As in the majority of the scene they are the same (exception for multi room and so on),
  32904. * this is easier to set here than in all the materials.
  32905. */
  32906. environmentTexture: Nullable<BaseTexture>;
  32907. /** @hidden */
  32908. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32909. /**
  32910. * Default image processing configuration used either in the rendering
  32911. * Forward main pass or through the imageProcessingPostProcess if present.
  32912. * As in the majority of the scene they are the same (exception for multi camera),
  32913. * this is easier to reference from here than from all the materials and post process.
  32914. *
  32915. * No setter as we it is a shared configuration, you can set the values instead.
  32916. */
  32917. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32918. private _forceWireframe;
  32919. /**
  32920. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32921. */
  32922. forceWireframe: boolean;
  32923. private _forcePointsCloud;
  32924. /**
  32925. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32926. */
  32927. forcePointsCloud: boolean;
  32928. /**
  32929. * Gets or sets the active clipplane 1
  32930. */
  32931. clipPlane: Nullable<Plane>;
  32932. /**
  32933. * Gets or sets the active clipplane 2
  32934. */
  32935. clipPlane2: Nullable<Plane>;
  32936. /**
  32937. * Gets or sets the active clipplane 3
  32938. */
  32939. clipPlane3: Nullable<Plane>;
  32940. /**
  32941. * Gets or sets the active clipplane 4
  32942. */
  32943. clipPlane4: Nullable<Plane>;
  32944. /**
  32945. * Gets or sets a boolean indicating if animations are enabled
  32946. */
  32947. animationsEnabled: boolean;
  32948. private _animationPropertiesOverride;
  32949. /**
  32950. * Gets or sets the animation properties override
  32951. */
  32952. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32953. /**
  32954. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32955. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32956. */
  32957. useConstantAnimationDeltaTime: boolean;
  32958. /**
  32959. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32960. * Please note that it requires to run a ray cast through the scene on every frame
  32961. */
  32962. constantlyUpdateMeshUnderPointer: boolean;
  32963. /**
  32964. * Defines the HTML cursor to use when hovering over interactive elements
  32965. */
  32966. hoverCursor: string;
  32967. /**
  32968. * Defines the HTML default cursor to use (empty by default)
  32969. */
  32970. defaultCursor: string;
  32971. /**
  32972. * This is used to call preventDefault() on pointer down
  32973. * in order to block unwanted artifacts like system double clicks
  32974. */
  32975. preventDefaultOnPointerDown: boolean;
  32976. /**
  32977. * This is used to call preventDefault() on pointer up
  32978. * in order to block unwanted artifacts like system double clicks
  32979. */
  32980. preventDefaultOnPointerUp: boolean;
  32981. /**
  32982. * Gets or sets user defined metadata
  32983. */
  32984. metadata: any;
  32985. /**
  32986. * For internal use only. Please do not use.
  32987. */
  32988. reservedDataStore: any;
  32989. /**
  32990. * Gets the name of the plugin used to load this scene (null by default)
  32991. */
  32992. loadingPluginName: string;
  32993. /**
  32994. * Use this array to add regular expressions used to disable offline support for specific urls
  32995. */
  32996. disableOfflineSupportExceptionRules: RegExp[];
  32997. /**
  32998. * An event triggered when the scene is disposed.
  32999. */
  33000. onDisposeObservable: Observable<Scene>;
  33001. private _onDisposeObserver;
  33002. /** Sets a function to be executed when this scene is disposed. */
  33003. onDispose: () => void;
  33004. /**
  33005. * An event triggered before rendering the scene (right after animations and physics)
  33006. */
  33007. onBeforeRenderObservable: Observable<Scene>;
  33008. private _onBeforeRenderObserver;
  33009. /** Sets a function to be executed before rendering this scene */
  33010. beforeRender: Nullable<() => void>;
  33011. /**
  33012. * An event triggered after rendering the scene
  33013. */
  33014. onAfterRenderObservable: Observable<Scene>;
  33015. private _onAfterRenderObserver;
  33016. /** Sets a function to be executed after rendering this scene */
  33017. afterRender: Nullable<() => void>;
  33018. /**
  33019. * An event triggered before animating the scene
  33020. */
  33021. onBeforeAnimationsObservable: Observable<Scene>;
  33022. /**
  33023. * An event triggered after animations processing
  33024. */
  33025. onAfterAnimationsObservable: Observable<Scene>;
  33026. /**
  33027. * An event triggered before draw calls are ready to be sent
  33028. */
  33029. onBeforeDrawPhaseObservable: Observable<Scene>;
  33030. /**
  33031. * An event triggered after draw calls have been sent
  33032. */
  33033. onAfterDrawPhaseObservable: Observable<Scene>;
  33034. /**
  33035. * An event triggered when the scene is ready
  33036. */
  33037. onReadyObservable: Observable<Scene>;
  33038. /**
  33039. * An event triggered before rendering a camera
  33040. */
  33041. onBeforeCameraRenderObservable: Observable<Camera>;
  33042. private _onBeforeCameraRenderObserver;
  33043. /** Sets a function to be executed before rendering a camera*/
  33044. beforeCameraRender: () => void;
  33045. /**
  33046. * An event triggered after rendering a camera
  33047. */
  33048. onAfterCameraRenderObservable: Observable<Camera>;
  33049. private _onAfterCameraRenderObserver;
  33050. /** Sets a function to be executed after rendering a camera*/
  33051. afterCameraRender: () => void;
  33052. /**
  33053. * An event triggered when active meshes evaluation is about to start
  33054. */
  33055. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33056. /**
  33057. * An event triggered when active meshes evaluation is done
  33058. */
  33059. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33060. /**
  33061. * An event triggered when particles rendering is about to start
  33062. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33063. */
  33064. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33065. /**
  33066. * An event triggered when particles rendering is done
  33067. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33068. */
  33069. onAfterParticlesRenderingObservable: Observable<Scene>;
  33070. /**
  33071. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33072. */
  33073. onDataLoadedObservable: Observable<Scene>;
  33074. /**
  33075. * An event triggered when a camera is created
  33076. */
  33077. onNewCameraAddedObservable: Observable<Camera>;
  33078. /**
  33079. * An event triggered when a camera is removed
  33080. */
  33081. onCameraRemovedObservable: Observable<Camera>;
  33082. /**
  33083. * An event triggered when a light is created
  33084. */
  33085. onNewLightAddedObservable: Observable<Light>;
  33086. /**
  33087. * An event triggered when a light is removed
  33088. */
  33089. onLightRemovedObservable: Observable<Light>;
  33090. /**
  33091. * An event triggered when a geometry is created
  33092. */
  33093. onNewGeometryAddedObservable: Observable<Geometry>;
  33094. /**
  33095. * An event triggered when a geometry is removed
  33096. */
  33097. onGeometryRemovedObservable: Observable<Geometry>;
  33098. /**
  33099. * An event triggered when a transform node is created
  33100. */
  33101. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33102. /**
  33103. * An event triggered when a transform node is removed
  33104. */
  33105. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33106. /**
  33107. * An event triggered when a mesh is created
  33108. */
  33109. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33110. /**
  33111. * An event triggered when a mesh is removed
  33112. */
  33113. onMeshRemovedObservable: Observable<AbstractMesh>;
  33114. /**
  33115. * An event triggered when a skeleton is created
  33116. */
  33117. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33118. /**
  33119. * An event triggered when a skeleton is removed
  33120. */
  33121. onSkeletonRemovedObservable: Observable<Skeleton>;
  33122. /**
  33123. * An event triggered when a material is created
  33124. */
  33125. onNewMaterialAddedObservable: Observable<Material>;
  33126. /**
  33127. * An event triggered when a material is removed
  33128. */
  33129. onMaterialRemovedObservable: Observable<Material>;
  33130. /**
  33131. * An event triggered when a texture is created
  33132. */
  33133. onNewTextureAddedObservable: Observable<BaseTexture>;
  33134. /**
  33135. * An event triggered when a texture is removed
  33136. */
  33137. onTextureRemovedObservable: Observable<BaseTexture>;
  33138. /**
  33139. * An event triggered when render targets are about to be rendered
  33140. * Can happen multiple times per frame.
  33141. */
  33142. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33143. /**
  33144. * An event triggered when render targets were rendered.
  33145. * Can happen multiple times per frame.
  33146. */
  33147. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33148. /**
  33149. * An event triggered before calculating deterministic simulation step
  33150. */
  33151. onBeforeStepObservable: Observable<Scene>;
  33152. /**
  33153. * An event triggered after calculating deterministic simulation step
  33154. */
  33155. onAfterStepObservable: Observable<Scene>;
  33156. /**
  33157. * An event triggered when the activeCamera property is updated
  33158. */
  33159. onActiveCameraChanged: Observable<Scene>;
  33160. /**
  33161. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33162. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33163. * 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)
  33164. */
  33165. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33166. /**
  33167. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33168. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33169. * 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)
  33170. */
  33171. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33172. /**
  33173. * This Observable will when a mesh has been imported into the scene.
  33174. */
  33175. onMeshImportedObservable: Observable<AbstractMesh>;
  33176. /**
  33177. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33178. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33179. */
  33180. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33181. /** @hidden */
  33182. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33183. /**
  33184. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33185. */
  33186. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33187. /**
  33188. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33189. */
  33190. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33191. /**
  33192. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33193. */
  33194. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33195. /** Callback called when a pointer move is detected */
  33196. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33197. /** Callback called when a pointer down is detected */
  33198. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33199. /** Callback called when a pointer up is detected */
  33200. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33201. /** Callback called when a pointer pick is detected */
  33202. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33203. /**
  33204. * 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).
  33205. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33206. */
  33207. onPrePointerObservable: Observable<PointerInfoPre>;
  33208. /**
  33209. * Observable event triggered each time an input event is received from the rendering canvas
  33210. */
  33211. onPointerObservable: Observable<PointerInfo>;
  33212. /**
  33213. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33214. */
  33215. readonly unTranslatedPointer: Vector2;
  33216. /**
  33217. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33218. */
  33219. static DragMovementThreshold: number;
  33220. /**
  33221. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33222. */
  33223. static LongPressDelay: number;
  33224. /**
  33225. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33226. */
  33227. static DoubleClickDelay: number;
  33228. /** If you need to check double click without raising a single click at first click, enable this flag */
  33229. static ExclusiveDoubleClickMode: boolean;
  33230. /** @hidden */
  33231. _mirroredCameraPosition: Nullable<Vector3>;
  33232. /**
  33233. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33234. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33235. */
  33236. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33237. /**
  33238. * Observable event triggered each time an keyboard event is received from the hosting window
  33239. */
  33240. onKeyboardObservable: Observable<KeyboardInfo>;
  33241. private _useRightHandedSystem;
  33242. /**
  33243. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33244. */
  33245. useRightHandedSystem: boolean;
  33246. private _timeAccumulator;
  33247. private _currentStepId;
  33248. private _currentInternalStep;
  33249. /**
  33250. * Sets the step Id used by deterministic lock step
  33251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33252. * @param newStepId defines the step Id
  33253. */
  33254. setStepId(newStepId: number): void;
  33255. /**
  33256. * Gets the step Id used by deterministic lock step
  33257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33258. * @returns the step Id
  33259. */
  33260. getStepId(): number;
  33261. /**
  33262. * Gets the internal step used by deterministic lock step
  33263. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33264. * @returns the internal step
  33265. */
  33266. getInternalStep(): number;
  33267. private _fogEnabled;
  33268. /**
  33269. * Gets or sets a boolean indicating if fog is enabled on this scene
  33270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33271. * (Default is true)
  33272. */
  33273. fogEnabled: boolean;
  33274. private _fogMode;
  33275. /**
  33276. * Gets or sets the fog mode to use
  33277. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33278. * | mode | value |
  33279. * | --- | --- |
  33280. * | FOGMODE_NONE | 0 |
  33281. * | FOGMODE_EXP | 1 |
  33282. * | FOGMODE_EXP2 | 2 |
  33283. * | FOGMODE_LINEAR | 3 |
  33284. */
  33285. fogMode: number;
  33286. /**
  33287. * Gets or sets the fog color to use
  33288. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33289. * (Default is Color3(0.2, 0.2, 0.3))
  33290. */
  33291. fogColor: Color3;
  33292. /**
  33293. * Gets or sets the fog density to use
  33294. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33295. * (Default is 0.1)
  33296. */
  33297. fogDensity: number;
  33298. /**
  33299. * Gets or sets the fog start distance to use
  33300. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33301. * (Default is 0)
  33302. */
  33303. fogStart: number;
  33304. /**
  33305. * Gets or sets the fog end distance to use
  33306. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33307. * (Default is 1000)
  33308. */
  33309. fogEnd: number;
  33310. private _shadowsEnabled;
  33311. /**
  33312. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33313. */
  33314. shadowsEnabled: boolean;
  33315. private _lightsEnabled;
  33316. /**
  33317. * Gets or sets a boolean indicating if lights are enabled on this scene
  33318. */
  33319. lightsEnabled: boolean;
  33320. /** All of the active cameras added to this scene. */
  33321. activeCameras: Camera[];
  33322. /** @hidden */
  33323. _activeCamera: Nullable<Camera>;
  33324. /** Gets or sets the current active camera */
  33325. activeCamera: Nullable<Camera>;
  33326. private _defaultMaterial;
  33327. /** The default material used on meshes when no material is affected */
  33328. /** The default material used on meshes when no material is affected */
  33329. defaultMaterial: Material;
  33330. private _texturesEnabled;
  33331. /**
  33332. * Gets or sets a boolean indicating if textures are enabled on this scene
  33333. */
  33334. texturesEnabled: boolean;
  33335. /**
  33336. * Gets or sets a boolean indicating if particles are enabled on this scene
  33337. */
  33338. particlesEnabled: boolean;
  33339. /**
  33340. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33341. */
  33342. spritesEnabled: boolean;
  33343. private _skeletonsEnabled;
  33344. /**
  33345. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33346. */
  33347. skeletonsEnabled: boolean;
  33348. /**
  33349. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33350. */
  33351. lensFlaresEnabled: boolean;
  33352. /**
  33353. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33355. */
  33356. collisionsEnabled: boolean;
  33357. private _collisionCoordinator;
  33358. /** @hidden */
  33359. readonly collisionCoordinator: ICollisionCoordinator;
  33360. /**
  33361. * Defines the gravity applied to this scene (used only for collisions)
  33362. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33363. */
  33364. gravity: Vector3;
  33365. /**
  33366. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33367. */
  33368. postProcessesEnabled: boolean;
  33369. /**
  33370. * The list of postprocesses added to the scene
  33371. */
  33372. postProcesses: PostProcess[];
  33373. /**
  33374. * Gets the current postprocess manager
  33375. */
  33376. postProcessManager: PostProcessManager;
  33377. /**
  33378. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33379. */
  33380. renderTargetsEnabled: boolean;
  33381. /**
  33382. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33383. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33384. */
  33385. dumpNextRenderTargets: boolean;
  33386. /**
  33387. * The list of user defined render targets added to the scene
  33388. */
  33389. customRenderTargets: RenderTargetTexture[];
  33390. /**
  33391. * Defines if texture loading must be delayed
  33392. * If true, textures will only be loaded when they need to be rendered
  33393. */
  33394. useDelayedTextureLoading: boolean;
  33395. /**
  33396. * Gets the list of meshes imported to the scene through SceneLoader
  33397. */
  33398. importedMeshesFiles: String[];
  33399. /**
  33400. * Gets or sets a boolean indicating if probes are enabled on this scene
  33401. */
  33402. probesEnabled: boolean;
  33403. /**
  33404. * Gets or sets the current offline provider to use to store scene data
  33405. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33406. */
  33407. offlineProvider: IOfflineProvider;
  33408. /**
  33409. * Gets or sets the action manager associated with the scene
  33410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33411. */
  33412. actionManager: AbstractActionManager;
  33413. private _meshesForIntersections;
  33414. /**
  33415. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33416. */
  33417. proceduralTexturesEnabled: boolean;
  33418. private _engine;
  33419. private _totalVertices;
  33420. /** @hidden */
  33421. _activeIndices: PerfCounter;
  33422. /** @hidden */
  33423. _activeParticles: PerfCounter;
  33424. /** @hidden */
  33425. _activeBones: PerfCounter;
  33426. private _animationRatio;
  33427. /** @hidden */
  33428. _animationTimeLast: number;
  33429. /** @hidden */
  33430. _animationTime: number;
  33431. /**
  33432. * Gets or sets a general scale for animation speed
  33433. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33434. */
  33435. animationTimeScale: number;
  33436. /** @hidden */
  33437. _cachedMaterial: Nullable<Material>;
  33438. /** @hidden */
  33439. _cachedEffect: Nullable<Effect>;
  33440. /** @hidden */
  33441. _cachedVisibility: Nullable<number>;
  33442. private _renderId;
  33443. private _frameId;
  33444. private _executeWhenReadyTimeoutId;
  33445. private _intermediateRendering;
  33446. private _viewUpdateFlag;
  33447. private _projectionUpdateFlag;
  33448. /** @hidden */
  33449. _toBeDisposed: Nullable<IDisposable>[];
  33450. private _activeRequests;
  33451. /** @hidden */
  33452. _pendingData: any[];
  33453. private _isDisposed;
  33454. /**
  33455. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33456. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33457. */
  33458. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33459. private _activeMeshes;
  33460. private _processedMaterials;
  33461. private _renderTargets;
  33462. /** @hidden */
  33463. _activeParticleSystems: SmartArray<IParticleSystem>;
  33464. private _activeSkeletons;
  33465. private _softwareSkinnedMeshes;
  33466. private _renderingManager;
  33467. /** @hidden */
  33468. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33469. private _transformMatrix;
  33470. private _sceneUbo;
  33471. /** @hidden */
  33472. _viewMatrix: Matrix;
  33473. private _projectionMatrix;
  33474. /** @hidden */
  33475. _forcedViewPosition: Nullable<Vector3>;
  33476. /** @hidden */
  33477. _frustumPlanes: Plane[];
  33478. /**
  33479. * Gets the list of frustum planes (built from the active camera)
  33480. */
  33481. readonly frustumPlanes: Plane[];
  33482. /**
  33483. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33484. * This is useful if there are more lights that the maximum simulteanous authorized
  33485. */
  33486. requireLightSorting: boolean;
  33487. /** @hidden */
  33488. readonly useMaterialMeshMap: boolean;
  33489. /** @hidden */
  33490. readonly useClonedMeshhMap: boolean;
  33491. private _externalData;
  33492. private _uid;
  33493. /**
  33494. * @hidden
  33495. * Backing store of defined scene components.
  33496. */
  33497. _components: ISceneComponent[];
  33498. /**
  33499. * @hidden
  33500. * Backing store of defined scene components.
  33501. */
  33502. _serializableComponents: ISceneSerializableComponent[];
  33503. /**
  33504. * List of components to register on the next registration step.
  33505. */
  33506. private _transientComponents;
  33507. /**
  33508. * Registers the transient components if needed.
  33509. */
  33510. private _registerTransientComponents;
  33511. /**
  33512. * @hidden
  33513. * Add a component to the scene.
  33514. * Note that the ccomponent could be registered on th next frame if this is called after
  33515. * the register component stage.
  33516. * @param component Defines the component to add to the scene
  33517. */
  33518. _addComponent(component: ISceneComponent): void;
  33519. /**
  33520. * @hidden
  33521. * Gets a component from the scene.
  33522. * @param name defines the name of the component to retrieve
  33523. * @returns the component or null if not present
  33524. */
  33525. _getComponent(name: string): Nullable<ISceneComponent>;
  33526. /**
  33527. * @hidden
  33528. * Defines the actions happening before camera updates.
  33529. */
  33530. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33531. /**
  33532. * @hidden
  33533. * Defines the actions happening before clear the canvas.
  33534. */
  33535. _beforeClearStage: Stage<SimpleStageAction>;
  33536. /**
  33537. * @hidden
  33538. * Defines the actions when collecting render targets for the frame.
  33539. */
  33540. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33541. /**
  33542. * @hidden
  33543. * Defines the actions happening for one camera in the frame.
  33544. */
  33545. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33546. /**
  33547. * @hidden
  33548. * Defines the actions happening during the per mesh ready checks.
  33549. */
  33550. _isReadyForMeshStage: Stage<MeshStageAction>;
  33551. /**
  33552. * @hidden
  33553. * Defines the actions happening before evaluate active mesh checks.
  33554. */
  33555. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33556. /**
  33557. * @hidden
  33558. * Defines the actions happening during the evaluate sub mesh checks.
  33559. */
  33560. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33561. /**
  33562. * @hidden
  33563. * Defines the actions happening during the active mesh stage.
  33564. */
  33565. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33566. /**
  33567. * @hidden
  33568. * Defines the actions happening during the per camera render target step.
  33569. */
  33570. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33571. /**
  33572. * @hidden
  33573. * Defines the actions happening just before the active camera is drawing.
  33574. */
  33575. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33576. /**
  33577. * @hidden
  33578. * Defines the actions happening just before a render target is drawing.
  33579. */
  33580. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33581. /**
  33582. * @hidden
  33583. * Defines the actions happening just before a rendering group is drawing.
  33584. */
  33585. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33586. /**
  33587. * @hidden
  33588. * Defines the actions happening just before a mesh is drawing.
  33589. */
  33590. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33591. /**
  33592. * @hidden
  33593. * Defines the actions happening just after a mesh has been drawn.
  33594. */
  33595. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33596. /**
  33597. * @hidden
  33598. * Defines the actions happening just after a rendering group has been drawn.
  33599. */
  33600. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33601. /**
  33602. * @hidden
  33603. * Defines the actions happening just after the active camera has been drawn.
  33604. */
  33605. _afterCameraDrawStage: Stage<CameraStageAction>;
  33606. /**
  33607. * @hidden
  33608. * Defines the actions happening just after a render target has been drawn.
  33609. */
  33610. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33611. /**
  33612. * @hidden
  33613. * Defines the actions happening just after rendering all cameras and computing intersections.
  33614. */
  33615. _afterRenderStage: Stage<SimpleStageAction>;
  33616. /**
  33617. * @hidden
  33618. * Defines the actions happening when a pointer move event happens.
  33619. */
  33620. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33621. /**
  33622. * @hidden
  33623. * Defines the actions happening when a pointer down event happens.
  33624. */
  33625. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33626. /**
  33627. * @hidden
  33628. * Defines the actions happening when a pointer up event happens.
  33629. */
  33630. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33631. /**
  33632. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33633. */
  33634. private geometriesByUniqueId;
  33635. /**
  33636. * Creates a new Scene
  33637. * @param engine defines the engine to use to render this scene
  33638. * @param options defines the scene options
  33639. */
  33640. constructor(engine: Engine, options?: SceneOptions);
  33641. /**
  33642. * Gets a string idenfifying the name of the class
  33643. * @returns "Scene" string
  33644. */
  33645. getClassName(): string;
  33646. private _defaultMeshCandidates;
  33647. /**
  33648. * @hidden
  33649. */
  33650. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33651. private _defaultSubMeshCandidates;
  33652. /**
  33653. * @hidden
  33654. */
  33655. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33656. /**
  33657. * Sets the default candidate providers for the scene.
  33658. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33659. * and getCollidingSubMeshCandidates to their default function
  33660. */
  33661. setDefaultCandidateProviders(): void;
  33662. /**
  33663. * Gets the mesh that is currently under the pointer
  33664. */
  33665. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33666. /**
  33667. * Gets or sets the current on-screen X position of the pointer
  33668. */
  33669. pointerX: number;
  33670. /**
  33671. * Gets or sets the current on-screen Y position of the pointer
  33672. */
  33673. pointerY: number;
  33674. /**
  33675. * Gets the cached material (ie. the latest rendered one)
  33676. * @returns the cached material
  33677. */
  33678. getCachedMaterial(): Nullable<Material>;
  33679. /**
  33680. * Gets the cached effect (ie. the latest rendered one)
  33681. * @returns the cached effect
  33682. */
  33683. getCachedEffect(): Nullable<Effect>;
  33684. /**
  33685. * Gets the cached visibility state (ie. the latest rendered one)
  33686. * @returns the cached visibility state
  33687. */
  33688. getCachedVisibility(): Nullable<number>;
  33689. /**
  33690. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33691. * @param material defines the current material
  33692. * @param effect defines the current effect
  33693. * @param visibility defines the current visibility state
  33694. * @returns true if one parameter is not cached
  33695. */
  33696. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33697. /**
  33698. * Gets the engine associated with the scene
  33699. * @returns an Engine
  33700. */
  33701. getEngine(): Engine;
  33702. /**
  33703. * Gets the total number of vertices rendered per frame
  33704. * @returns the total number of vertices rendered per frame
  33705. */
  33706. getTotalVertices(): number;
  33707. /**
  33708. * Gets the performance counter for total vertices
  33709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33710. */
  33711. readonly totalVerticesPerfCounter: PerfCounter;
  33712. /**
  33713. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33714. * @returns the total number of active indices rendered per frame
  33715. */
  33716. getActiveIndices(): number;
  33717. /**
  33718. * Gets the performance counter for active indices
  33719. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33720. */
  33721. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33722. /**
  33723. * Gets the total number of active particles rendered per frame
  33724. * @returns the total number of active particles rendered per frame
  33725. */
  33726. getActiveParticles(): number;
  33727. /**
  33728. * Gets the performance counter for active particles
  33729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33730. */
  33731. readonly activeParticlesPerfCounter: PerfCounter;
  33732. /**
  33733. * Gets the total number of active bones rendered per frame
  33734. * @returns the total number of active bones rendered per frame
  33735. */
  33736. getActiveBones(): number;
  33737. /**
  33738. * Gets the performance counter for active bones
  33739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33740. */
  33741. readonly activeBonesPerfCounter: PerfCounter;
  33742. /**
  33743. * Gets the array of active meshes
  33744. * @returns an array of AbstractMesh
  33745. */
  33746. getActiveMeshes(): SmartArray<AbstractMesh>;
  33747. /**
  33748. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33749. * @returns a number
  33750. */
  33751. getAnimationRatio(): number;
  33752. /**
  33753. * Gets an unique Id for the current render phase
  33754. * @returns a number
  33755. */
  33756. getRenderId(): number;
  33757. /**
  33758. * Gets an unique Id for the current frame
  33759. * @returns a number
  33760. */
  33761. getFrameId(): number;
  33762. /** Call this function if you want to manually increment the render Id*/
  33763. incrementRenderId(): void;
  33764. private _createUbo;
  33765. /**
  33766. * Use this method to simulate a pointer move on a mesh
  33767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33770. * @returns the current scene
  33771. */
  33772. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33773. /**
  33774. * Use this method to simulate a pointer down on a mesh
  33775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33778. * @returns the current scene
  33779. */
  33780. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33781. /**
  33782. * Use this method to simulate a pointer up on a mesh
  33783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33786. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33787. * @returns the current scene
  33788. */
  33789. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33790. /**
  33791. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33792. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33793. * @returns true if the pointer was captured
  33794. */
  33795. isPointerCaptured(pointerId?: number): boolean;
  33796. /**
  33797. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33798. * @param attachUp defines if you want to attach events to pointerup
  33799. * @param attachDown defines if you want to attach events to pointerdown
  33800. * @param attachMove defines if you want to attach events to pointermove
  33801. */
  33802. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33803. /** Detaches all event handlers*/
  33804. detachControl(): void;
  33805. /**
  33806. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33807. * Delay loaded resources are not taking in account
  33808. * @return true if all required resources are ready
  33809. */
  33810. isReady(): boolean;
  33811. /** Resets all cached information relative to material (including effect and visibility) */
  33812. resetCachedMaterial(): void;
  33813. /**
  33814. * Registers a function to be called before every frame render
  33815. * @param func defines the function to register
  33816. */
  33817. registerBeforeRender(func: () => void): void;
  33818. /**
  33819. * Unregisters a function called before every frame render
  33820. * @param func defines the function to unregister
  33821. */
  33822. unregisterBeforeRender(func: () => void): void;
  33823. /**
  33824. * Registers a function to be called after every frame render
  33825. * @param func defines the function to register
  33826. */
  33827. registerAfterRender(func: () => void): void;
  33828. /**
  33829. * Unregisters a function called after every frame render
  33830. * @param func defines the function to unregister
  33831. */
  33832. unregisterAfterRender(func: () => void): void;
  33833. private _executeOnceBeforeRender;
  33834. /**
  33835. * The provided function will run before render once and will be disposed afterwards.
  33836. * A timeout delay can be provided so that the function will be executed in N ms.
  33837. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33838. * @param func The function to be executed.
  33839. * @param timeout optional delay in ms
  33840. */
  33841. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33842. /** @hidden */
  33843. _addPendingData(data: any): void;
  33844. /** @hidden */
  33845. _removePendingData(data: any): void;
  33846. /**
  33847. * Returns the number of items waiting to be loaded
  33848. * @returns the number of items waiting to be loaded
  33849. */
  33850. getWaitingItemsCount(): number;
  33851. /**
  33852. * Returns a boolean indicating if the scene is still loading data
  33853. */
  33854. readonly isLoading: boolean;
  33855. /**
  33856. * Registers a function to be executed when the scene is ready
  33857. * @param {Function} func - the function to be executed
  33858. */
  33859. executeWhenReady(func: () => void): void;
  33860. /**
  33861. * Returns a promise that resolves when the scene is ready
  33862. * @returns A promise that resolves when the scene is ready
  33863. */
  33864. whenReadyAsync(): Promise<void>;
  33865. /** @hidden */
  33866. _checkIsReady(): void;
  33867. /**
  33868. * Gets all animatable attached to the scene
  33869. */
  33870. readonly animatables: Animatable[];
  33871. /**
  33872. * Resets the last animation time frame.
  33873. * Useful to override when animations start running when loading a scene for the first time.
  33874. */
  33875. resetLastAnimationTimeFrame(): void;
  33876. /**
  33877. * Gets the current view matrix
  33878. * @returns a Matrix
  33879. */
  33880. getViewMatrix(): Matrix;
  33881. /**
  33882. * Gets the current projection matrix
  33883. * @returns a Matrix
  33884. */
  33885. getProjectionMatrix(): Matrix;
  33886. /**
  33887. * Gets the current transform matrix
  33888. * @returns a Matrix made of View * Projection
  33889. */
  33890. getTransformMatrix(): Matrix;
  33891. /**
  33892. * Sets the current transform matrix
  33893. * @param viewL defines the View matrix to use
  33894. * @param projectionL defines the Projection matrix to use
  33895. * @param viewR defines the right View matrix to use (if provided)
  33896. * @param projectionR defines the right Projection matrix to use (if provided)
  33897. */
  33898. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33899. /**
  33900. * Gets the uniform buffer used to store scene data
  33901. * @returns a UniformBuffer
  33902. */
  33903. getSceneUniformBuffer(): UniformBuffer;
  33904. /**
  33905. * Gets an unique (relatively to the current scene) Id
  33906. * @returns an unique number for the scene
  33907. */
  33908. getUniqueId(): number;
  33909. /**
  33910. * Add a mesh to the list of scene's meshes
  33911. * @param newMesh defines the mesh to add
  33912. * @param recursive if all child meshes should also be added to the scene
  33913. */
  33914. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33915. /**
  33916. * Remove a mesh for the list of scene's meshes
  33917. * @param toRemove defines the mesh to remove
  33918. * @param recursive if all child meshes should also be removed from the scene
  33919. * @returns the index where the mesh was in the mesh list
  33920. */
  33921. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33922. /**
  33923. * Add a transform node to the list of scene's transform nodes
  33924. * @param newTransformNode defines the transform node to add
  33925. */
  33926. addTransformNode(newTransformNode: TransformNode): void;
  33927. /**
  33928. * Remove a transform node for the list of scene's transform nodes
  33929. * @param toRemove defines the transform node to remove
  33930. * @returns the index where the transform node was in the transform node list
  33931. */
  33932. removeTransformNode(toRemove: TransformNode): number;
  33933. /**
  33934. * Remove a skeleton for the list of scene's skeletons
  33935. * @param toRemove defines the skeleton to remove
  33936. * @returns the index where the skeleton was in the skeleton list
  33937. */
  33938. removeSkeleton(toRemove: Skeleton): number;
  33939. /**
  33940. * Remove a morph target for the list of scene's morph targets
  33941. * @param toRemove defines the morph target to remove
  33942. * @returns the index where the morph target was in the morph target list
  33943. */
  33944. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33945. /**
  33946. * Remove a light for the list of scene's lights
  33947. * @param toRemove defines the light to remove
  33948. * @returns the index where the light was in the light list
  33949. */
  33950. removeLight(toRemove: Light): number;
  33951. /**
  33952. * Remove a camera for the list of scene's cameras
  33953. * @param toRemove defines the camera to remove
  33954. * @returns the index where the camera was in the camera list
  33955. */
  33956. removeCamera(toRemove: Camera): number;
  33957. /**
  33958. * Remove a particle system for the list of scene's particle systems
  33959. * @param toRemove defines the particle system to remove
  33960. * @returns the index where the particle system was in the particle system list
  33961. */
  33962. removeParticleSystem(toRemove: IParticleSystem): number;
  33963. /**
  33964. * Remove a animation for the list of scene's animations
  33965. * @param toRemove defines the animation to remove
  33966. * @returns the index where the animation was in the animation list
  33967. */
  33968. removeAnimation(toRemove: Animation): number;
  33969. /**
  33970. * Will stop the animation of the given target
  33971. * @param target - the target
  33972. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33973. * @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)
  33974. */
  33975. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33976. /**
  33977. * Removes the given animation group from this scene.
  33978. * @param toRemove The animation group to remove
  33979. * @returns The index of the removed animation group
  33980. */
  33981. removeAnimationGroup(toRemove: AnimationGroup): number;
  33982. /**
  33983. * Removes the given multi-material from this scene.
  33984. * @param toRemove The multi-material to remove
  33985. * @returns The index of the removed multi-material
  33986. */
  33987. removeMultiMaterial(toRemove: MultiMaterial): number;
  33988. /**
  33989. * Removes the given material from this scene.
  33990. * @param toRemove The material to remove
  33991. * @returns The index of the removed material
  33992. */
  33993. removeMaterial(toRemove: Material): number;
  33994. /**
  33995. * Removes the given action manager from this scene.
  33996. * @param toRemove The action manager to remove
  33997. * @returns The index of the removed action manager
  33998. */
  33999. removeActionManager(toRemove: AbstractActionManager): number;
  34000. /**
  34001. * Removes the given texture from this scene.
  34002. * @param toRemove The texture to remove
  34003. * @returns The index of the removed texture
  34004. */
  34005. removeTexture(toRemove: BaseTexture): number;
  34006. /**
  34007. * Adds the given light to this scene
  34008. * @param newLight The light to add
  34009. */
  34010. addLight(newLight: Light): void;
  34011. /**
  34012. * Sorts the list list based on light priorities
  34013. */
  34014. sortLightsByPriority(): void;
  34015. /**
  34016. * Adds the given camera to this scene
  34017. * @param newCamera The camera to add
  34018. */
  34019. addCamera(newCamera: Camera): void;
  34020. /**
  34021. * Adds the given skeleton to this scene
  34022. * @param newSkeleton The skeleton to add
  34023. */
  34024. addSkeleton(newSkeleton: Skeleton): void;
  34025. /**
  34026. * Adds the given particle system to this scene
  34027. * @param newParticleSystem The particle system to add
  34028. */
  34029. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34030. /**
  34031. * Adds the given animation to this scene
  34032. * @param newAnimation The animation to add
  34033. */
  34034. addAnimation(newAnimation: Animation): void;
  34035. /**
  34036. * Adds the given animation group to this scene.
  34037. * @param newAnimationGroup The animation group to add
  34038. */
  34039. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34040. /**
  34041. * Adds the given multi-material to this scene
  34042. * @param newMultiMaterial The multi-material to add
  34043. */
  34044. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34045. /**
  34046. * Adds the given material to this scene
  34047. * @param newMaterial The material to add
  34048. */
  34049. addMaterial(newMaterial: Material): void;
  34050. /**
  34051. * Adds the given morph target to this scene
  34052. * @param newMorphTargetManager The morph target to add
  34053. */
  34054. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34055. /**
  34056. * Adds the given geometry to this scene
  34057. * @param newGeometry The geometry to add
  34058. */
  34059. addGeometry(newGeometry: Geometry): void;
  34060. /**
  34061. * Adds the given action manager to this scene
  34062. * @param newActionManager The action manager to add
  34063. */
  34064. addActionManager(newActionManager: AbstractActionManager): void;
  34065. /**
  34066. * Adds the given texture to this scene.
  34067. * @param newTexture The texture to add
  34068. */
  34069. addTexture(newTexture: BaseTexture): void;
  34070. /**
  34071. * Switch active camera
  34072. * @param newCamera defines the new active camera
  34073. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34074. */
  34075. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34076. /**
  34077. * sets the active camera of the scene using its ID
  34078. * @param id defines the camera's ID
  34079. * @return the new active camera or null if none found.
  34080. */
  34081. setActiveCameraByID(id: string): Nullable<Camera>;
  34082. /**
  34083. * sets the active camera of the scene using its name
  34084. * @param name defines the camera's name
  34085. * @returns the new active camera or null if none found.
  34086. */
  34087. setActiveCameraByName(name: string): Nullable<Camera>;
  34088. /**
  34089. * get an animation group using its name
  34090. * @param name defines the material's name
  34091. * @return the animation group or null if none found.
  34092. */
  34093. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34094. /**
  34095. * Get a material using its unique id
  34096. * @param uniqueId defines the material's unique id
  34097. * @return the material or null if none found.
  34098. */
  34099. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34100. /**
  34101. * get a material using its id
  34102. * @param id defines the material's ID
  34103. * @return the material or null if none found.
  34104. */
  34105. getMaterialByID(id: string): Nullable<Material>;
  34106. /**
  34107. * Gets a material using its name
  34108. * @param name defines the material's name
  34109. * @return the material or null if none found.
  34110. */
  34111. getMaterialByName(name: string): Nullable<Material>;
  34112. /**
  34113. * Gets a camera using its id
  34114. * @param id defines the id to look for
  34115. * @returns the camera or null if not found
  34116. */
  34117. getCameraByID(id: string): Nullable<Camera>;
  34118. /**
  34119. * Gets a camera using its unique id
  34120. * @param uniqueId defines the unique id to look for
  34121. * @returns the camera or null if not found
  34122. */
  34123. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34124. /**
  34125. * Gets a camera using its name
  34126. * @param name defines the camera's name
  34127. * @return the camera or null if none found.
  34128. */
  34129. getCameraByName(name: string): Nullable<Camera>;
  34130. /**
  34131. * Gets a bone using its id
  34132. * @param id defines the bone's id
  34133. * @return the bone or null if not found
  34134. */
  34135. getBoneByID(id: string): Nullable<Bone>;
  34136. /**
  34137. * Gets a bone using its id
  34138. * @param name defines the bone's name
  34139. * @return the bone or null if not found
  34140. */
  34141. getBoneByName(name: string): Nullable<Bone>;
  34142. /**
  34143. * Gets a light node using its name
  34144. * @param name defines the the light's name
  34145. * @return the light or null if none found.
  34146. */
  34147. getLightByName(name: string): Nullable<Light>;
  34148. /**
  34149. * Gets a light node using its id
  34150. * @param id defines the light's id
  34151. * @return the light or null if none found.
  34152. */
  34153. getLightByID(id: string): Nullable<Light>;
  34154. /**
  34155. * Gets a light node using its scene-generated unique ID
  34156. * @param uniqueId defines the light's unique id
  34157. * @return the light or null if none found.
  34158. */
  34159. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34160. /**
  34161. * Gets a particle system by id
  34162. * @param id defines the particle system id
  34163. * @return the corresponding system or null if none found
  34164. */
  34165. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34166. /**
  34167. * Gets a geometry using its ID
  34168. * @param id defines the geometry's id
  34169. * @return the geometry or null if none found.
  34170. */
  34171. getGeometryByID(id: string): Nullable<Geometry>;
  34172. private _getGeometryByUniqueID;
  34173. /**
  34174. * Add a new geometry to this scene
  34175. * @param geometry defines the geometry to be added to the scene.
  34176. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34177. * @return a boolean defining if the geometry was added or not
  34178. */
  34179. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34180. /**
  34181. * Removes an existing geometry
  34182. * @param geometry defines the geometry to be removed from the scene
  34183. * @return a boolean defining if the geometry was removed or not
  34184. */
  34185. removeGeometry(geometry: Geometry): boolean;
  34186. /**
  34187. * Gets the list of geometries attached to the scene
  34188. * @returns an array of Geometry
  34189. */
  34190. getGeometries(): Geometry[];
  34191. /**
  34192. * Gets the first added mesh found of a given ID
  34193. * @param id defines the id to search for
  34194. * @return the mesh found or null if not found at all
  34195. */
  34196. getMeshByID(id: string): Nullable<AbstractMesh>;
  34197. /**
  34198. * Gets a list of meshes using their id
  34199. * @param id defines the id to search for
  34200. * @returns a list of meshes
  34201. */
  34202. getMeshesByID(id: string): Array<AbstractMesh>;
  34203. /**
  34204. * Gets the first added transform node found of a given ID
  34205. * @param id defines the id to search for
  34206. * @return the found transform node or null if not found at all.
  34207. */
  34208. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34209. /**
  34210. * Gets a transform node with its auto-generated unique id
  34211. * @param uniqueId efines the unique id to search for
  34212. * @return the found transform node or null if not found at all.
  34213. */
  34214. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34215. /**
  34216. * Gets a list of transform nodes using their id
  34217. * @param id defines the id to search for
  34218. * @returns a list of transform nodes
  34219. */
  34220. getTransformNodesByID(id: string): Array<TransformNode>;
  34221. /**
  34222. * Gets a mesh with its auto-generated unique id
  34223. * @param uniqueId defines the unique id to search for
  34224. * @return the found mesh or null if not found at all.
  34225. */
  34226. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34227. /**
  34228. * Gets a the last added mesh using a given id
  34229. * @param id defines the id to search for
  34230. * @return the found mesh or null if not found at all.
  34231. */
  34232. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34233. /**
  34234. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34235. * @param id defines the id to search for
  34236. * @return the found node or null if not found at all
  34237. */
  34238. getLastEntryByID(id: string): Nullable<Node>;
  34239. /**
  34240. * Gets a node (Mesh, Camera, Light) using a given id
  34241. * @param id defines the id to search for
  34242. * @return the found node or null if not found at all
  34243. */
  34244. getNodeByID(id: string): Nullable<Node>;
  34245. /**
  34246. * Gets a node (Mesh, Camera, Light) using a given name
  34247. * @param name defines the name to search for
  34248. * @return the found node or null if not found at all.
  34249. */
  34250. getNodeByName(name: string): Nullable<Node>;
  34251. /**
  34252. * Gets a mesh using a given name
  34253. * @param name defines the name to search for
  34254. * @return the found mesh or null if not found at all.
  34255. */
  34256. getMeshByName(name: string): Nullable<AbstractMesh>;
  34257. /**
  34258. * Gets a transform node using a given name
  34259. * @param name defines the name to search for
  34260. * @return the found transform node or null if not found at all.
  34261. */
  34262. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34263. /**
  34264. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34265. * @param id defines the id to search for
  34266. * @return the found skeleton or null if not found at all.
  34267. */
  34268. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34269. /**
  34270. * Gets a skeleton using a given auto generated unique id
  34271. * @param uniqueId defines the unique id to search for
  34272. * @return the found skeleton or null if not found at all.
  34273. */
  34274. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34275. /**
  34276. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34277. * @param id defines the id to search for
  34278. * @return the found skeleton or null if not found at all.
  34279. */
  34280. getSkeletonById(id: string): Nullable<Skeleton>;
  34281. /**
  34282. * Gets a skeleton using a given name
  34283. * @param name defines the name to search for
  34284. * @return the found skeleton or null if not found at all.
  34285. */
  34286. getSkeletonByName(name: string): Nullable<Skeleton>;
  34287. /**
  34288. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34289. * @param id defines the id to search for
  34290. * @return the found morph target manager or null if not found at all.
  34291. */
  34292. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34293. /**
  34294. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34295. * @param id defines the id to search for
  34296. * @return the found morph target or null if not found at all.
  34297. */
  34298. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34299. /**
  34300. * Gets a boolean indicating if the given mesh is active
  34301. * @param mesh defines the mesh to look for
  34302. * @returns true if the mesh is in the active list
  34303. */
  34304. isActiveMesh(mesh: AbstractMesh): boolean;
  34305. /**
  34306. * Return a unique id as a string which can serve as an identifier for the scene
  34307. */
  34308. readonly uid: string;
  34309. /**
  34310. * Add an externaly attached data from its key.
  34311. * This method call will fail and return false, if such key already exists.
  34312. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34313. * @param key the unique key that identifies the data
  34314. * @param data the data object to associate to the key for this Engine instance
  34315. * @return true if no such key were already present and the data was added successfully, false otherwise
  34316. */
  34317. addExternalData<T>(key: string, data: T): boolean;
  34318. /**
  34319. * Get an externaly attached data from its key
  34320. * @param key the unique key that identifies the data
  34321. * @return the associated data, if present (can be null), or undefined if not present
  34322. */
  34323. getExternalData<T>(key: string): Nullable<T>;
  34324. /**
  34325. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34326. * @param key the unique key that identifies the data
  34327. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34328. * @return the associated data, can be null if the factory returned null.
  34329. */
  34330. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34331. /**
  34332. * Remove an externaly attached data from the Engine instance
  34333. * @param key the unique key that identifies the data
  34334. * @return true if the data was successfully removed, false if it doesn't exist
  34335. */
  34336. removeExternalData(key: string): boolean;
  34337. private _evaluateSubMesh;
  34338. /**
  34339. * Clear the processed materials smart array preventing retention point in material dispose.
  34340. */
  34341. freeProcessedMaterials(): void;
  34342. private _preventFreeActiveMeshesAndRenderingGroups;
  34343. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34344. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34345. * when disposing several meshes in a row or a hierarchy of meshes.
  34346. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34347. */
  34348. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34349. /**
  34350. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34351. */
  34352. freeActiveMeshes(): void;
  34353. /**
  34354. * Clear the info related to rendering groups preventing retention points during dispose.
  34355. */
  34356. freeRenderingGroups(): void;
  34357. /** @hidden */
  34358. _isInIntermediateRendering(): boolean;
  34359. /**
  34360. * Lambda returning the list of potentially active meshes.
  34361. */
  34362. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34363. /**
  34364. * Lambda returning the list of potentially active sub meshes.
  34365. */
  34366. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34367. /**
  34368. * Lambda returning the list of potentially intersecting sub meshes.
  34369. */
  34370. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34371. /**
  34372. * Lambda returning the list of potentially colliding sub meshes.
  34373. */
  34374. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34375. private _activeMeshesFrozen;
  34376. /**
  34377. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34378. * @returns the current scene
  34379. */
  34380. freezeActiveMeshes(): Scene;
  34381. /**
  34382. * Use this function to restart evaluating active meshes on every frame
  34383. * @returns the current scene
  34384. */
  34385. unfreezeActiveMeshes(): Scene;
  34386. private _evaluateActiveMeshes;
  34387. private _activeMesh;
  34388. /**
  34389. * Update the transform matrix to update from the current active camera
  34390. * @param force defines a boolean used to force the update even if cache is up to date
  34391. */
  34392. updateTransformMatrix(force?: boolean): void;
  34393. private _bindFrameBuffer;
  34394. /** @hidden */
  34395. _allowPostProcessClearColor: boolean;
  34396. /** @hidden */
  34397. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34398. private _processSubCameras;
  34399. private _checkIntersections;
  34400. /** @hidden */
  34401. _advancePhysicsEngineStep(step: number): void;
  34402. /**
  34403. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34404. */
  34405. getDeterministicFrameTime: () => number;
  34406. /** @hidden */
  34407. _animate(): void;
  34408. /** Execute all animations (for a frame) */
  34409. animate(): void;
  34410. /**
  34411. * Render the scene
  34412. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34413. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34414. */
  34415. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34416. /**
  34417. * Freeze all materials
  34418. * A frozen material will not be updatable but should be faster to render
  34419. */
  34420. freezeMaterials(): void;
  34421. /**
  34422. * Unfreeze all materials
  34423. * A frozen material will not be updatable but should be faster to render
  34424. */
  34425. unfreezeMaterials(): void;
  34426. /**
  34427. * Releases all held ressources
  34428. */
  34429. dispose(): void;
  34430. /**
  34431. * Gets if the scene is already disposed
  34432. */
  34433. readonly isDisposed: boolean;
  34434. /**
  34435. * Call this function to reduce memory footprint of the scene.
  34436. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34437. */
  34438. clearCachedVertexData(): void;
  34439. /**
  34440. * This function will remove the local cached buffer data from texture.
  34441. * It will save memory but will prevent the texture from being rebuilt
  34442. */
  34443. cleanCachedTextureBuffer(): void;
  34444. /**
  34445. * Get the world extend vectors with an optional filter
  34446. *
  34447. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34448. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34449. */
  34450. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34451. min: Vector3;
  34452. max: Vector3;
  34453. };
  34454. /**
  34455. * Creates a ray that can be used to pick in the scene
  34456. * @param x defines the x coordinate of the origin (on-screen)
  34457. * @param y defines the y coordinate of the origin (on-screen)
  34458. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34459. * @param camera defines the camera to use for the picking
  34460. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34461. * @returns a Ray
  34462. */
  34463. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34464. /**
  34465. * Creates a ray that can be used to pick in the scene
  34466. * @param x defines the x coordinate of the origin (on-screen)
  34467. * @param y defines the y coordinate of the origin (on-screen)
  34468. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34469. * @param result defines the ray where to store the picking ray
  34470. * @param camera defines the camera to use for the picking
  34471. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34472. * @returns the current scene
  34473. */
  34474. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34475. /**
  34476. * Creates a ray that can be used to pick in the scene
  34477. * @param x defines the x coordinate of the origin (on-screen)
  34478. * @param y defines the y coordinate of the origin (on-screen)
  34479. * @param camera defines the camera to use for the picking
  34480. * @returns a Ray
  34481. */
  34482. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34483. /**
  34484. * Creates a ray that can be used to pick in the scene
  34485. * @param x defines the x coordinate of the origin (on-screen)
  34486. * @param y defines the y coordinate of the origin (on-screen)
  34487. * @param result defines the ray where to store the picking ray
  34488. * @param camera defines the camera to use for the picking
  34489. * @returns the current scene
  34490. */
  34491. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34492. /** Launch a ray to try to pick a mesh in the scene
  34493. * @param x position on screen
  34494. * @param y position on screen
  34495. * @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
  34496. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34497. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34498. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34499. * @returns a PickingInfo
  34500. */
  34501. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34502. /** Use the given ray to pick a mesh in the scene
  34503. * @param ray The ray to use to pick meshes
  34504. * @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
  34505. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34506. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34507. * @returns a PickingInfo
  34508. */
  34509. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34510. /**
  34511. * Launch a ray to try to pick a mesh in the scene
  34512. * @param x X position on screen
  34513. * @param y Y position on screen
  34514. * @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
  34515. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34516. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34517. * @returns an array of PickingInfo
  34518. */
  34519. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34520. /**
  34521. * Launch a ray to try to pick a mesh in the scene
  34522. * @param ray Ray to use
  34523. * @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
  34524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34525. * @returns an array of PickingInfo
  34526. */
  34527. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34528. /**
  34529. * Force the value of meshUnderPointer
  34530. * @param mesh defines the mesh to use
  34531. */
  34532. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34533. /**
  34534. * Gets the mesh under the pointer
  34535. * @returns a Mesh or null if no mesh is under the pointer
  34536. */
  34537. getPointerOverMesh(): Nullable<AbstractMesh>;
  34538. /** @hidden */
  34539. _rebuildGeometries(): void;
  34540. /** @hidden */
  34541. _rebuildTextures(): void;
  34542. private _getByTags;
  34543. /**
  34544. * Get a list of meshes by tags
  34545. * @param tagsQuery defines the tags query to use
  34546. * @param forEach defines a predicate used to filter results
  34547. * @returns an array of Mesh
  34548. */
  34549. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34550. /**
  34551. * Get a list of cameras by tags
  34552. * @param tagsQuery defines the tags query to use
  34553. * @param forEach defines a predicate used to filter results
  34554. * @returns an array of Camera
  34555. */
  34556. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34557. /**
  34558. * Get a list of lights by tags
  34559. * @param tagsQuery defines the tags query to use
  34560. * @param forEach defines a predicate used to filter results
  34561. * @returns an array of Light
  34562. */
  34563. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34564. /**
  34565. * Get a list of materials by tags
  34566. * @param tagsQuery defines the tags query to use
  34567. * @param forEach defines a predicate used to filter results
  34568. * @returns an array of Material
  34569. */
  34570. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34571. /**
  34572. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34573. * This allowed control for front to back rendering or reversly depending of the special needs.
  34574. *
  34575. * @param renderingGroupId The rendering group id corresponding to its index
  34576. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34577. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34578. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34579. */
  34580. 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;
  34581. /**
  34582. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34583. *
  34584. * @param renderingGroupId The rendering group id corresponding to its index
  34585. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34586. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34587. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34588. */
  34589. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34590. /**
  34591. * Gets the current auto clear configuration for one rendering group of the rendering
  34592. * manager.
  34593. * @param index the rendering group index to get the information for
  34594. * @returns The auto clear setup for the requested rendering group
  34595. */
  34596. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34597. private _blockMaterialDirtyMechanism;
  34598. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34599. blockMaterialDirtyMechanism: boolean;
  34600. /**
  34601. * Will flag all materials as dirty to trigger new shader compilation
  34602. * @param flag defines the flag used to specify which material part must be marked as dirty
  34603. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34604. */
  34605. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34606. /** @hidden */
  34607. _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;
  34608. /** @hidden */
  34609. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34610. }
  34611. }
  34612. declare module "babylonjs/assetContainer" {
  34613. import { AbstractScene } from "babylonjs/abstractScene";
  34614. import { Scene } from "babylonjs/scene";
  34615. import { Mesh } from "babylonjs/Meshes/mesh";
  34616. /**
  34617. * Set of assets to keep when moving a scene into an asset container.
  34618. */
  34619. export class KeepAssets extends AbstractScene {
  34620. }
  34621. /**
  34622. * Container with a set of assets that can be added or removed from a scene.
  34623. */
  34624. export class AssetContainer extends AbstractScene {
  34625. /**
  34626. * The scene the AssetContainer belongs to.
  34627. */
  34628. scene: Scene;
  34629. /**
  34630. * Instantiates an AssetContainer.
  34631. * @param scene The scene the AssetContainer belongs to.
  34632. */
  34633. constructor(scene: Scene);
  34634. /**
  34635. * Adds all the assets from the container to the scene.
  34636. */
  34637. addAllToScene(): void;
  34638. /**
  34639. * Removes all the assets in the container from the scene
  34640. */
  34641. removeAllFromScene(): void;
  34642. /**
  34643. * Disposes all the assets in the container
  34644. */
  34645. dispose(): void;
  34646. private _moveAssets;
  34647. /**
  34648. * Removes all the assets contained in the scene and adds them to the container.
  34649. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34650. */
  34651. moveAllFromScene(keepAssets?: KeepAssets): void;
  34652. /**
  34653. * 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.
  34654. * @returns the root mesh
  34655. */
  34656. createRootMesh(): Mesh;
  34657. }
  34658. }
  34659. declare module "babylonjs/abstractScene" {
  34660. import { Scene } from "babylonjs/scene";
  34661. import { Nullable } from "babylonjs/types";
  34662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34663. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34664. import { Geometry } from "babylonjs/Meshes/geometry";
  34665. import { Skeleton } from "babylonjs/Bones/skeleton";
  34666. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34667. import { AssetContainer } from "babylonjs/assetContainer";
  34668. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34669. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34671. import { Material } from "babylonjs/Materials/material";
  34672. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34673. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34674. import { Camera } from "babylonjs/Cameras/camera";
  34675. import { Light } from "babylonjs/Lights/light";
  34676. import { Node } from "babylonjs/node";
  34677. import { Animation } from "babylonjs/Animations/animation";
  34678. /**
  34679. * Defines how the parser contract is defined.
  34680. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34681. */
  34682. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34683. /**
  34684. * Defines how the individual parser contract is defined.
  34685. * These parser can parse an individual asset
  34686. */
  34687. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34688. /**
  34689. * Base class of the scene acting as a container for the different elements composing a scene.
  34690. * This class is dynamically extended by the different components of the scene increasing
  34691. * flexibility and reducing coupling
  34692. */
  34693. export abstract class AbstractScene {
  34694. /**
  34695. * Stores the list of available parsers in the application.
  34696. */
  34697. private static _BabylonFileParsers;
  34698. /**
  34699. * Stores the list of available individual parsers in the application.
  34700. */
  34701. private static _IndividualBabylonFileParsers;
  34702. /**
  34703. * Adds a parser in the list of available ones
  34704. * @param name Defines the name of the parser
  34705. * @param parser Defines the parser to add
  34706. */
  34707. static AddParser(name: string, parser: BabylonFileParser): void;
  34708. /**
  34709. * Gets a general parser from the list of avaialble ones
  34710. * @param name Defines the name of the parser
  34711. * @returns the requested parser or null
  34712. */
  34713. static GetParser(name: string): Nullable<BabylonFileParser>;
  34714. /**
  34715. * Adds n individual parser in the list of available ones
  34716. * @param name Defines the name of the parser
  34717. * @param parser Defines the parser to add
  34718. */
  34719. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34720. /**
  34721. * Gets an individual parser from the list of avaialble ones
  34722. * @param name Defines the name of the parser
  34723. * @returns the requested parser or null
  34724. */
  34725. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34726. /**
  34727. * Parser json data and populate both a scene and its associated container object
  34728. * @param jsonData Defines the data to parse
  34729. * @param scene Defines the scene to parse the data for
  34730. * @param container Defines the container attached to the parsing sequence
  34731. * @param rootUrl Defines the root url of the data
  34732. */
  34733. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34734. /**
  34735. * Gets the list of root nodes (ie. nodes with no parent)
  34736. */
  34737. rootNodes: Node[];
  34738. /** All of the cameras added to this scene
  34739. * @see http://doc.babylonjs.com/babylon101/cameras
  34740. */
  34741. cameras: Camera[];
  34742. /**
  34743. * All of the lights added to this scene
  34744. * @see http://doc.babylonjs.com/babylon101/lights
  34745. */
  34746. lights: Light[];
  34747. /**
  34748. * All of the (abstract) meshes added to this scene
  34749. */
  34750. meshes: AbstractMesh[];
  34751. /**
  34752. * The list of skeletons added to the scene
  34753. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34754. */
  34755. skeletons: Skeleton[];
  34756. /**
  34757. * All of the particle systems added to this scene
  34758. * @see http://doc.babylonjs.com/babylon101/particles
  34759. */
  34760. particleSystems: IParticleSystem[];
  34761. /**
  34762. * Gets a list of Animations associated with the scene
  34763. */
  34764. animations: Animation[];
  34765. /**
  34766. * All of the animation groups added to this scene
  34767. * @see http://doc.babylonjs.com/how_to/group
  34768. */
  34769. animationGroups: AnimationGroup[];
  34770. /**
  34771. * All of the multi-materials added to this scene
  34772. * @see http://doc.babylonjs.com/how_to/multi_materials
  34773. */
  34774. multiMaterials: MultiMaterial[];
  34775. /**
  34776. * All of the materials added to this scene
  34777. * In the context of a Scene, it is not supposed to be modified manually.
  34778. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34779. * Note also that the order of the Material wihin the array is not significant and might change.
  34780. * @see http://doc.babylonjs.com/babylon101/materials
  34781. */
  34782. materials: Material[];
  34783. /**
  34784. * The list of morph target managers added to the scene
  34785. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34786. */
  34787. morphTargetManagers: MorphTargetManager[];
  34788. /**
  34789. * The list of geometries used in the scene.
  34790. */
  34791. geometries: Geometry[];
  34792. /**
  34793. * All of the tranform nodes added to this scene
  34794. * In the context of a Scene, it is not supposed to be modified manually.
  34795. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34796. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34797. * @see http://doc.babylonjs.com/how_to/transformnode
  34798. */
  34799. transformNodes: TransformNode[];
  34800. /**
  34801. * ActionManagers available on the scene.
  34802. */
  34803. actionManagers: AbstractActionManager[];
  34804. /**
  34805. * Textures to keep.
  34806. */
  34807. textures: BaseTexture[];
  34808. /**
  34809. * Environment texture for the scene
  34810. */
  34811. environmentTexture: Nullable<BaseTexture>;
  34812. }
  34813. }
  34814. declare module "babylonjs/Audio/sound" {
  34815. import { Observable } from "babylonjs/Misc/observable";
  34816. import { Vector3 } from "babylonjs/Maths/math";
  34817. import { Nullable } from "babylonjs/types";
  34818. import { Scene } from "babylonjs/scene";
  34819. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34820. /**
  34821. * Defines a sound that can be played in the application.
  34822. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34824. */
  34825. export class Sound {
  34826. /**
  34827. * The name of the sound in the scene.
  34828. */
  34829. name: string;
  34830. /**
  34831. * Does the sound autoplay once loaded.
  34832. */
  34833. autoplay: boolean;
  34834. /**
  34835. * Does the sound loop after it finishes playing once.
  34836. */
  34837. loop: boolean;
  34838. /**
  34839. * Does the sound use a custom attenuation curve to simulate the falloff
  34840. * happening when the source gets further away from the camera.
  34841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34842. */
  34843. useCustomAttenuation: boolean;
  34844. /**
  34845. * The sound track id this sound belongs to.
  34846. */
  34847. soundTrackId: number;
  34848. /**
  34849. * Is this sound currently played.
  34850. */
  34851. isPlaying: boolean;
  34852. /**
  34853. * Is this sound currently paused.
  34854. */
  34855. isPaused: boolean;
  34856. /**
  34857. * Does this sound enables spatial sound.
  34858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34859. */
  34860. spatialSound: boolean;
  34861. /**
  34862. * Define the reference distance the sound should be heard perfectly.
  34863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34864. */
  34865. refDistance: number;
  34866. /**
  34867. * Define the roll off factor of spatial sounds.
  34868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34869. */
  34870. rolloffFactor: number;
  34871. /**
  34872. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34874. */
  34875. maxDistance: number;
  34876. /**
  34877. * Define the distance attenuation model the sound will follow.
  34878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34879. */
  34880. distanceModel: string;
  34881. /**
  34882. * @hidden
  34883. * Back Compat
  34884. **/
  34885. onended: () => any;
  34886. /**
  34887. * Observable event when the current playing sound finishes.
  34888. */
  34889. onEndedObservable: Observable<Sound>;
  34890. private _panningModel;
  34891. private _playbackRate;
  34892. private _streaming;
  34893. private _startTime;
  34894. private _startOffset;
  34895. private _position;
  34896. /** @hidden */
  34897. _positionInEmitterSpace: boolean;
  34898. private _localDirection;
  34899. private _volume;
  34900. private _isReadyToPlay;
  34901. private _isDirectional;
  34902. private _readyToPlayCallback;
  34903. private _audioBuffer;
  34904. private _soundSource;
  34905. private _streamingSource;
  34906. private _soundPanner;
  34907. private _soundGain;
  34908. private _inputAudioNode;
  34909. private _outputAudioNode;
  34910. private _coneInnerAngle;
  34911. private _coneOuterAngle;
  34912. private _coneOuterGain;
  34913. private _scene;
  34914. private _connectedTransformNode;
  34915. private _customAttenuationFunction;
  34916. private _registerFunc;
  34917. private _isOutputConnected;
  34918. private _htmlAudioElement;
  34919. private _urlType;
  34920. /** @hidden */
  34921. static _SceneComponentInitialization: (scene: Scene) => void;
  34922. /**
  34923. * Create a sound and attach it to a scene
  34924. * @param name Name of your sound
  34925. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34926. * @param scene defines the scene the sound belongs to
  34927. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34928. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34929. */
  34930. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34931. /**
  34932. * Release the sound and its associated resources
  34933. */
  34934. dispose(): void;
  34935. /**
  34936. * Gets if the sounds is ready to be played or not.
  34937. * @returns true if ready, otherwise false
  34938. */
  34939. isReady(): boolean;
  34940. private _soundLoaded;
  34941. /**
  34942. * Sets the data of the sound from an audiobuffer
  34943. * @param audioBuffer The audioBuffer containing the data
  34944. */
  34945. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34946. /**
  34947. * Updates the current sounds options such as maxdistance, loop...
  34948. * @param options A JSON object containing values named as the object properties
  34949. */
  34950. updateOptions(options: any): void;
  34951. private _createSpatialParameters;
  34952. private _updateSpatialParameters;
  34953. /**
  34954. * Switch the panning model to HRTF:
  34955. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34957. */
  34958. switchPanningModelToHRTF(): void;
  34959. /**
  34960. * Switch the panning model to Equal Power:
  34961. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34963. */
  34964. switchPanningModelToEqualPower(): void;
  34965. private _switchPanningModel;
  34966. /**
  34967. * Connect this sound to a sound track audio node like gain...
  34968. * @param soundTrackAudioNode the sound track audio node to connect to
  34969. */
  34970. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34971. /**
  34972. * Transform this sound into a directional source
  34973. * @param coneInnerAngle Size of the inner cone in degree
  34974. * @param coneOuterAngle Size of the outer cone in degree
  34975. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34976. */
  34977. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34978. /**
  34979. * Gets or sets the inner angle for the directional cone.
  34980. */
  34981. /**
  34982. * Gets or sets the inner angle for the directional cone.
  34983. */
  34984. directionalConeInnerAngle: number;
  34985. /**
  34986. * Gets or sets the outer angle for the directional cone.
  34987. */
  34988. /**
  34989. * Gets or sets the outer angle for the directional cone.
  34990. */
  34991. directionalConeOuterAngle: number;
  34992. /**
  34993. * Sets the position of the emitter if spatial sound is enabled
  34994. * @param newPosition Defines the new posisiton
  34995. */
  34996. setPosition(newPosition: Vector3): void;
  34997. /**
  34998. * Sets the local direction of the emitter if spatial sound is enabled
  34999. * @param newLocalDirection Defines the new local direction
  35000. */
  35001. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35002. private _updateDirection;
  35003. /** @hidden */
  35004. updateDistanceFromListener(): void;
  35005. /**
  35006. * Sets a new custom attenuation function for the sound.
  35007. * @param callback Defines the function used for the attenuation
  35008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35009. */
  35010. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35011. /**
  35012. * Play the sound
  35013. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35014. * @param offset (optional) Start the sound setting it at a specific time
  35015. */
  35016. play(time?: number, offset?: number): void;
  35017. private _onended;
  35018. /**
  35019. * Stop the sound
  35020. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35021. */
  35022. stop(time?: number): void;
  35023. /**
  35024. * Put the sound in pause
  35025. */
  35026. pause(): void;
  35027. /**
  35028. * Sets a dedicated volume for this sounds
  35029. * @param newVolume Define the new volume of the sound
  35030. * @param time Define in how long the sound should be at this value
  35031. */
  35032. setVolume(newVolume: number, time?: number): void;
  35033. /**
  35034. * Set the sound play back rate
  35035. * @param newPlaybackRate Define the playback rate the sound should be played at
  35036. */
  35037. setPlaybackRate(newPlaybackRate: number): void;
  35038. /**
  35039. * Gets the volume of the sound.
  35040. * @returns the volume of the sound
  35041. */
  35042. getVolume(): number;
  35043. /**
  35044. * Attach the sound to a dedicated mesh
  35045. * @param transformNode The transform node to connect the sound with
  35046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35047. */
  35048. attachToMesh(transformNode: TransformNode): void;
  35049. /**
  35050. * Detach the sound from the previously attached mesh
  35051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35052. */
  35053. detachFromMesh(): void;
  35054. private _onRegisterAfterWorldMatrixUpdate;
  35055. /**
  35056. * Clone the current sound in the scene.
  35057. * @returns the new sound clone
  35058. */
  35059. clone(): Nullable<Sound>;
  35060. /**
  35061. * Gets the current underlying audio buffer containing the data
  35062. * @returns the audio buffer
  35063. */
  35064. getAudioBuffer(): Nullable<AudioBuffer>;
  35065. /**
  35066. * Serializes the Sound in a JSON representation
  35067. * @returns the JSON representation of the sound
  35068. */
  35069. serialize(): any;
  35070. /**
  35071. * Parse a JSON representation of a sound to innstantiate in a given scene
  35072. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35073. * @param scene Define the scene the new parsed sound should be created in
  35074. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35075. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35076. * @returns the newly parsed sound
  35077. */
  35078. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35079. }
  35080. }
  35081. declare module "babylonjs/Actions/directAudioActions" {
  35082. import { Action } from "babylonjs/Actions/action";
  35083. import { Condition } from "babylonjs/Actions/condition";
  35084. import { Sound } from "babylonjs/Audio/sound";
  35085. /**
  35086. * This defines an action helpful to play a defined sound on a triggered action.
  35087. */
  35088. export class PlaySoundAction extends Action {
  35089. private _sound;
  35090. /**
  35091. * Instantiate the action
  35092. * @param triggerOptions defines the trigger options
  35093. * @param sound defines the sound to play
  35094. * @param condition defines the trigger related conditions
  35095. */
  35096. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35097. /** @hidden */
  35098. _prepare(): void;
  35099. /**
  35100. * Execute the action and play the sound.
  35101. */
  35102. execute(): void;
  35103. /**
  35104. * Serializes the actions and its related information.
  35105. * @param parent defines the object to serialize in
  35106. * @returns the serialized object
  35107. */
  35108. serialize(parent: any): any;
  35109. }
  35110. /**
  35111. * This defines an action helpful to stop a defined sound on a triggered action.
  35112. */
  35113. export class StopSoundAction extends Action {
  35114. private _sound;
  35115. /**
  35116. * Instantiate the action
  35117. * @param triggerOptions defines the trigger options
  35118. * @param sound defines the sound to stop
  35119. * @param condition defines the trigger related conditions
  35120. */
  35121. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35122. /** @hidden */
  35123. _prepare(): void;
  35124. /**
  35125. * Execute the action and stop the sound.
  35126. */
  35127. execute(): void;
  35128. /**
  35129. * Serializes the actions and its related information.
  35130. * @param parent defines the object to serialize in
  35131. * @returns the serialized object
  35132. */
  35133. serialize(parent: any): any;
  35134. }
  35135. }
  35136. declare module "babylonjs/Actions/interpolateValueAction" {
  35137. import { Action } from "babylonjs/Actions/action";
  35138. import { Condition } from "babylonjs/Actions/condition";
  35139. import { Observable } from "babylonjs/Misc/observable";
  35140. /**
  35141. * This defines an action responsible to change the value of a property
  35142. * by interpolating between its current value and the newly set one once triggered.
  35143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35144. */
  35145. export class InterpolateValueAction extends Action {
  35146. /**
  35147. * Defines the path of the property where the value should be interpolated
  35148. */
  35149. propertyPath: string;
  35150. /**
  35151. * Defines the target value at the end of the interpolation.
  35152. */
  35153. value: any;
  35154. /**
  35155. * Defines the time it will take for the property to interpolate to the value.
  35156. */
  35157. duration: number;
  35158. /**
  35159. * Defines if the other scene animations should be stopped when the action has been triggered
  35160. */
  35161. stopOtherAnimations?: boolean;
  35162. /**
  35163. * Defines a callback raised once the interpolation animation has been done.
  35164. */
  35165. onInterpolationDone?: () => void;
  35166. /**
  35167. * Observable triggered once the interpolation animation has been done.
  35168. */
  35169. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35170. private _target;
  35171. private _effectiveTarget;
  35172. private _property;
  35173. /**
  35174. * Instantiate the action
  35175. * @param triggerOptions defines the trigger options
  35176. * @param target defines the object containing the value to interpolate
  35177. * @param propertyPath defines the path to the property in the target object
  35178. * @param value defines the target value at the end of the interpolation
  35179. * @param duration deines the time it will take for the property to interpolate to the value.
  35180. * @param condition defines the trigger related conditions
  35181. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35182. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35183. */
  35184. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35185. /** @hidden */
  35186. _prepare(): void;
  35187. /**
  35188. * Execute the action starts the value interpolation.
  35189. */
  35190. execute(): void;
  35191. /**
  35192. * Serializes the actions and its related information.
  35193. * @param parent defines the object to serialize in
  35194. * @returns the serialized object
  35195. */
  35196. serialize(parent: any): any;
  35197. }
  35198. }
  35199. declare module "babylonjs/Actions/index" {
  35200. export * from "babylonjs/Actions/action";
  35201. export * from "babylonjs/Actions/actionEvent";
  35202. export * from "babylonjs/Actions/actionManager";
  35203. export * from "babylonjs/Actions/condition";
  35204. export * from "babylonjs/Actions/directActions";
  35205. export * from "babylonjs/Actions/directAudioActions";
  35206. export * from "babylonjs/Actions/interpolateValueAction";
  35207. }
  35208. declare module "babylonjs/Animations/index" {
  35209. export * from "babylonjs/Animations/animatable";
  35210. export * from "babylonjs/Animations/animation";
  35211. export * from "babylonjs/Animations/animationGroup";
  35212. export * from "babylonjs/Animations/animationPropertiesOverride";
  35213. export * from "babylonjs/Animations/easing";
  35214. export * from "babylonjs/Animations/runtimeAnimation";
  35215. export * from "babylonjs/Animations/animationEvent";
  35216. export * from "babylonjs/Animations/animationGroup";
  35217. export * from "babylonjs/Animations/animationKey";
  35218. export * from "babylonjs/Animations/animationRange";
  35219. }
  35220. declare module "babylonjs/Audio/soundTrack" {
  35221. import { Sound } from "babylonjs/Audio/sound";
  35222. import { Analyser } from "babylonjs/Audio/analyser";
  35223. import { Scene } from "babylonjs/scene";
  35224. /**
  35225. * Options allowed during the creation of a sound track.
  35226. */
  35227. export interface ISoundTrackOptions {
  35228. /**
  35229. * The volume the sound track should take during creation
  35230. */
  35231. volume?: number;
  35232. /**
  35233. * Define if the sound track is the main sound track of the scene
  35234. */
  35235. mainTrack?: boolean;
  35236. }
  35237. /**
  35238. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35239. * It will be also used in a future release to apply effects on a specific track.
  35240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35241. */
  35242. export class SoundTrack {
  35243. /**
  35244. * The unique identifier of the sound track in the scene.
  35245. */
  35246. id: number;
  35247. /**
  35248. * The list of sounds included in the sound track.
  35249. */
  35250. soundCollection: Array<Sound>;
  35251. private _outputAudioNode;
  35252. private _scene;
  35253. private _isMainTrack;
  35254. private _connectedAnalyser;
  35255. private _options;
  35256. private _isInitialized;
  35257. /**
  35258. * Creates a new sound track.
  35259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35260. * @param scene Define the scene the sound track belongs to
  35261. * @param options
  35262. */
  35263. constructor(scene: Scene, options?: ISoundTrackOptions);
  35264. private _initializeSoundTrackAudioGraph;
  35265. /**
  35266. * Release the sound track and its associated resources
  35267. */
  35268. dispose(): void;
  35269. /**
  35270. * Adds a sound to this sound track
  35271. * @param sound define the cound to add
  35272. * @ignoreNaming
  35273. */
  35274. AddSound(sound: Sound): void;
  35275. /**
  35276. * Removes a sound to this sound track
  35277. * @param sound define the cound to remove
  35278. * @ignoreNaming
  35279. */
  35280. RemoveSound(sound: Sound): void;
  35281. /**
  35282. * Set a global volume for the full sound track.
  35283. * @param newVolume Define the new volume of the sound track
  35284. */
  35285. setVolume(newVolume: number): void;
  35286. /**
  35287. * Switch the panning model to HRTF:
  35288. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35290. */
  35291. switchPanningModelToHRTF(): void;
  35292. /**
  35293. * Switch the panning model to Equal Power:
  35294. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35296. */
  35297. switchPanningModelToEqualPower(): void;
  35298. /**
  35299. * Connect the sound track to an audio analyser allowing some amazing
  35300. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35302. * @param analyser The analyser to connect to the engine
  35303. */
  35304. connectToAnalyser(analyser: Analyser): void;
  35305. }
  35306. }
  35307. declare module "babylonjs/Audio/audioSceneComponent" {
  35308. import { Sound } from "babylonjs/Audio/sound";
  35309. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35310. import { Nullable } from "babylonjs/types";
  35311. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35312. import { Scene } from "babylonjs/scene";
  35313. import { AbstractScene } from "babylonjs/abstractScene";
  35314. module "babylonjs/abstractScene" {
  35315. interface AbstractScene {
  35316. /**
  35317. * The list of sounds used in the scene.
  35318. */
  35319. sounds: Nullable<Array<Sound>>;
  35320. }
  35321. }
  35322. module "babylonjs/scene" {
  35323. interface Scene {
  35324. /**
  35325. * @hidden
  35326. * Backing field
  35327. */
  35328. _mainSoundTrack: SoundTrack;
  35329. /**
  35330. * The main sound track played by the scene.
  35331. * It cotains your primary collection of sounds.
  35332. */
  35333. mainSoundTrack: SoundTrack;
  35334. /**
  35335. * The list of sound tracks added to the scene
  35336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35337. */
  35338. soundTracks: Nullable<Array<SoundTrack>>;
  35339. /**
  35340. * Gets a sound using a given name
  35341. * @param name defines the name to search for
  35342. * @return the found sound or null if not found at all.
  35343. */
  35344. getSoundByName(name: string): Nullable<Sound>;
  35345. /**
  35346. * Gets or sets if audio support is enabled
  35347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35348. */
  35349. audioEnabled: boolean;
  35350. /**
  35351. * Gets or sets if audio will be output to headphones
  35352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35353. */
  35354. headphone: boolean;
  35355. }
  35356. }
  35357. /**
  35358. * Defines the sound scene component responsible to manage any sounds
  35359. * in a given scene.
  35360. */
  35361. export class AudioSceneComponent implements ISceneSerializableComponent {
  35362. /**
  35363. * The component name helpfull to identify the component in the list of scene components.
  35364. */
  35365. readonly name: string;
  35366. /**
  35367. * The scene the component belongs to.
  35368. */
  35369. scene: Scene;
  35370. private _audioEnabled;
  35371. /**
  35372. * Gets whether audio is enabled or not.
  35373. * Please use related enable/disable method to switch state.
  35374. */
  35375. readonly audioEnabled: boolean;
  35376. private _headphone;
  35377. /**
  35378. * Gets whether audio is outputing to headphone or not.
  35379. * Please use the according Switch methods to change output.
  35380. */
  35381. readonly headphone: boolean;
  35382. /**
  35383. * Creates a new instance of the component for the given scene
  35384. * @param scene Defines the scene to register the component in
  35385. */
  35386. constructor(scene: Scene);
  35387. /**
  35388. * Registers the component in a given scene
  35389. */
  35390. register(): void;
  35391. /**
  35392. * Rebuilds the elements related to this component in case of
  35393. * context lost for instance.
  35394. */
  35395. rebuild(): void;
  35396. /**
  35397. * Serializes the component data to the specified json object
  35398. * @param serializationObject The object to serialize to
  35399. */
  35400. serialize(serializationObject: any): void;
  35401. /**
  35402. * Adds all the element from the container to the scene
  35403. * @param container the container holding the elements
  35404. */
  35405. addFromContainer(container: AbstractScene): void;
  35406. /**
  35407. * Removes all the elements in the container from the scene
  35408. * @param container contains the elements to remove
  35409. * @param dispose if the removed element should be disposed (default: false)
  35410. */
  35411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35412. /**
  35413. * Disposes the component and the associated ressources.
  35414. */
  35415. dispose(): void;
  35416. /**
  35417. * Disables audio in the associated scene.
  35418. */
  35419. disableAudio(): void;
  35420. /**
  35421. * Enables audio in the associated scene.
  35422. */
  35423. enableAudio(): void;
  35424. /**
  35425. * Switch audio to headphone output.
  35426. */
  35427. switchAudioModeForHeadphones(): void;
  35428. /**
  35429. * Switch audio to normal speakers.
  35430. */
  35431. switchAudioModeForNormalSpeakers(): void;
  35432. private _afterRender;
  35433. }
  35434. }
  35435. declare module "babylonjs/Audio/weightedsound" {
  35436. import { Sound } from "babylonjs/Audio/sound";
  35437. /**
  35438. * Wraps one or more Sound objects and selects one with random weight for playback.
  35439. */
  35440. export class WeightedSound {
  35441. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35442. loop: boolean;
  35443. private _coneInnerAngle;
  35444. private _coneOuterAngle;
  35445. private _volume;
  35446. /** A Sound is currently playing. */
  35447. isPlaying: boolean;
  35448. /** A Sound is currently paused. */
  35449. isPaused: boolean;
  35450. private _sounds;
  35451. private _weights;
  35452. private _currentIndex?;
  35453. /**
  35454. * Creates a new WeightedSound from the list of sounds given.
  35455. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35456. * @param sounds Array of Sounds that will be selected from.
  35457. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35458. */
  35459. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35460. /**
  35461. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35462. */
  35463. /**
  35464. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35465. */
  35466. directionalConeInnerAngle: number;
  35467. /**
  35468. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35469. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35470. */
  35471. /**
  35472. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35473. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35474. */
  35475. directionalConeOuterAngle: number;
  35476. /**
  35477. * Playback volume.
  35478. */
  35479. /**
  35480. * Playback volume.
  35481. */
  35482. volume: number;
  35483. private _onended;
  35484. /**
  35485. * Suspend playback
  35486. */
  35487. pause(): void;
  35488. /**
  35489. * Stop playback
  35490. */
  35491. stop(): void;
  35492. /**
  35493. * Start playback.
  35494. * @param startOffset Position the clip head at a specific time in seconds.
  35495. */
  35496. play(startOffset?: number): void;
  35497. }
  35498. }
  35499. declare module "babylonjs/Audio/index" {
  35500. export * from "babylonjs/Audio/analyser";
  35501. export * from "babylonjs/Audio/audioEngine";
  35502. export * from "babylonjs/Audio/audioSceneComponent";
  35503. export * from "babylonjs/Audio/sound";
  35504. export * from "babylonjs/Audio/soundTrack";
  35505. export * from "babylonjs/Audio/weightedsound";
  35506. }
  35507. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35508. import { Behavior } from "babylonjs/Behaviors/behavior";
  35509. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35510. import { BackEase } from "babylonjs/Animations/easing";
  35511. /**
  35512. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35513. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35514. */
  35515. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35516. /**
  35517. * Gets the name of the behavior.
  35518. */
  35519. readonly name: string;
  35520. /**
  35521. * The easing function used by animations
  35522. */
  35523. static EasingFunction: BackEase;
  35524. /**
  35525. * The easing mode used by animations
  35526. */
  35527. static EasingMode: number;
  35528. /**
  35529. * The duration of the animation, in milliseconds
  35530. */
  35531. transitionDuration: number;
  35532. /**
  35533. * Length of the distance animated by the transition when lower radius is reached
  35534. */
  35535. lowerRadiusTransitionRange: number;
  35536. /**
  35537. * Length of the distance animated by the transition when upper radius is reached
  35538. */
  35539. upperRadiusTransitionRange: number;
  35540. private _autoTransitionRange;
  35541. /**
  35542. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35543. */
  35544. /**
  35545. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35546. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35547. */
  35548. autoTransitionRange: boolean;
  35549. private _attachedCamera;
  35550. private _onAfterCheckInputsObserver;
  35551. private _onMeshTargetChangedObserver;
  35552. /**
  35553. * Initializes the behavior.
  35554. */
  35555. init(): void;
  35556. /**
  35557. * Attaches the behavior to its arc rotate camera.
  35558. * @param camera Defines the camera to attach the behavior to
  35559. */
  35560. attach(camera: ArcRotateCamera): void;
  35561. /**
  35562. * Detaches the behavior from its current arc rotate camera.
  35563. */
  35564. detach(): void;
  35565. private _radiusIsAnimating;
  35566. private _radiusBounceTransition;
  35567. private _animatables;
  35568. private _cachedWheelPrecision;
  35569. /**
  35570. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35571. * @param radiusLimit The limit to check against.
  35572. * @return Bool to indicate if at limit.
  35573. */
  35574. private _isRadiusAtLimit;
  35575. /**
  35576. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35577. * @param radiusDelta The delta by which to animate to. Can be negative.
  35578. */
  35579. private _applyBoundRadiusAnimation;
  35580. /**
  35581. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35582. */
  35583. protected _clearAnimationLocks(): void;
  35584. /**
  35585. * Stops and removes all animations that have been applied to the camera
  35586. */
  35587. stopAllAnimations(): void;
  35588. }
  35589. }
  35590. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35591. import { Behavior } from "babylonjs/Behaviors/behavior";
  35592. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35593. import { ExponentialEase } from "babylonjs/Animations/easing";
  35594. import { Nullable } from "babylonjs/types";
  35595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35596. import { Vector3 } from "babylonjs/Maths/math";
  35597. /**
  35598. * 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.
  35599. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35600. */
  35601. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35602. /**
  35603. * Gets the name of the behavior.
  35604. */
  35605. readonly name: string;
  35606. private _mode;
  35607. private _radiusScale;
  35608. private _positionScale;
  35609. private _defaultElevation;
  35610. private _elevationReturnTime;
  35611. private _elevationReturnWaitTime;
  35612. private _zoomStopsAnimation;
  35613. private _framingTime;
  35614. /**
  35615. * The easing function used by animations
  35616. */
  35617. static EasingFunction: ExponentialEase;
  35618. /**
  35619. * The easing mode used by animations
  35620. */
  35621. static EasingMode: number;
  35622. /**
  35623. * Sets the current mode used by the behavior
  35624. */
  35625. /**
  35626. * Gets current mode used by the behavior.
  35627. */
  35628. mode: number;
  35629. /**
  35630. * Sets the scale applied to the radius (1 by default)
  35631. */
  35632. /**
  35633. * Gets the scale applied to the radius
  35634. */
  35635. radiusScale: number;
  35636. /**
  35637. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35638. */
  35639. /**
  35640. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35641. */
  35642. positionScale: number;
  35643. /**
  35644. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35645. * behaviour is triggered, in radians.
  35646. */
  35647. /**
  35648. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35649. * behaviour is triggered, in radians.
  35650. */
  35651. defaultElevation: number;
  35652. /**
  35653. * Sets the time (in milliseconds) taken to return to the default beta position.
  35654. * Negative value indicates camera should not return to default.
  35655. */
  35656. /**
  35657. * Gets the time (in milliseconds) taken to return to the default beta position.
  35658. * Negative value indicates camera should not return to default.
  35659. */
  35660. elevationReturnTime: number;
  35661. /**
  35662. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35663. */
  35664. /**
  35665. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35666. */
  35667. elevationReturnWaitTime: number;
  35668. /**
  35669. * Sets the flag that indicates if user zooming should stop animation.
  35670. */
  35671. /**
  35672. * Gets the flag that indicates if user zooming should stop animation.
  35673. */
  35674. zoomStopsAnimation: boolean;
  35675. /**
  35676. * Sets the transition time when framing the mesh, in milliseconds
  35677. */
  35678. /**
  35679. * Gets the transition time when framing the mesh, in milliseconds
  35680. */
  35681. framingTime: number;
  35682. /**
  35683. * Define if the behavior should automatically change the configured
  35684. * camera limits and sensibilities.
  35685. */
  35686. autoCorrectCameraLimitsAndSensibility: boolean;
  35687. private _onPrePointerObservableObserver;
  35688. private _onAfterCheckInputsObserver;
  35689. private _onMeshTargetChangedObserver;
  35690. private _attachedCamera;
  35691. private _isPointerDown;
  35692. private _lastInteractionTime;
  35693. /**
  35694. * Initializes the behavior.
  35695. */
  35696. init(): void;
  35697. /**
  35698. * Attaches the behavior to its arc rotate camera.
  35699. * @param camera Defines the camera to attach the behavior to
  35700. */
  35701. attach(camera: ArcRotateCamera): void;
  35702. /**
  35703. * Detaches the behavior from its current arc rotate camera.
  35704. */
  35705. detach(): void;
  35706. private _animatables;
  35707. private _betaIsAnimating;
  35708. private _betaTransition;
  35709. private _radiusTransition;
  35710. private _vectorTransition;
  35711. /**
  35712. * Targets the given mesh and updates zoom level accordingly.
  35713. * @param mesh The mesh to target.
  35714. * @param radius Optional. If a cached radius position already exists, overrides default.
  35715. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35716. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35717. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35718. */
  35719. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35720. /**
  35721. * Targets the given mesh with its children and updates zoom level accordingly.
  35722. * @param mesh The mesh to target.
  35723. * @param radius Optional. If a cached radius position already exists, overrides default.
  35724. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35725. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35726. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35727. */
  35728. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35729. /**
  35730. * Targets the given meshes with their children and updates zoom level accordingly.
  35731. * @param meshes The mesh to target.
  35732. * @param radius Optional. If a cached radius position already exists, overrides default.
  35733. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35734. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35735. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35736. */
  35737. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35738. /**
  35739. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35740. * @param minimumWorld Determines the smaller position of the bounding box extend
  35741. * @param maximumWorld Determines the bigger position of the bounding box extend
  35742. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35743. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35744. */
  35745. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35746. /**
  35747. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35748. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35749. * frustum width.
  35750. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35751. * to fully enclose the mesh in the viewing frustum.
  35752. */
  35753. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35754. /**
  35755. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35756. * is automatically returned to its default position (expected to be above ground plane).
  35757. */
  35758. private _maintainCameraAboveGround;
  35759. /**
  35760. * Returns the frustum slope based on the canvas ratio and camera FOV
  35761. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35762. */
  35763. private _getFrustumSlope;
  35764. /**
  35765. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35766. */
  35767. private _clearAnimationLocks;
  35768. /**
  35769. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35770. */
  35771. private _applyUserInteraction;
  35772. /**
  35773. * Stops and removes all animations that have been applied to the camera
  35774. */
  35775. stopAllAnimations(): void;
  35776. /**
  35777. * Gets a value indicating if the user is moving the camera
  35778. */
  35779. readonly isUserIsMoving: boolean;
  35780. /**
  35781. * The camera can move all the way towards the mesh.
  35782. */
  35783. static IgnoreBoundsSizeMode: number;
  35784. /**
  35785. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35786. */
  35787. static FitFrustumSidesMode: number;
  35788. }
  35789. }
  35790. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35791. import { Nullable } from "babylonjs/types";
  35792. import { Camera } from "babylonjs/Cameras/camera";
  35793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35794. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35795. /**
  35796. * Base class for Camera Pointer Inputs.
  35797. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35798. * for example usage.
  35799. */
  35800. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35801. /**
  35802. * Defines the camera the input is attached to.
  35803. */
  35804. abstract camera: Camera;
  35805. /**
  35806. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35807. */
  35808. protected _altKey: boolean;
  35809. protected _ctrlKey: boolean;
  35810. protected _metaKey: boolean;
  35811. protected _shiftKey: boolean;
  35812. /**
  35813. * Which mouse buttons were pressed at time of last mouse event.
  35814. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35815. */
  35816. protected _buttonsPressed: number;
  35817. /**
  35818. * Defines the buttons associated with the input to handle camera move.
  35819. */
  35820. buttons: number[];
  35821. /**
  35822. * Attach the input controls to a specific dom element to get the input from.
  35823. * @param element Defines the element the controls should be listened from
  35824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35825. */
  35826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35827. /**
  35828. * Detach the current controls from the specified dom element.
  35829. * @param element Defines the element to stop listening the inputs from
  35830. */
  35831. detachControl(element: Nullable<HTMLElement>): void;
  35832. /**
  35833. * Gets the class name of the current input.
  35834. * @returns the class name
  35835. */
  35836. getClassName(): string;
  35837. /**
  35838. * Get the friendly name associated with the input class.
  35839. * @returns the input friendly name
  35840. */
  35841. getSimpleName(): string;
  35842. /**
  35843. * Called on pointer POINTERDOUBLETAP event.
  35844. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35845. */
  35846. protected onDoubleTap(type: string): void;
  35847. /**
  35848. * Called on pointer POINTERMOVE event if only a single touch is active.
  35849. * Override this method to provide functionality.
  35850. */
  35851. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35852. /**
  35853. * Called on pointer POINTERMOVE event if multiple touches are active.
  35854. * Override this method to provide functionality.
  35855. */
  35856. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35857. /**
  35858. * Called on JS contextmenu event.
  35859. * Override this method to provide functionality.
  35860. */
  35861. protected onContextMenu(evt: PointerEvent): void;
  35862. /**
  35863. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35864. * press.
  35865. * Override this method to provide functionality.
  35866. */
  35867. protected onButtonDown(evt: PointerEvent): void;
  35868. /**
  35869. * Called each time a new POINTERUP event occurs. Ie, for each button
  35870. * release.
  35871. * Override this method to provide functionality.
  35872. */
  35873. protected onButtonUp(evt: PointerEvent): void;
  35874. /**
  35875. * Called when window becomes inactive.
  35876. * Override this method to provide functionality.
  35877. */
  35878. protected onLostFocus(): void;
  35879. private _pointerInput;
  35880. private _observer;
  35881. private _onLostFocus;
  35882. private pointA;
  35883. private pointB;
  35884. }
  35885. }
  35886. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35887. import { Nullable } from "babylonjs/types";
  35888. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35889. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35890. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35891. /**
  35892. * Manage the pointers inputs to control an arc rotate camera.
  35893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35894. */
  35895. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35896. /**
  35897. * Defines the camera the input is attached to.
  35898. */
  35899. camera: ArcRotateCamera;
  35900. /**
  35901. * Gets the class name of the current input.
  35902. * @returns the class name
  35903. */
  35904. getClassName(): string;
  35905. /**
  35906. * Defines the buttons associated with the input to handle camera move.
  35907. */
  35908. buttons: number[];
  35909. /**
  35910. * Defines the pointer angular sensibility along the X axis or how fast is
  35911. * the camera rotating.
  35912. */
  35913. angularSensibilityX: number;
  35914. /**
  35915. * Defines the pointer angular sensibility along the Y axis or how fast is
  35916. * the camera rotating.
  35917. */
  35918. angularSensibilityY: number;
  35919. /**
  35920. * Defines the pointer pinch precision or how fast is the camera zooming.
  35921. */
  35922. pinchPrecision: number;
  35923. /**
  35924. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35925. * from 0.
  35926. * It defines the percentage of current camera.radius to use as delta when
  35927. * pinch zoom is used.
  35928. */
  35929. pinchDeltaPercentage: number;
  35930. /**
  35931. * Defines the pointer panning sensibility or how fast is the camera moving.
  35932. */
  35933. panningSensibility: number;
  35934. /**
  35935. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35936. */
  35937. multiTouchPanning: boolean;
  35938. /**
  35939. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35940. * zoom (pinch) through multitouch.
  35941. */
  35942. multiTouchPanAndZoom: boolean;
  35943. /**
  35944. * Revers pinch action direction.
  35945. */
  35946. pinchInwards: boolean;
  35947. private _isPanClick;
  35948. private _twoFingerActivityCount;
  35949. private _isPinching;
  35950. /**
  35951. * Called on pointer POINTERMOVE event if only a single touch is active.
  35952. */
  35953. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35954. /**
  35955. * Called on pointer POINTERDOUBLETAP event.
  35956. */
  35957. protected onDoubleTap(type: string): void;
  35958. /**
  35959. * Called on pointer POINTERMOVE event if multiple touches are active.
  35960. */
  35961. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35962. /**
  35963. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35964. * press.
  35965. */
  35966. protected onButtonDown(evt: PointerEvent): void;
  35967. /**
  35968. * Called each time a new POINTERUP event occurs. Ie, for each button
  35969. * release.
  35970. */
  35971. protected onButtonUp(evt: PointerEvent): void;
  35972. /**
  35973. * Called when window becomes inactive.
  35974. */
  35975. protected onLostFocus(): void;
  35976. }
  35977. }
  35978. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35979. import { Nullable } from "babylonjs/types";
  35980. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35981. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35982. /**
  35983. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35985. */
  35986. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35987. /**
  35988. * Defines the camera the input is attached to.
  35989. */
  35990. camera: ArcRotateCamera;
  35991. /**
  35992. * Defines the list of key codes associated with the up action (increase alpha)
  35993. */
  35994. keysUp: number[];
  35995. /**
  35996. * Defines the list of key codes associated with the down action (decrease alpha)
  35997. */
  35998. keysDown: number[];
  35999. /**
  36000. * Defines the list of key codes associated with the left action (increase beta)
  36001. */
  36002. keysLeft: number[];
  36003. /**
  36004. * Defines the list of key codes associated with the right action (decrease beta)
  36005. */
  36006. keysRight: number[];
  36007. /**
  36008. * Defines the list of key codes associated with the reset action.
  36009. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36010. */
  36011. keysReset: number[];
  36012. /**
  36013. * Defines the panning sensibility of the inputs.
  36014. * (How fast is the camera paning)
  36015. */
  36016. panningSensibility: number;
  36017. /**
  36018. * Defines the zooming sensibility of the inputs.
  36019. * (How fast is the camera zooming)
  36020. */
  36021. zoomingSensibility: number;
  36022. /**
  36023. * Defines wether maintaining the alt key down switch the movement mode from
  36024. * orientation to zoom.
  36025. */
  36026. useAltToZoom: boolean;
  36027. /**
  36028. * Rotation speed of the camera
  36029. */
  36030. angularSpeed: number;
  36031. private _keys;
  36032. private _ctrlPressed;
  36033. private _altPressed;
  36034. private _onCanvasBlurObserver;
  36035. private _onKeyboardObserver;
  36036. private _engine;
  36037. private _scene;
  36038. /**
  36039. * Attach the input controls to a specific dom element to get the input from.
  36040. * @param element Defines the element the controls should be listened from
  36041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36042. */
  36043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36044. /**
  36045. * Detach the current controls from the specified dom element.
  36046. * @param element Defines the element to stop listening the inputs from
  36047. */
  36048. detachControl(element: Nullable<HTMLElement>): void;
  36049. /**
  36050. * Update the current camera state depending on the inputs that have been used this frame.
  36051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36052. */
  36053. checkInputs(): void;
  36054. /**
  36055. * Gets the class name of the current intput.
  36056. * @returns the class name
  36057. */
  36058. getClassName(): string;
  36059. /**
  36060. * Get the friendly name associated with the input class.
  36061. * @returns the input friendly name
  36062. */
  36063. getSimpleName(): string;
  36064. }
  36065. }
  36066. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36067. import { Nullable } from "babylonjs/types";
  36068. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36070. /**
  36071. * Manage the mouse wheel inputs to control an arc rotate camera.
  36072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36073. */
  36074. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36075. /**
  36076. * Defines the camera the input is attached to.
  36077. */
  36078. camera: ArcRotateCamera;
  36079. /**
  36080. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36081. */
  36082. wheelPrecision: number;
  36083. /**
  36084. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36085. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36086. */
  36087. wheelDeltaPercentage: number;
  36088. private _wheel;
  36089. private _observer;
  36090. private computeDeltaFromMouseWheelLegacyEvent;
  36091. /**
  36092. * Attach the input controls to a specific dom element to get the input from.
  36093. * @param element Defines the element the controls should be listened from
  36094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36095. */
  36096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36097. /**
  36098. * Detach the current controls from the specified dom element.
  36099. * @param element Defines the element to stop listening the inputs from
  36100. */
  36101. detachControl(element: Nullable<HTMLElement>): void;
  36102. /**
  36103. * Gets the class name of the current intput.
  36104. * @returns the class name
  36105. */
  36106. getClassName(): string;
  36107. /**
  36108. * Get the friendly name associated with the input class.
  36109. * @returns the input friendly name
  36110. */
  36111. getSimpleName(): string;
  36112. }
  36113. }
  36114. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36115. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36116. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36117. /**
  36118. * Default Inputs manager for the ArcRotateCamera.
  36119. * It groups all the default supported inputs for ease of use.
  36120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36121. */
  36122. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36123. /**
  36124. * Instantiates a new ArcRotateCameraInputsManager.
  36125. * @param camera Defines the camera the inputs belong to
  36126. */
  36127. constructor(camera: ArcRotateCamera);
  36128. /**
  36129. * Add mouse wheel input support to the input manager.
  36130. * @returns the current input manager
  36131. */
  36132. addMouseWheel(): ArcRotateCameraInputsManager;
  36133. /**
  36134. * Add pointers input support to the input manager.
  36135. * @returns the current input manager
  36136. */
  36137. addPointers(): ArcRotateCameraInputsManager;
  36138. /**
  36139. * Add keyboard input support to the input manager.
  36140. * @returns the current input manager
  36141. */
  36142. addKeyboard(): ArcRotateCameraInputsManager;
  36143. }
  36144. }
  36145. declare module "babylonjs/Cameras/arcRotateCamera" {
  36146. import { Observable } from "babylonjs/Misc/observable";
  36147. import { Nullable } from "babylonjs/types";
  36148. import { Scene } from "babylonjs/scene";
  36149. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36151. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36152. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36153. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36154. import { Camera } from "babylonjs/Cameras/camera";
  36155. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36156. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36157. import { Collider } from "babylonjs/Collisions/collider";
  36158. /**
  36159. * This represents an orbital type of camera.
  36160. *
  36161. * 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.
  36162. * 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.
  36163. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36164. */
  36165. export class ArcRotateCamera extends TargetCamera {
  36166. /**
  36167. * Defines the rotation angle of the camera along the longitudinal axis.
  36168. */
  36169. alpha: number;
  36170. /**
  36171. * Defines the rotation angle of the camera along the latitudinal axis.
  36172. */
  36173. beta: number;
  36174. /**
  36175. * Defines the radius of the camera from it s target point.
  36176. */
  36177. radius: number;
  36178. protected _target: Vector3;
  36179. protected _targetHost: Nullable<AbstractMesh>;
  36180. /**
  36181. * Defines the target point of the camera.
  36182. * The camera looks towards it form the radius distance.
  36183. */
  36184. target: Vector3;
  36185. /**
  36186. * Define the current local position of the camera in the scene
  36187. */
  36188. position: Vector3;
  36189. protected _upVector: Vector3;
  36190. protected _upToYMatrix: Matrix;
  36191. protected _YToUpMatrix: Matrix;
  36192. /**
  36193. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36194. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36195. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36196. */
  36197. upVector: Vector3;
  36198. /**
  36199. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36200. */
  36201. setMatUp(): void;
  36202. /**
  36203. * Current inertia value on the longitudinal axis.
  36204. * The bigger this number the longer it will take for the camera to stop.
  36205. */
  36206. inertialAlphaOffset: number;
  36207. /**
  36208. * Current inertia value on the latitudinal axis.
  36209. * The bigger this number the longer it will take for the camera to stop.
  36210. */
  36211. inertialBetaOffset: number;
  36212. /**
  36213. * Current inertia value on the radius axis.
  36214. * The bigger this number the longer it will take for the camera to stop.
  36215. */
  36216. inertialRadiusOffset: number;
  36217. /**
  36218. * Minimum allowed angle on the longitudinal axis.
  36219. * This can help limiting how the Camera is able to move in the scene.
  36220. */
  36221. lowerAlphaLimit: Nullable<number>;
  36222. /**
  36223. * Maximum allowed angle on the longitudinal axis.
  36224. * This can help limiting how the Camera is able to move in the scene.
  36225. */
  36226. upperAlphaLimit: Nullable<number>;
  36227. /**
  36228. * Minimum allowed angle on the latitudinal axis.
  36229. * This can help limiting how the Camera is able to move in the scene.
  36230. */
  36231. lowerBetaLimit: number;
  36232. /**
  36233. * Maximum allowed angle on the latitudinal axis.
  36234. * This can help limiting how the Camera is able to move in the scene.
  36235. */
  36236. upperBetaLimit: number;
  36237. /**
  36238. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36239. * This can help limiting how the Camera is able to move in the scene.
  36240. */
  36241. lowerRadiusLimit: Nullable<number>;
  36242. /**
  36243. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36244. * This can help limiting how the Camera is able to move in the scene.
  36245. */
  36246. upperRadiusLimit: Nullable<number>;
  36247. /**
  36248. * Defines the current inertia value used during panning of the camera along the X axis.
  36249. */
  36250. inertialPanningX: number;
  36251. /**
  36252. * Defines the current inertia value used during panning of the camera along the Y axis.
  36253. */
  36254. inertialPanningY: number;
  36255. /**
  36256. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36257. * Basically if your fingers moves away from more than this distance you will be considered
  36258. * in pinch mode.
  36259. */
  36260. pinchToPanMaxDistance: number;
  36261. /**
  36262. * Defines the maximum distance the camera can pan.
  36263. * This could help keeping the cammera always in your scene.
  36264. */
  36265. panningDistanceLimit: Nullable<number>;
  36266. /**
  36267. * Defines the target of the camera before paning.
  36268. */
  36269. panningOriginTarget: Vector3;
  36270. /**
  36271. * Defines the value of the inertia used during panning.
  36272. * 0 would mean stop inertia and one would mean no decelleration at all.
  36273. */
  36274. panningInertia: number;
  36275. /**
  36276. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36277. */
  36278. angularSensibilityX: number;
  36279. /**
  36280. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36281. */
  36282. angularSensibilityY: number;
  36283. /**
  36284. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36285. */
  36286. pinchPrecision: number;
  36287. /**
  36288. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36289. * It will be used instead of pinchDeltaPrecision if different from 0.
  36290. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36291. */
  36292. pinchDeltaPercentage: number;
  36293. /**
  36294. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36295. */
  36296. panningSensibility: number;
  36297. /**
  36298. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36299. */
  36300. keysUp: number[];
  36301. /**
  36302. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36303. */
  36304. keysDown: number[];
  36305. /**
  36306. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36307. */
  36308. keysLeft: number[];
  36309. /**
  36310. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36311. */
  36312. keysRight: number[];
  36313. /**
  36314. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36315. */
  36316. wheelPrecision: number;
  36317. /**
  36318. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36319. * It will be used instead of pinchDeltaPrecision if different from 0.
  36320. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36321. */
  36322. wheelDeltaPercentage: number;
  36323. /**
  36324. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36325. */
  36326. zoomOnFactor: number;
  36327. /**
  36328. * Defines a screen offset for the camera position.
  36329. */
  36330. targetScreenOffset: Vector2;
  36331. /**
  36332. * Allows the camera to be completely reversed.
  36333. * If false the camera can not arrive upside down.
  36334. */
  36335. allowUpsideDown: boolean;
  36336. /**
  36337. * Define if double tap/click is used to restore the previously saved state of the camera.
  36338. */
  36339. useInputToRestoreState: boolean;
  36340. /** @hidden */
  36341. _viewMatrix: Matrix;
  36342. /** @hidden */
  36343. _useCtrlForPanning: boolean;
  36344. /** @hidden */
  36345. _panningMouseButton: number;
  36346. /**
  36347. * Defines the input associated to the camera.
  36348. */
  36349. inputs: ArcRotateCameraInputsManager;
  36350. /** @hidden */
  36351. _reset: () => void;
  36352. /**
  36353. * Defines the allowed panning axis.
  36354. */
  36355. panningAxis: Vector3;
  36356. protected _localDirection: Vector3;
  36357. protected _transformedDirection: Vector3;
  36358. private _bouncingBehavior;
  36359. /**
  36360. * Gets the bouncing behavior of the camera if it has been enabled.
  36361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36362. */
  36363. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36364. /**
  36365. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36367. */
  36368. useBouncingBehavior: boolean;
  36369. private _framingBehavior;
  36370. /**
  36371. * Gets the framing behavior of the camera if it has been enabled.
  36372. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36373. */
  36374. readonly framingBehavior: Nullable<FramingBehavior>;
  36375. /**
  36376. * Defines if the framing behavior of the camera is enabled on the camera.
  36377. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36378. */
  36379. useFramingBehavior: boolean;
  36380. private _autoRotationBehavior;
  36381. /**
  36382. * Gets the auto rotation behavior of the camera if it has been enabled.
  36383. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36384. */
  36385. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36386. /**
  36387. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36388. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36389. */
  36390. useAutoRotationBehavior: boolean;
  36391. /**
  36392. * Observable triggered when the mesh target has been changed on the camera.
  36393. */
  36394. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36395. /**
  36396. * Event raised when the camera is colliding with a mesh.
  36397. */
  36398. onCollide: (collidedMesh: AbstractMesh) => void;
  36399. /**
  36400. * Defines whether the camera should check collision with the objects oh the scene.
  36401. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36402. */
  36403. checkCollisions: boolean;
  36404. /**
  36405. * Defines the collision radius of the camera.
  36406. * This simulates a sphere around the camera.
  36407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36408. */
  36409. collisionRadius: Vector3;
  36410. protected _collider: Collider;
  36411. protected _previousPosition: Vector3;
  36412. protected _collisionVelocity: Vector3;
  36413. protected _newPosition: Vector3;
  36414. protected _previousAlpha: number;
  36415. protected _previousBeta: number;
  36416. protected _previousRadius: number;
  36417. protected _collisionTriggered: boolean;
  36418. protected _targetBoundingCenter: Nullable<Vector3>;
  36419. private _computationVector;
  36420. /**
  36421. * Instantiates a new ArcRotateCamera in a given scene
  36422. * @param name Defines the name of the camera
  36423. * @param alpha Defines the camera rotation along the logitudinal axis
  36424. * @param beta Defines the camera rotation along the latitudinal axis
  36425. * @param radius Defines the camera distance from its target
  36426. * @param target Defines the camera target
  36427. * @param scene Defines the scene the camera belongs to
  36428. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36429. */
  36430. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36431. /** @hidden */
  36432. _initCache(): void;
  36433. /** @hidden */
  36434. _updateCache(ignoreParentClass?: boolean): void;
  36435. protected _getTargetPosition(): Vector3;
  36436. private _storedAlpha;
  36437. private _storedBeta;
  36438. private _storedRadius;
  36439. private _storedTarget;
  36440. /**
  36441. * Stores the current state of the camera (alpha, beta, radius and target)
  36442. * @returns the camera itself
  36443. */
  36444. storeState(): Camera;
  36445. /**
  36446. * @hidden
  36447. * Restored camera state. You must call storeState() first
  36448. */
  36449. _restoreStateValues(): boolean;
  36450. /** @hidden */
  36451. _isSynchronizedViewMatrix(): boolean;
  36452. /**
  36453. * Attached controls to the current camera.
  36454. * @param element Defines the element the controls should be listened from
  36455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36456. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36457. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36458. */
  36459. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36460. /**
  36461. * Detach the current controls from the camera.
  36462. * The camera will stop reacting to inputs.
  36463. * @param element Defines the element to stop listening the inputs from
  36464. */
  36465. detachControl(element: HTMLElement): void;
  36466. /** @hidden */
  36467. _checkInputs(): void;
  36468. protected _checkLimits(): void;
  36469. /**
  36470. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36471. */
  36472. rebuildAnglesAndRadius(): void;
  36473. /**
  36474. * Use a position to define the current camera related information like aplha, beta and radius
  36475. * @param position Defines the position to set the camera at
  36476. */
  36477. setPosition(position: Vector3): void;
  36478. /**
  36479. * Defines the target the camera should look at.
  36480. * This will automatically adapt alpha beta and radius to fit within the new target.
  36481. * @param target Defines the new target as a Vector or a mesh
  36482. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36483. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36484. */
  36485. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36486. /** @hidden */
  36487. _getViewMatrix(): Matrix;
  36488. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36489. /**
  36490. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36491. * @param meshes Defines the mesh to zoom on
  36492. * @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)
  36493. */
  36494. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36495. /**
  36496. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36497. * The target will be changed but the radius
  36498. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36499. * @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)
  36500. */
  36501. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36502. min: Vector3;
  36503. max: Vector3;
  36504. distance: number;
  36505. }, doNotUpdateMaxZ?: boolean): void;
  36506. /**
  36507. * @override
  36508. * Override Camera.createRigCamera
  36509. */
  36510. createRigCamera(name: string, cameraIndex: number): Camera;
  36511. /**
  36512. * @hidden
  36513. * @override
  36514. * Override Camera._updateRigCameras
  36515. */
  36516. _updateRigCameras(): void;
  36517. /**
  36518. * Destroy the camera and release the current resources hold by it.
  36519. */
  36520. dispose(): void;
  36521. /**
  36522. * Gets the current object class name.
  36523. * @return the class name
  36524. */
  36525. getClassName(): string;
  36526. }
  36527. }
  36528. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36529. import { Behavior } from "babylonjs/Behaviors/behavior";
  36530. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36531. /**
  36532. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36533. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36534. */
  36535. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36536. /**
  36537. * Gets the name of the behavior.
  36538. */
  36539. readonly name: string;
  36540. private _zoomStopsAnimation;
  36541. private _idleRotationSpeed;
  36542. private _idleRotationWaitTime;
  36543. private _idleRotationSpinupTime;
  36544. /**
  36545. * Sets the flag that indicates if user zooming should stop animation.
  36546. */
  36547. /**
  36548. * Gets the flag that indicates if user zooming should stop animation.
  36549. */
  36550. zoomStopsAnimation: boolean;
  36551. /**
  36552. * Sets the default speed at which the camera rotates around the model.
  36553. */
  36554. /**
  36555. * Gets the default speed at which the camera rotates around the model.
  36556. */
  36557. idleRotationSpeed: number;
  36558. /**
  36559. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36560. */
  36561. /**
  36562. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36563. */
  36564. idleRotationWaitTime: number;
  36565. /**
  36566. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36567. */
  36568. /**
  36569. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36570. */
  36571. idleRotationSpinupTime: number;
  36572. /**
  36573. * Gets a value indicating if the camera is currently rotating because of this behavior
  36574. */
  36575. readonly rotationInProgress: boolean;
  36576. private _onPrePointerObservableObserver;
  36577. private _onAfterCheckInputsObserver;
  36578. private _attachedCamera;
  36579. private _isPointerDown;
  36580. private _lastFrameTime;
  36581. private _lastInteractionTime;
  36582. private _cameraRotationSpeed;
  36583. /**
  36584. * Initializes the behavior.
  36585. */
  36586. init(): void;
  36587. /**
  36588. * Attaches the behavior to its arc rotate camera.
  36589. * @param camera Defines the camera to attach the behavior to
  36590. */
  36591. attach(camera: ArcRotateCamera): void;
  36592. /**
  36593. * Detaches the behavior from its current arc rotate camera.
  36594. */
  36595. detach(): void;
  36596. /**
  36597. * Returns true if user is scrolling.
  36598. * @return true if user is scrolling.
  36599. */
  36600. private _userIsZooming;
  36601. private _lastFrameRadius;
  36602. private _shouldAnimationStopForInteraction;
  36603. /**
  36604. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36605. */
  36606. private _applyUserInteraction;
  36607. private _userIsMoving;
  36608. }
  36609. }
  36610. declare module "babylonjs/Behaviors/Cameras/index" {
  36611. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36612. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36613. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36614. }
  36615. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36616. import { Mesh } from "babylonjs/Meshes/mesh";
  36617. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36618. import { Behavior } from "babylonjs/Behaviors/behavior";
  36619. /**
  36620. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36621. */
  36622. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36623. private ui;
  36624. /**
  36625. * The name of the behavior
  36626. */
  36627. name: string;
  36628. /**
  36629. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36630. */
  36631. distanceAwayFromFace: number;
  36632. /**
  36633. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36634. */
  36635. distanceAwayFromBottomOfFace: number;
  36636. private _faceVectors;
  36637. private _target;
  36638. private _scene;
  36639. private _onRenderObserver;
  36640. private _tmpMatrix;
  36641. private _tmpVector;
  36642. /**
  36643. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36644. * @param ui The transform node that should be attched to the mesh
  36645. */
  36646. constructor(ui: TransformNode);
  36647. /**
  36648. * Initializes the behavior
  36649. */
  36650. init(): void;
  36651. private _closestFace;
  36652. private _zeroVector;
  36653. private _lookAtTmpMatrix;
  36654. private _lookAtToRef;
  36655. /**
  36656. * Attaches the AttachToBoxBehavior to the passed in mesh
  36657. * @param target The mesh that the specified node will be attached to
  36658. */
  36659. attach(target: Mesh): void;
  36660. /**
  36661. * Detaches the behavior from the mesh
  36662. */
  36663. detach(): void;
  36664. }
  36665. }
  36666. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36667. import { Behavior } from "babylonjs/Behaviors/behavior";
  36668. import { Mesh } from "babylonjs/Meshes/mesh";
  36669. /**
  36670. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36671. */
  36672. export class FadeInOutBehavior implements Behavior<Mesh> {
  36673. /**
  36674. * Time in milliseconds to delay before fading in (Default: 0)
  36675. */
  36676. delay: number;
  36677. /**
  36678. * Time in milliseconds for the mesh to fade in (Default: 300)
  36679. */
  36680. fadeInTime: number;
  36681. private _millisecondsPerFrame;
  36682. private _hovered;
  36683. private _hoverValue;
  36684. private _ownerNode;
  36685. /**
  36686. * Instatiates the FadeInOutBehavior
  36687. */
  36688. constructor();
  36689. /**
  36690. * The name of the behavior
  36691. */
  36692. readonly name: string;
  36693. /**
  36694. * Initializes the behavior
  36695. */
  36696. init(): void;
  36697. /**
  36698. * Attaches the fade behavior on the passed in mesh
  36699. * @param ownerNode The mesh that will be faded in/out once attached
  36700. */
  36701. attach(ownerNode: Mesh): void;
  36702. /**
  36703. * Detaches the behavior from the mesh
  36704. */
  36705. detach(): void;
  36706. /**
  36707. * Triggers the mesh to begin fading in or out
  36708. * @param value if the object should fade in or out (true to fade in)
  36709. */
  36710. fadeIn(value: boolean): void;
  36711. private _update;
  36712. private _setAllVisibility;
  36713. }
  36714. }
  36715. declare module "babylonjs/Misc/pivotTools" {
  36716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36717. /**
  36718. * Class containing a set of static utilities functions for managing Pivots
  36719. * @hidden
  36720. */
  36721. export class PivotTools {
  36722. private static _PivotCached;
  36723. private static _OldPivotPoint;
  36724. private static _PivotTranslation;
  36725. private static _PivotTmpVector;
  36726. /** @hidden */
  36727. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36728. /** @hidden */
  36729. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36730. }
  36731. }
  36732. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36733. import { Scene } from "babylonjs/scene";
  36734. import { Vector4, Plane } from "babylonjs/Maths/math";
  36735. import { Mesh } from "babylonjs/Meshes/mesh";
  36736. import { Nullable } from "babylonjs/types";
  36737. /**
  36738. * Class containing static functions to help procedurally build meshes
  36739. */
  36740. export class PlaneBuilder {
  36741. /**
  36742. * Creates a plane mesh
  36743. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36744. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36745. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36749. * @param name defines the name of the mesh
  36750. * @param options defines the options used to create the mesh
  36751. * @param scene defines the hosting scene
  36752. * @returns the plane mesh
  36753. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36754. */
  36755. static CreatePlane(name: string, options: {
  36756. size?: number;
  36757. width?: number;
  36758. height?: number;
  36759. sideOrientation?: number;
  36760. frontUVs?: Vector4;
  36761. backUVs?: Vector4;
  36762. updatable?: boolean;
  36763. sourcePlane?: Plane;
  36764. }, scene?: Nullable<Scene>): Mesh;
  36765. }
  36766. }
  36767. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36768. import { Behavior } from "babylonjs/Behaviors/behavior";
  36769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36770. import { Observable } from "babylonjs/Misc/observable";
  36771. import { Vector3 } from "babylonjs/Maths/math";
  36772. import { Ray } from "babylonjs/Culling/ray";
  36773. import "babylonjs/Meshes/Builders/planeBuilder";
  36774. /**
  36775. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36776. */
  36777. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36778. private static _AnyMouseID;
  36779. private _attachedNode;
  36780. private _dragPlane;
  36781. private _scene;
  36782. private _pointerObserver;
  36783. private _beforeRenderObserver;
  36784. private static _planeScene;
  36785. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36786. /**
  36787. * 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)
  36788. */
  36789. maxDragAngle: number;
  36790. /**
  36791. * @hidden
  36792. */
  36793. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36794. /**
  36795. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36796. */
  36797. currentDraggingPointerID: number;
  36798. /**
  36799. * The last position where the pointer hit the drag plane in world space
  36800. */
  36801. lastDragPosition: Vector3;
  36802. /**
  36803. * If the behavior is currently in a dragging state
  36804. */
  36805. dragging: boolean;
  36806. /**
  36807. * 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)
  36808. */
  36809. dragDeltaRatio: number;
  36810. /**
  36811. * If the drag plane orientation should be updated during the dragging (Default: true)
  36812. */
  36813. updateDragPlane: boolean;
  36814. private _debugMode;
  36815. private _moving;
  36816. /**
  36817. * Fires each time the attached mesh is dragged with the pointer
  36818. * * delta between last drag position and current drag position in world space
  36819. * * dragDistance along the drag axis
  36820. * * dragPlaneNormal normal of the current drag plane used during the drag
  36821. * * dragPlanePoint in world space where the drag intersects the drag plane
  36822. */
  36823. onDragObservable: Observable<{
  36824. delta: Vector3;
  36825. dragPlanePoint: Vector3;
  36826. dragPlaneNormal: Vector3;
  36827. dragDistance: number;
  36828. pointerId: number;
  36829. }>;
  36830. /**
  36831. * Fires each time a drag begins (eg. mouse down on mesh)
  36832. */
  36833. onDragStartObservable: Observable<{
  36834. dragPlanePoint: Vector3;
  36835. pointerId: number;
  36836. }>;
  36837. /**
  36838. * Fires each time a drag ends (eg. mouse release after drag)
  36839. */
  36840. onDragEndObservable: Observable<{
  36841. dragPlanePoint: Vector3;
  36842. pointerId: number;
  36843. }>;
  36844. /**
  36845. * If the attached mesh should be moved when dragged
  36846. */
  36847. moveAttached: boolean;
  36848. /**
  36849. * If the drag behavior will react to drag events (Default: true)
  36850. */
  36851. enabled: boolean;
  36852. /**
  36853. * If camera controls should be detached during the drag
  36854. */
  36855. detachCameraControls: boolean;
  36856. /**
  36857. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36858. */
  36859. useObjectOrienationForDragging: boolean;
  36860. private _options;
  36861. /**
  36862. * Creates a pointer drag behavior that can be attached to a mesh
  36863. * @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)
  36864. */
  36865. constructor(options?: {
  36866. dragAxis?: Vector3;
  36867. dragPlaneNormal?: Vector3;
  36868. });
  36869. /**
  36870. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36871. */
  36872. validateDrag: (targetPosition: Vector3) => boolean;
  36873. /**
  36874. * The name of the behavior
  36875. */
  36876. readonly name: string;
  36877. /**
  36878. * Initializes the behavior
  36879. */
  36880. init(): void;
  36881. private _tmpVector;
  36882. private _alternatePickedPoint;
  36883. private _worldDragAxis;
  36884. private _targetPosition;
  36885. private _attachedElement;
  36886. /**
  36887. * Attaches the drag behavior the passed in mesh
  36888. * @param ownerNode The mesh that will be dragged around once attached
  36889. */
  36890. attach(ownerNode: AbstractMesh): void;
  36891. /**
  36892. * Force relase the drag action by code.
  36893. */
  36894. releaseDrag(): void;
  36895. private _startDragRay;
  36896. private _lastPointerRay;
  36897. /**
  36898. * Simulates the start of a pointer drag event on the behavior
  36899. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36900. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36901. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36902. */
  36903. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36904. private _startDrag;
  36905. private _dragDelta;
  36906. private _moveDrag;
  36907. private _pickWithRayOnDragPlane;
  36908. private _pointA;
  36909. private _pointB;
  36910. private _pointC;
  36911. private _lineA;
  36912. private _lineB;
  36913. private _localAxis;
  36914. private _lookAt;
  36915. private _updateDragPlanePosition;
  36916. /**
  36917. * Detaches the behavior from the mesh
  36918. */
  36919. detach(): void;
  36920. }
  36921. }
  36922. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36923. import { Mesh } from "babylonjs/Meshes/mesh";
  36924. import { Behavior } from "babylonjs/Behaviors/behavior";
  36925. /**
  36926. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36927. */
  36928. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36929. private _dragBehaviorA;
  36930. private _dragBehaviorB;
  36931. private _startDistance;
  36932. private _initialScale;
  36933. private _targetScale;
  36934. private _ownerNode;
  36935. private _sceneRenderObserver;
  36936. /**
  36937. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36938. */
  36939. constructor();
  36940. /**
  36941. * The name of the behavior
  36942. */
  36943. readonly name: string;
  36944. /**
  36945. * Initializes the behavior
  36946. */
  36947. init(): void;
  36948. private _getCurrentDistance;
  36949. /**
  36950. * Attaches the scale behavior the passed in mesh
  36951. * @param ownerNode The mesh that will be scaled around once attached
  36952. */
  36953. attach(ownerNode: Mesh): void;
  36954. /**
  36955. * Detaches the behavior from the mesh
  36956. */
  36957. detach(): void;
  36958. }
  36959. }
  36960. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36961. import { Behavior } from "babylonjs/Behaviors/behavior";
  36962. import { Mesh } from "babylonjs/Meshes/mesh";
  36963. import { Observable } from "babylonjs/Misc/observable";
  36964. /**
  36965. * 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
  36966. */
  36967. export class SixDofDragBehavior implements Behavior<Mesh> {
  36968. private static _virtualScene;
  36969. private _ownerNode;
  36970. private _sceneRenderObserver;
  36971. private _scene;
  36972. private _targetPosition;
  36973. private _virtualOriginMesh;
  36974. private _virtualDragMesh;
  36975. private _pointerObserver;
  36976. private _moving;
  36977. private _startingOrientation;
  36978. /**
  36979. * 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)
  36980. */
  36981. private zDragFactor;
  36982. /**
  36983. * If the object should rotate to face the drag origin
  36984. */
  36985. rotateDraggedObject: boolean;
  36986. /**
  36987. * If the behavior is currently in a dragging state
  36988. */
  36989. dragging: boolean;
  36990. /**
  36991. * 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)
  36992. */
  36993. dragDeltaRatio: number;
  36994. /**
  36995. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36996. */
  36997. currentDraggingPointerID: number;
  36998. /**
  36999. * If camera controls should be detached during the drag
  37000. */
  37001. detachCameraControls: boolean;
  37002. /**
  37003. * Fires each time a drag starts
  37004. */
  37005. onDragStartObservable: Observable<{}>;
  37006. /**
  37007. * Fires each time a drag ends (eg. mouse release after drag)
  37008. */
  37009. onDragEndObservable: Observable<{}>;
  37010. /**
  37011. * 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
  37012. */
  37013. constructor();
  37014. /**
  37015. * The name of the behavior
  37016. */
  37017. readonly name: string;
  37018. /**
  37019. * Initializes the behavior
  37020. */
  37021. init(): void;
  37022. /**
  37023. * Attaches the scale behavior the passed in mesh
  37024. * @param ownerNode The mesh that will be scaled around once attached
  37025. */
  37026. attach(ownerNode: Mesh): void;
  37027. /**
  37028. * Detaches the behavior from the mesh
  37029. */
  37030. detach(): void;
  37031. }
  37032. }
  37033. declare module "babylonjs/Behaviors/Meshes/index" {
  37034. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37035. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37036. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37037. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37038. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37039. }
  37040. declare module "babylonjs/Behaviors/index" {
  37041. export * from "babylonjs/Behaviors/behavior";
  37042. export * from "babylonjs/Behaviors/Cameras/index";
  37043. export * from "babylonjs/Behaviors/Meshes/index";
  37044. }
  37045. declare module "babylonjs/Bones/boneIKController" {
  37046. import { Bone } from "babylonjs/Bones/bone";
  37047. import { Vector3 } from "babylonjs/Maths/math";
  37048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37049. import { Nullable } from "babylonjs/types";
  37050. /**
  37051. * Class used to apply inverse kinematics to bones
  37052. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37053. */
  37054. export class BoneIKController {
  37055. private static _tmpVecs;
  37056. private static _tmpQuat;
  37057. private static _tmpMats;
  37058. /**
  37059. * Gets or sets the target mesh
  37060. */
  37061. targetMesh: AbstractMesh;
  37062. /** Gets or sets the mesh used as pole */
  37063. poleTargetMesh: AbstractMesh;
  37064. /**
  37065. * Gets or sets the bone used as pole
  37066. */
  37067. poleTargetBone: Nullable<Bone>;
  37068. /**
  37069. * Gets or sets the target position
  37070. */
  37071. targetPosition: Vector3;
  37072. /**
  37073. * Gets or sets the pole target position
  37074. */
  37075. poleTargetPosition: Vector3;
  37076. /**
  37077. * Gets or sets the pole target local offset
  37078. */
  37079. poleTargetLocalOffset: Vector3;
  37080. /**
  37081. * Gets or sets the pole angle
  37082. */
  37083. poleAngle: number;
  37084. /**
  37085. * Gets or sets the mesh associated with the controller
  37086. */
  37087. mesh: AbstractMesh;
  37088. /**
  37089. * 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)
  37090. */
  37091. slerpAmount: number;
  37092. private _bone1Quat;
  37093. private _bone1Mat;
  37094. private _bone2Ang;
  37095. private _bone1;
  37096. private _bone2;
  37097. private _bone1Length;
  37098. private _bone2Length;
  37099. private _maxAngle;
  37100. private _maxReach;
  37101. private _rightHandedSystem;
  37102. private _bendAxis;
  37103. private _slerping;
  37104. private _adjustRoll;
  37105. /**
  37106. * Gets or sets maximum allowed angle
  37107. */
  37108. maxAngle: number;
  37109. /**
  37110. * Creates a new BoneIKController
  37111. * @param mesh defines the mesh to control
  37112. * @param bone defines the bone to control
  37113. * @param options defines options to set up the controller
  37114. */
  37115. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37116. targetMesh?: AbstractMesh;
  37117. poleTargetMesh?: AbstractMesh;
  37118. poleTargetBone?: Bone;
  37119. poleTargetLocalOffset?: Vector3;
  37120. poleAngle?: number;
  37121. bendAxis?: Vector3;
  37122. maxAngle?: number;
  37123. slerpAmount?: number;
  37124. });
  37125. private _setMaxAngle;
  37126. /**
  37127. * Force the controller to update the bones
  37128. */
  37129. update(): void;
  37130. }
  37131. }
  37132. declare module "babylonjs/Bones/boneLookController" {
  37133. import { Vector3, Space } from "babylonjs/Maths/math";
  37134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37135. import { Bone } from "babylonjs/Bones/bone";
  37136. /**
  37137. * Class used to make a bone look toward a point in space
  37138. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37139. */
  37140. export class BoneLookController {
  37141. private static _tmpVecs;
  37142. private static _tmpQuat;
  37143. private static _tmpMats;
  37144. /**
  37145. * The target Vector3 that the bone will look at
  37146. */
  37147. target: Vector3;
  37148. /**
  37149. * The mesh that the bone is attached to
  37150. */
  37151. mesh: AbstractMesh;
  37152. /**
  37153. * The bone that will be looking to the target
  37154. */
  37155. bone: Bone;
  37156. /**
  37157. * The up axis of the coordinate system that is used when the bone is rotated
  37158. */
  37159. upAxis: Vector3;
  37160. /**
  37161. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37162. */
  37163. upAxisSpace: Space;
  37164. /**
  37165. * Used to make an adjustment to the yaw of the bone
  37166. */
  37167. adjustYaw: number;
  37168. /**
  37169. * Used to make an adjustment to the pitch of the bone
  37170. */
  37171. adjustPitch: number;
  37172. /**
  37173. * Used to make an adjustment to the roll of the bone
  37174. */
  37175. adjustRoll: number;
  37176. /**
  37177. * 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)
  37178. */
  37179. slerpAmount: number;
  37180. private _minYaw;
  37181. private _maxYaw;
  37182. private _minPitch;
  37183. private _maxPitch;
  37184. private _minYawSin;
  37185. private _minYawCos;
  37186. private _maxYawSin;
  37187. private _maxYawCos;
  37188. private _midYawConstraint;
  37189. private _minPitchTan;
  37190. private _maxPitchTan;
  37191. private _boneQuat;
  37192. private _slerping;
  37193. private _transformYawPitch;
  37194. private _transformYawPitchInv;
  37195. private _firstFrameSkipped;
  37196. private _yawRange;
  37197. private _fowardAxis;
  37198. /**
  37199. * Gets or sets the minimum yaw angle that the bone can look to
  37200. */
  37201. minYaw: number;
  37202. /**
  37203. * Gets or sets the maximum yaw angle that the bone can look to
  37204. */
  37205. maxYaw: number;
  37206. /**
  37207. * Gets or sets the minimum pitch angle that the bone can look to
  37208. */
  37209. minPitch: number;
  37210. /**
  37211. * Gets or sets the maximum pitch angle that the bone can look to
  37212. */
  37213. maxPitch: number;
  37214. /**
  37215. * Create a BoneLookController
  37216. * @param mesh the mesh that the bone belongs to
  37217. * @param bone the bone that will be looking to the target
  37218. * @param target the target Vector3 to look at
  37219. * @param options optional settings:
  37220. * * maxYaw: the maximum angle the bone will yaw to
  37221. * * minYaw: the minimum angle the bone will yaw to
  37222. * * maxPitch: the maximum angle the bone will pitch to
  37223. * * minPitch: the minimum angle the bone will yaw to
  37224. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37225. * * upAxis: the up axis of the coordinate system
  37226. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37227. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37228. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37229. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37230. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37231. * * adjustRoll: used to make an adjustment to the roll of the bone
  37232. **/
  37233. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37234. maxYaw?: number;
  37235. minYaw?: number;
  37236. maxPitch?: number;
  37237. minPitch?: number;
  37238. slerpAmount?: number;
  37239. upAxis?: Vector3;
  37240. upAxisSpace?: Space;
  37241. yawAxis?: Vector3;
  37242. pitchAxis?: Vector3;
  37243. adjustYaw?: number;
  37244. adjustPitch?: number;
  37245. adjustRoll?: number;
  37246. });
  37247. /**
  37248. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37249. */
  37250. update(): void;
  37251. private _getAngleDiff;
  37252. private _getAngleBetween;
  37253. private _isAngleBetween;
  37254. }
  37255. }
  37256. declare module "babylonjs/Bones/index" {
  37257. export * from "babylonjs/Bones/bone";
  37258. export * from "babylonjs/Bones/boneIKController";
  37259. export * from "babylonjs/Bones/boneLookController";
  37260. export * from "babylonjs/Bones/skeleton";
  37261. }
  37262. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37263. import { Nullable } from "babylonjs/types";
  37264. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37265. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37266. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37267. /**
  37268. * Manage the gamepad inputs to control an arc rotate camera.
  37269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37270. */
  37271. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37272. /**
  37273. * Defines the camera the input is attached to.
  37274. */
  37275. camera: ArcRotateCamera;
  37276. /**
  37277. * Defines the gamepad the input is gathering event from.
  37278. */
  37279. gamepad: Nullable<Gamepad>;
  37280. /**
  37281. * Defines the gamepad rotation sensiblity.
  37282. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37283. */
  37284. gamepadRotationSensibility: number;
  37285. /**
  37286. * Defines the gamepad move sensiblity.
  37287. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37288. */
  37289. gamepadMoveSensibility: number;
  37290. private _onGamepadConnectedObserver;
  37291. private _onGamepadDisconnectedObserver;
  37292. /**
  37293. * Attach the input controls to a specific dom element to get the input from.
  37294. * @param element Defines the element the controls should be listened from
  37295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37296. */
  37297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37298. /**
  37299. * Detach the current controls from the specified dom element.
  37300. * @param element Defines the element to stop listening the inputs from
  37301. */
  37302. detachControl(element: Nullable<HTMLElement>): void;
  37303. /**
  37304. * Update the current camera state depending on the inputs that have been used this frame.
  37305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37306. */
  37307. checkInputs(): void;
  37308. /**
  37309. * Gets the class name of the current intput.
  37310. * @returns the class name
  37311. */
  37312. getClassName(): string;
  37313. /**
  37314. * Get the friendly name associated with the input class.
  37315. * @returns the input friendly name
  37316. */
  37317. getSimpleName(): string;
  37318. }
  37319. }
  37320. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37321. import { Nullable } from "babylonjs/types";
  37322. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37323. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37324. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37325. interface ArcRotateCameraInputsManager {
  37326. /**
  37327. * Add orientation input support to the input manager.
  37328. * @returns the current input manager
  37329. */
  37330. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37331. }
  37332. }
  37333. /**
  37334. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37336. */
  37337. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37338. /**
  37339. * Defines the camera the input is attached to.
  37340. */
  37341. camera: ArcRotateCamera;
  37342. /**
  37343. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37344. */
  37345. alphaCorrection: number;
  37346. /**
  37347. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37348. */
  37349. gammaCorrection: number;
  37350. private _alpha;
  37351. private _gamma;
  37352. private _dirty;
  37353. private _deviceOrientationHandler;
  37354. /**
  37355. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37356. */
  37357. constructor();
  37358. /**
  37359. * Attach the input controls to a specific dom element to get the input from.
  37360. * @param element Defines the element the controls should be listened from
  37361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37362. */
  37363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37364. /** @hidden */
  37365. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37366. /**
  37367. * Update the current camera state depending on the inputs that have been used this frame.
  37368. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37369. */
  37370. checkInputs(): void;
  37371. /**
  37372. * Detach the current controls from the specified dom element.
  37373. * @param element Defines the element to stop listening the inputs from
  37374. */
  37375. detachControl(element: Nullable<HTMLElement>): void;
  37376. /**
  37377. * Gets the class name of the current intput.
  37378. * @returns the class name
  37379. */
  37380. getClassName(): string;
  37381. /**
  37382. * Get the friendly name associated with the input class.
  37383. * @returns the input friendly name
  37384. */
  37385. getSimpleName(): string;
  37386. }
  37387. }
  37388. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37389. import { Nullable } from "babylonjs/types";
  37390. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37391. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37392. /**
  37393. * Listen to mouse events to control the camera.
  37394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37395. */
  37396. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37397. /**
  37398. * Defines the camera the input is attached to.
  37399. */
  37400. camera: FlyCamera;
  37401. /**
  37402. * Defines if touch is enabled. (Default is true.)
  37403. */
  37404. touchEnabled: boolean;
  37405. /**
  37406. * Defines the buttons associated with the input to handle camera rotation.
  37407. */
  37408. buttons: number[];
  37409. /**
  37410. * Assign buttons for Yaw control.
  37411. */
  37412. buttonsYaw: number[];
  37413. /**
  37414. * Assign buttons for Pitch control.
  37415. */
  37416. buttonsPitch: number[];
  37417. /**
  37418. * Assign buttons for Roll control.
  37419. */
  37420. buttonsRoll: number[];
  37421. /**
  37422. * Detect if any button is being pressed while mouse is moved.
  37423. * -1 = Mouse locked.
  37424. * 0 = Left button.
  37425. * 1 = Middle Button.
  37426. * 2 = Right Button.
  37427. */
  37428. activeButton: number;
  37429. /**
  37430. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37431. * Higher values reduce its sensitivity.
  37432. */
  37433. angularSensibility: number;
  37434. private _mousemoveCallback;
  37435. private _observer;
  37436. private _rollObserver;
  37437. private previousPosition;
  37438. private noPreventDefault;
  37439. private element;
  37440. /**
  37441. * Listen to mouse events to control the camera.
  37442. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37444. */
  37445. constructor(touchEnabled?: boolean);
  37446. /**
  37447. * Attach the mouse control to the HTML DOM element.
  37448. * @param element Defines the element that listens to the input events.
  37449. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37450. */
  37451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37452. /**
  37453. * Detach the current controls from the specified dom element.
  37454. * @param element Defines the element to stop listening the inputs from
  37455. */
  37456. detachControl(element: Nullable<HTMLElement>): void;
  37457. /**
  37458. * Gets the class name of the current input.
  37459. * @returns the class name.
  37460. */
  37461. getClassName(): string;
  37462. /**
  37463. * Get the friendly name associated with the input class.
  37464. * @returns the input's friendly name.
  37465. */
  37466. getSimpleName(): string;
  37467. private _pointerInput;
  37468. private _onMouseMove;
  37469. /**
  37470. * Rotate camera by mouse offset.
  37471. */
  37472. private rotateCamera;
  37473. }
  37474. }
  37475. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37476. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37477. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37478. /**
  37479. * Default Inputs manager for the FlyCamera.
  37480. * It groups all the default supported inputs for ease of use.
  37481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37482. */
  37483. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37484. /**
  37485. * Instantiates a new FlyCameraInputsManager.
  37486. * @param camera Defines the camera the inputs belong to.
  37487. */
  37488. constructor(camera: FlyCamera);
  37489. /**
  37490. * Add keyboard input support to the input manager.
  37491. * @returns the new FlyCameraKeyboardMoveInput().
  37492. */
  37493. addKeyboard(): FlyCameraInputsManager;
  37494. /**
  37495. * Add mouse input support to the input manager.
  37496. * @param touchEnabled Enable touch screen support.
  37497. * @returns the new FlyCameraMouseInput().
  37498. */
  37499. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37500. }
  37501. }
  37502. declare module "babylonjs/Cameras/flyCamera" {
  37503. import { Scene } from "babylonjs/scene";
  37504. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37506. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37507. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37508. /**
  37509. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37510. * such as in a 3D Space Shooter or a Flight Simulator.
  37511. */
  37512. export class FlyCamera extends TargetCamera {
  37513. /**
  37514. * Define the collision ellipsoid of the camera.
  37515. * This is helpful for simulating a camera body, like a player's body.
  37516. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37517. */
  37518. ellipsoid: Vector3;
  37519. /**
  37520. * Define an offset for the position of the ellipsoid around the camera.
  37521. * This can be helpful if the camera is attached away from the player's body center,
  37522. * such as at its head.
  37523. */
  37524. ellipsoidOffset: Vector3;
  37525. /**
  37526. * Enable or disable collisions of the camera with the rest of the scene objects.
  37527. */
  37528. checkCollisions: boolean;
  37529. /**
  37530. * Enable or disable gravity on the camera.
  37531. */
  37532. applyGravity: boolean;
  37533. /**
  37534. * Define the current direction the camera is moving to.
  37535. */
  37536. cameraDirection: Vector3;
  37537. /**
  37538. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37539. * This overrides and empties cameraRotation.
  37540. */
  37541. rotationQuaternion: Quaternion;
  37542. /**
  37543. * Track Roll to maintain the wanted Rolling when looking around.
  37544. */
  37545. _trackRoll: number;
  37546. /**
  37547. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37548. */
  37549. rollCorrect: number;
  37550. /**
  37551. * Mimic a banked turn, Rolling the camera when Yawing.
  37552. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37553. */
  37554. bankedTurn: boolean;
  37555. /**
  37556. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37557. */
  37558. bankedTurnLimit: number;
  37559. /**
  37560. * Value of 0 disables the banked Roll.
  37561. * Value of 1 is equal to the Yaw angle in radians.
  37562. */
  37563. bankedTurnMultiplier: number;
  37564. /**
  37565. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37566. */
  37567. inputs: FlyCameraInputsManager;
  37568. /**
  37569. * Gets the input sensibility for mouse input.
  37570. * Higher values reduce sensitivity.
  37571. */
  37572. /**
  37573. * Sets the input sensibility for a mouse input.
  37574. * Higher values reduce sensitivity.
  37575. */
  37576. angularSensibility: number;
  37577. /**
  37578. * Get the keys for camera movement forward.
  37579. */
  37580. /**
  37581. * Set the keys for camera movement forward.
  37582. */
  37583. keysForward: number[];
  37584. /**
  37585. * Get the keys for camera movement backward.
  37586. */
  37587. keysBackward: number[];
  37588. /**
  37589. * Get the keys for camera movement up.
  37590. */
  37591. /**
  37592. * Set the keys for camera movement up.
  37593. */
  37594. keysUp: number[];
  37595. /**
  37596. * Get the keys for camera movement down.
  37597. */
  37598. /**
  37599. * Set the keys for camera movement down.
  37600. */
  37601. keysDown: number[];
  37602. /**
  37603. * Get the keys for camera movement left.
  37604. */
  37605. /**
  37606. * Set the keys for camera movement left.
  37607. */
  37608. keysLeft: number[];
  37609. /**
  37610. * Set the keys for camera movement right.
  37611. */
  37612. /**
  37613. * Set the keys for camera movement right.
  37614. */
  37615. keysRight: number[];
  37616. /**
  37617. * Event raised when the camera collides with a mesh in the scene.
  37618. */
  37619. onCollide: (collidedMesh: AbstractMesh) => void;
  37620. private _collider;
  37621. private _needMoveForGravity;
  37622. private _oldPosition;
  37623. private _diffPosition;
  37624. private _newPosition;
  37625. /** @hidden */
  37626. _localDirection: Vector3;
  37627. /** @hidden */
  37628. _transformedDirection: Vector3;
  37629. /**
  37630. * Instantiates a FlyCamera.
  37631. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37632. * such as in a 3D Space Shooter or a Flight Simulator.
  37633. * @param name Define the name of the camera in the scene.
  37634. * @param position Define the starting position of the camera in the scene.
  37635. * @param scene Define the scene the camera belongs to.
  37636. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37637. */
  37638. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37639. /**
  37640. * Attach a control to the HTML DOM element.
  37641. * @param element Defines the element that listens to the input events.
  37642. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37643. */
  37644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37645. /**
  37646. * Detach a control from the HTML DOM element.
  37647. * The camera will stop reacting to that input.
  37648. * @param element Defines the element that listens to the input events.
  37649. */
  37650. detachControl(element: HTMLElement): void;
  37651. private _collisionMask;
  37652. /**
  37653. * Get the mask that the camera ignores in collision events.
  37654. */
  37655. /**
  37656. * Set the mask that the camera ignores in collision events.
  37657. */
  37658. collisionMask: number;
  37659. /** @hidden */
  37660. _collideWithWorld(displacement: Vector3): void;
  37661. /** @hidden */
  37662. private _onCollisionPositionChange;
  37663. /** @hidden */
  37664. _checkInputs(): void;
  37665. /** @hidden */
  37666. _decideIfNeedsToMove(): boolean;
  37667. /** @hidden */
  37668. _updatePosition(): void;
  37669. /**
  37670. * Restore the Roll to its target value at the rate specified.
  37671. * @param rate - Higher means slower restoring.
  37672. * @hidden
  37673. */
  37674. restoreRoll(rate: number): void;
  37675. /**
  37676. * Destroy the camera and release the current resources held by it.
  37677. */
  37678. dispose(): void;
  37679. /**
  37680. * Get the current object class name.
  37681. * @returns the class name.
  37682. */
  37683. getClassName(): string;
  37684. }
  37685. }
  37686. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37687. import { Nullable } from "babylonjs/types";
  37688. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37689. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37690. /**
  37691. * Listen to keyboard events to control the camera.
  37692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37693. */
  37694. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37695. /**
  37696. * Defines the camera the input is attached to.
  37697. */
  37698. camera: FlyCamera;
  37699. /**
  37700. * The list of keyboard keys used to control the forward move of the camera.
  37701. */
  37702. keysForward: number[];
  37703. /**
  37704. * The list of keyboard keys used to control the backward move of the camera.
  37705. */
  37706. keysBackward: number[];
  37707. /**
  37708. * The list of keyboard keys used to control the forward move of the camera.
  37709. */
  37710. keysUp: number[];
  37711. /**
  37712. * The list of keyboard keys used to control the backward move of the camera.
  37713. */
  37714. keysDown: number[];
  37715. /**
  37716. * The list of keyboard keys used to control the right strafe move of the camera.
  37717. */
  37718. keysRight: number[];
  37719. /**
  37720. * The list of keyboard keys used to control the left strafe move of the camera.
  37721. */
  37722. keysLeft: number[];
  37723. private _keys;
  37724. private _onCanvasBlurObserver;
  37725. private _onKeyboardObserver;
  37726. private _engine;
  37727. private _scene;
  37728. /**
  37729. * Attach the input controls to a specific dom element to get the input from.
  37730. * @param element Defines the element the controls should be listened from
  37731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37732. */
  37733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37734. /**
  37735. * Detach the current controls from the specified dom element.
  37736. * @param element Defines the element to stop listening the inputs from
  37737. */
  37738. detachControl(element: Nullable<HTMLElement>): void;
  37739. /**
  37740. * Gets the class name of the current intput.
  37741. * @returns the class name
  37742. */
  37743. getClassName(): string;
  37744. /** @hidden */
  37745. _onLostFocus(e: FocusEvent): void;
  37746. /**
  37747. * Get the friendly name associated with the input class.
  37748. * @returns the input friendly name
  37749. */
  37750. getSimpleName(): string;
  37751. /**
  37752. * Update the current camera state depending on the inputs that have been used this frame.
  37753. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37754. */
  37755. checkInputs(): void;
  37756. }
  37757. }
  37758. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37759. import { Nullable } from "babylonjs/types";
  37760. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37761. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37762. /**
  37763. * Manage the mouse wheel inputs to control a follow camera.
  37764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37765. */
  37766. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37767. /**
  37768. * Defines the camera the input is attached to.
  37769. */
  37770. camera: FollowCamera;
  37771. /**
  37772. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37773. */
  37774. axisControlRadius: boolean;
  37775. /**
  37776. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37777. */
  37778. axisControlHeight: boolean;
  37779. /**
  37780. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37781. */
  37782. axisControlRotation: boolean;
  37783. /**
  37784. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37785. * relation to mouseWheel events.
  37786. */
  37787. wheelPrecision: number;
  37788. /**
  37789. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37790. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37791. */
  37792. wheelDeltaPercentage: number;
  37793. private _wheel;
  37794. private _observer;
  37795. /**
  37796. * Attach the input controls to a specific dom element to get the input from.
  37797. * @param element Defines the element the controls should be listened from
  37798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37799. */
  37800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37801. /**
  37802. * Detach the current controls from the specified dom element.
  37803. * @param element Defines the element to stop listening the inputs from
  37804. */
  37805. detachControl(element: Nullable<HTMLElement>): void;
  37806. /**
  37807. * Gets the class name of the current intput.
  37808. * @returns the class name
  37809. */
  37810. getClassName(): string;
  37811. /**
  37812. * Get the friendly name associated with the input class.
  37813. * @returns the input friendly name
  37814. */
  37815. getSimpleName(): string;
  37816. }
  37817. }
  37818. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37819. import { Nullable } from "babylonjs/types";
  37820. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37821. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37822. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37823. /**
  37824. * Manage the pointers inputs to control an follow camera.
  37825. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37826. */
  37827. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37828. /**
  37829. * Defines the camera the input is attached to.
  37830. */
  37831. camera: FollowCamera;
  37832. /**
  37833. * Gets the class name of the current input.
  37834. * @returns the class name
  37835. */
  37836. getClassName(): string;
  37837. /**
  37838. * Defines the pointer angular sensibility along the X axis or how fast is
  37839. * the camera rotating.
  37840. * A negative number will reverse the axis direction.
  37841. */
  37842. angularSensibilityX: number;
  37843. /**
  37844. * Defines the pointer angular sensibility along the Y axis or how fast is
  37845. * the camera rotating.
  37846. * A negative number will reverse the axis direction.
  37847. */
  37848. angularSensibilityY: number;
  37849. /**
  37850. * Defines the pointer pinch precision or how fast is the camera zooming.
  37851. * A negative number will reverse the axis direction.
  37852. */
  37853. pinchPrecision: number;
  37854. /**
  37855. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37856. * from 0.
  37857. * It defines the percentage of current camera.radius to use as delta when
  37858. * pinch zoom is used.
  37859. */
  37860. pinchDeltaPercentage: number;
  37861. /**
  37862. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37863. */
  37864. axisXControlRadius: boolean;
  37865. /**
  37866. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37867. */
  37868. axisXControlHeight: boolean;
  37869. /**
  37870. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37871. */
  37872. axisXControlRotation: boolean;
  37873. /**
  37874. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37875. */
  37876. axisYControlRadius: boolean;
  37877. /**
  37878. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37879. */
  37880. axisYControlHeight: boolean;
  37881. /**
  37882. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37883. */
  37884. axisYControlRotation: boolean;
  37885. /**
  37886. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37887. */
  37888. axisPinchControlRadius: boolean;
  37889. /**
  37890. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37891. */
  37892. axisPinchControlHeight: boolean;
  37893. /**
  37894. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37895. */
  37896. axisPinchControlRotation: boolean;
  37897. /**
  37898. * Log error messages if basic misconfiguration has occurred.
  37899. */
  37900. warningEnable: boolean;
  37901. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37902. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37903. private _warningCounter;
  37904. private _warning;
  37905. }
  37906. }
  37907. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37908. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37909. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37910. /**
  37911. * Default Inputs manager for the FollowCamera.
  37912. * It groups all the default supported inputs for ease of use.
  37913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37914. */
  37915. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37916. /**
  37917. * Instantiates a new FollowCameraInputsManager.
  37918. * @param camera Defines the camera the inputs belong to
  37919. */
  37920. constructor(camera: FollowCamera);
  37921. /**
  37922. * Add keyboard input support to the input manager.
  37923. * @returns the current input manager
  37924. */
  37925. addKeyboard(): FollowCameraInputsManager;
  37926. /**
  37927. * Add mouse wheel input support to the input manager.
  37928. * @returns the current input manager
  37929. */
  37930. addMouseWheel(): FollowCameraInputsManager;
  37931. /**
  37932. * Add pointers input support to the input manager.
  37933. * @returns the current input manager
  37934. */
  37935. addPointers(): FollowCameraInputsManager;
  37936. /**
  37937. * Add orientation input support to the input manager.
  37938. * @returns the current input manager
  37939. */
  37940. addVRDeviceOrientation(): FollowCameraInputsManager;
  37941. }
  37942. }
  37943. declare module "babylonjs/Cameras/followCamera" {
  37944. import { Nullable } from "babylonjs/types";
  37945. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37946. import { Scene } from "babylonjs/scene";
  37947. import { Vector3 } from "babylonjs/Maths/math";
  37948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37949. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37950. /**
  37951. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37952. * an arc rotate version arcFollowCamera are available.
  37953. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37954. */
  37955. export class FollowCamera extends TargetCamera {
  37956. /**
  37957. * Distance the follow camera should follow an object at
  37958. */
  37959. radius: number;
  37960. /**
  37961. * Minimum allowed distance of the camera to the axis of rotation
  37962. * (The camera can not get closer).
  37963. * This can help limiting how the Camera is able to move in the scene.
  37964. */
  37965. lowerRadiusLimit: Nullable<number>;
  37966. /**
  37967. * Maximum allowed distance of the camera to the axis of rotation
  37968. * (The camera can not get further).
  37969. * This can help limiting how the Camera is able to move in the scene.
  37970. */
  37971. upperRadiusLimit: Nullable<number>;
  37972. /**
  37973. * Define a rotation offset between the camera and the object it follows
  37974. */
  37975. rotationOffset: number;
  37976. /**
  37977. * Minimum allowed angle to camera position relative to target object.
  37978. * This can help limiting how the Camera is able to move in the scene.
  37979. */
  37980. lowerRotationOffsetLimit: Nullable<number>;
  37981. /**
  37982. * Maximum allowed angle to camera position relative to target object.
  37983. * This can help limiting how the Camera is able to move in the scene.
  37984. */
  37985. upperRotationOffsetLimit: Nullable<number>;
  37986. /**
  37987. * Define a height offset between the camera and the object it follows.
  37988. * It can help following an object from the top (like a car chaing a plane)
  37989. */
  37990. heightOffset: number;
  37991. /**
  37992. * Minimum allowed height of camera position relative to target object.
  37993. * This can help limiting how the Camera is able to move in the scene.
  37994. */
  37995. lowerHeightOffsetLimit: Nullable<number>;
  37996. /**
  37997. * Maximum allowed height of camera position relative to target object.
  37998. * This can help limiting how the Camera is able to move in the scene.
  37999. */
  38000. upperHeightOffsetLimit: Nullable<number>;
  38001. /**
  38002. * Define how fast the camera can accelerate to follow it s target.
  38003. */
  38004. cameraAcceleration: number;
  38005. /**
  38006. * Define the speed limit of the camera following an object.
  38007. */
  38008. maxCameraSpeed: number;
  38009. /**
  38010. * Define the target of the camera.
  38011. */
  38012. lockedTarget: Nullable<AbstractMesh>;
  38013. /**
  38014. * Defines the input associated with the camera.
  38015. */
  38016. inputs: FollowCameraInputsManager;
  38017. /**
  38018. * Instantiates the follow camera.
  38019. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38020. * @param name Define the name of the camera in the scene
  38021. * @param position Define the position of the camera
  38022. * @param scene Define the scene the camera belong to
  38023. * @param lockedTarget Define the target of the camera
  38024. */
  38025. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38026. private _follow;
  38027. /**
  38028. * Attached controls to the current camera.
  38029. * @param element Defines the element the controls should be listened from
  38030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38031. */
  38032. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38033. /**
  38034. * Detach the current controls from the camera.
  38035. * The camera will stop reacting to inputs.
  38036. * @param element Defines the element to stop listening the inputs from
  38037. */
  38038. detachControl(element: HTMLElement): void;
  38039. /** @hidden */
  38040. _checkInputs(): void;
  38041. private _checkLimits;
  38042. /**
  38043. * Gets the camera class name.
  38044. * @returns the class name
  38045. */
  38046. getClassName(): string;
  38047. }
  38048. /**
  38049. * Arc Rotate version of the follow camera.
  38050. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38051. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38052. */
  38053. export class ArcFollowCamera extends TargetCamera {
  38054. /** The longitudinal angle of the camera */
  38055. alpha: number;
  38056. /** The latitudinal angle of the camera */
  38057. beta: number;
  38058. /** The radius of the camera from its target */
  38059. radius: number;
  38060. /** Define the camera target (the messh it should follow) */
  38061. target: Nullable<AbstractMesh>;
  38062. private _cartesianCoordinates;
  38063. /**
  38064. * Instantiates a new ArcFollowCamera
  38065. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38066. * @param name Define the name of the camera
  38067. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38068. * @param beta Define the rotation angle of the camera around the elevation axis
  38069. * @param radius Define the radius of the camera from its target point
  38070. * @param target Define the target of the camera
  38071. * @param scene Define the scene the camera belongs to
  38072. */
  38073. constructor(name: string,
  38074. /** The longitudinal angle of the camera */
  38075. alpha: number,
  38076. /** The latitudinal angle of the camera */
  38077. beta: number,
  38078. /** The radius of the camera from its target */
  38079. radius: number,
  38080. /** Define the camera target (the messh it should follow) */
  38081. target: Nullable<AbstractMesh>, scene: Scene);
  38082. private _follow;
  38083. /** @hidden */
  38084. _checkInputs(): void;
  38085. /**
  38086. * Returns the class name of the object.
  38087. * It is mostly used internally for serialization purposes.
  38088. */
  38089. getClassName(): string;
  38090. }
  38091. }
  38092. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38093. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38094. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38095. import { Nullable } from "babylonjs/types";
  38096. /**
  38097. * Manage the keyboard inputs to control the movement of a follow camera.
  38098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38099. */
  38100. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38101. /**
  38102. * Defines the camera the input is attached to.
  38103. */
  38104. camera: FollowCamera;
  38105. /**
  38106. * Defines the list of key codes associated with the up action (increase heightOffset)
  38107. */
  38108. keysHeightOffsetIncr: number[];
  38109. /**
  38110. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38111. */
  38112. keysHeightOffsetDecr: number[];
  38113. /**
  38114. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38115. */
  38116. keysHeightOffsetModifierAlt: boolean;
  38117. /**
  38118. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38119. */
  38120. keysHeightOffsetModifierCtrl: boolean;
  38121. /**
  38122. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38123. */
  38124. keysHeightOffsetModifierShift: boolean;
  38125. /**
  38126. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38127. */
  38128. keysRotationOffsetIncr: number[];
  38129. /**
  38130. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38131. */
  38132. keysRotationOffsetDecr: number[];
  38133. /**
  38134. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38135. */
  38136. keysRotationOffsetModifierAlt: boolean;
  38137. /**
  38138. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38139. */
  38140. keysRotationOffsetModifierCtrl: boolean;
  38141. /**
  38142. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38143. */
  38144. keysRotationOffsetModifierShift: boolean;
  38145. /**
  38146. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38147. */
  38148. keysRadiusIncr: number[];
  38149. /**
  38150. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38151. */
  38152. keysRadiusDecr: number[];
  38153. /**
  38154. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38155. */
  38156. keysRadiusModifierAlt: boolean;
  38157. /**
  38158. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38159. */
  38160. keysRadiusModifierCtrl: boolean;
  38161. /**
  38162. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38163. */
  38164. keysRadiusModifierShift: boolean;
  38165. /**
  38166. * Defines the rate of change of heightOffset.
  38167. */
  38168. heightSensibility: number;
  38169. /**
  38170. * Defines the rate of change of rotationOffset.
  38171. */
  38172. rotationSensibility: number;
  38173. /**
  38174. * Defines the rate of change of radius.
  38175. */
  38176. radiusSensibility: number;
  38177. private _keys;
  38178. private _ctrlPressed;
  38179. private _altPressed;
  38180. private _shiftPressed;
  38181. private _onCanvasBlurObserver;
  38182. private _onKeyboardObserver;
  38183. private _engine;
  38184. private _scene;
  38185. /**
  38186. * Attach the input controls to a specific dom element to get the input from.
  38187. * @param element Defines the element the controls should be listened from
  38188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38189. */
  38190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38191. /**
  38192. * Detach the current controls from the specified dom element.
  38193. * @param element Defines the element to stop listening the inputs from
  38194. */
  38195. detachControl(element: Nullable<HTMLElement>): void;
  38196. /**
  38197. * Update the current camera state depending on the inputs that have been used this frame.
  38198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38199. */
  38200. checkInputs(): void;
  38201. /**
  38202. * Gets the class name of the current input.
  38203. * @returns the class name
  38204. */
  38205. getClassName(): string;
  38206. /**
  38207. * Get the friendly name associated with the input class.
  38208. * @returns the input friendly name
  38209. */
  38210. getSimpleName(): string;
  38211. /**
  38212. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38213. * allow modification of the heightOffset value.
  38214. */
  38215. private _modifierHeightOffset;
  38216. /**
  38217. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38218. * allow modification of the rotationOffset value.
  38219. */
  38220. private _modifierRotationOffset;
  38221. /**
  38222. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38223. * allow modification of the radius value.
  38224. */
  38225. private _modifierRadius;
  38226. }
  38227. }
  38228. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38229. import { Nullable } from "babylonjs/types";
  38230. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38231. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38232. import { Observable } from "babylonjs/Misc/observable";
  38233. module "babylonjs/Cameras/freeCameraInputsManager" {
  38234. interface FreeCameraInputsManager {
  38235. /**
  38236. * @hidden
  38237. */
  38238. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38239. /**
  38240. * Add orientation input support to the input manager.
  38241. * @returns the current input manager
  38242. */
  38243. addDeviceOrientation(): FreeCameraInputsManager;
  38244. }
  38245. }
  38246. /**
  38247. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38248. * Screen rotation is taken into account.
  38249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38250. */
  38251. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38252. private _camera;
  38253. private _screenOrientationAngle;
  38254. private _constantTranform;
  38255. private _screenQuaternion;
  38256. private _alpha;
  38257. private _beta;
  38258. private _gamma;
  38259. /**
  38260. * @hidden
  38261. */
  38262. _onDeviceOrientationChangedObservable: Observable<void>;
  38263. /**
  38264. * Instantiates a new input
  38265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38266. */
  38267. constructor();
  38268. /**
  38269. * Define the camera controlled by the input.
  38270. */
  38271. camera: FreeCamera;
  38272. /**
  38273. * Attach the input controls to a specific dom element to get the input from.
  38274. * @param element Defines the element the controls should be listened from
  38275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38276. */
  38277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38278. private _orientationChanged;
  38279. private _deviceOrientation;
  38280. /**
  38281. * Detach the current controls from the specified dom element.
  38282. * @param element Defines the element to stop listening the inputs from
  38283. */
  38284. detachControl(element: Nullable<HTMLElement>): void;
  38285. /**
  38286. * Update the current camera state depending on the inputs that have been used this frame.
  38287. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38288. */
  38289. checkInputs(): void;
  38290. /**
  38291. * Gets the class name of the current intput.
  38292. * @returns the class name
  38293. */
  38294. getClassName(): string;
  38295. /**
  38296. * Get the friendly name associated with the input class.
  38297. * @returns the input friendly name
  38298. */
  38299. getSimpleName(): string;
  38300. }
  38301. }
  38302. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38303. import { Nullable } from "babylonjs/types";
  38304. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38305. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38306. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38307. /**
  38308. * Manage the gamepad inputs to control a free camera.
  38309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38310. */
  38311. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38312. /**
  38313. * Define the camera the input is attached to.
  38314. */
  38315. camera: FreeCamera;
  38316. /**
  38317. * Define the Gamepad controlling the input
  38318. */
  38319. gamepad: Nullable<Gamepad>;
  38320. /**
  38321. * Defines the gamepad rotation sensiblity.
  38322. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38323. */
  38324. gamepadAngularSensibility: number;
  38325. /**
  38326. * Defines the gamepad move sensiblity.
  38327. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38328. */
  38329. gamepadMoveSensibility: number;
  38330. private _onGamepadConnectedObserver;
  38331. private _onGamepadDisconnectedObserver;
  38332. private _cameraTransform;
  38333. private _deltaTransform;
  38334. private _vector3;
  38335. private _vector2;
  38336. /**
  38337. * Attach the input controls to a specific dom element to get the input from.
  38338. * @param element Defines the element the controls should be listened from
  38339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38340. */
  38341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38342. /**
  38343. * Detach the current controls from the specified dom element.
  38344. * @param element Defines the element to stop listening the inputs from
  38345. */
  38346. detachControl(element: Nullable<HTMLElement>): void;
  38347. /**
  38348. * Update the current camera state depending on the inputs that have been used this frame.
  38349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38350. */
  38351. checkInputs(): void;
  38352. /**
  38353. * Gets the class name of the current intput.
  38354. * @returns the class name
  38355. */
  38356. getClassName(): string;
  38357. /**
  38358. * Get the friendly name associated with the input class.
  38359. * @returns the input friendly name
  38360. */
  38361. getSimpleName(): string;
  38362. }
  38363. }
  38364. declare module "babylonjs/Misc/virtualJoystick" {
  38365. import { Nullable } from "babylonjs/types";
  38366. import { Vector3 } from "babylonjs/Maths/math";
  38367. /**
  38368. * Defines the potential axis of a Joystick
  38369. */
  38370. export enum JoystickAxis {
  38371. /** X axis */
  38372. X = 0,
  38373. /** Y axis */
  38374. Y = 1,
  38375. /** Z axis */
  38376. Z = 2
  38377. }
  38378. /**
  38379. * Class used to define virtual joystick (used in touch mode)
  38380. */
  38381. export class VirtualJoystick {
  38382. /**
  38383. * Gets or sets a boolean indicating that left and right values must be inverted
  38384. */
  38385. reverseLeftRight: boolean;
  38386. /**
  38387. * Gets or sets a boolean indicating that up and down values must be inverted
  38388. */
  38389. reverseUpDown: boolean;
  38390. /**
  38391. * Gets the offset value for the position (ie. the change of the position value)
  38392. */
  38393. deltaPosition: Vector3;
  38394. /**
  38395. * Gets a boolean indicating if the virtual joystick was pressed
  38396. */
  38397. pressed: boolean;
  38398. /**
  38399. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38400. */
  38401. static Canvas: Nullable<HTMLCanvasElement>;
  38402. private static _globalJoystickIndex;
  38403. private static vjCanvasContext;
  38404. private static vjCanvasWidth;
  38405. private static vjCanvasHeight;
  38406. private static halfWidth;
  38407. private _action;
  38408. private _axisTargetedByLeftAndRight;
  38409. private _axisTargetedByUpAndDown;
  38410. private _joystickSensibility;
  38411. private _inversedSensibility;
  38412. private _joystickPointerID;
  38413. private _joystickColor;
  38414. private _joystickPointerPos;
  38415. private _joystickPreviousPointerPos;
  38416. private _joystickPointerStartPos;
  38417. private _deltaJoystickVector;
  38418. private _leftJoystick;
  38419. private _touches;
  38420. private _onPointerDownHandlerRef;
  38421. private _onPointerMoveHandlerRef;
  38422. private _onPointerUpHandlerRef;
  38423. private _onResize;
  38424. /**
  38425. * Creates a new virtual joystick
  38426. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38427. */
  38428. constructor(leftJoystick?: boolean);
  38429. /**
  38430. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38431. * @param newJoystickSensibility defines the new sensibility
  38432. */
  38433. setJoystickSensibility(newJoystickSensibility: number): void;
  38434. private _onPointerDown;
  38435. private _onPointerMove;
  38436. private _onPointerUp;
  38437. /**
  38438. * Change the color of the virtual joystick
  38439. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38440. */
  38441. setJoystickColor(newColor: string): void;
  38442. /**
  38443. * Defines a callback to call when the joystick is touched
  38444. * @param action defines the callback
  38445. */
  38446. setActionOnTouch(action: () => any): void;
  38447. /**
  38448. * Defines which axis you'd like to control for left & right
  38449. * @param axis defines the axis to use
  38450. */
  38451. setAxisForLeftRight(axis: JoystickAxis): void;
  38452. /**
  38453. * Defines which axis you'd like to control for up & down
  38454. * @param axis defines the axis to use
  38455. */
  38456. setAxisForUpDown(axis: JoystickAxis): void;
  38457. private _drawVirtualJoystick;
  38458. /**
  38459. * Release internal HTML canvas
  38460. */
  38461. releaseCanvas(): void;
  38462. }
  38463. }
  38464. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38465. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38466. import { Nullable } from "babylonjs/types";
  38467. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38468. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38469. module "babylonjs/Cameras/freeCameraInputsManager" {
  38470. interface FreeCameraInputsManager {
  38471. /**
  38472. * Add virtual joystick input support to the input manager.
  38473. * @returns the current input manager
  38474. */
  38475. addVirtualJoystick(): FreeCameraInputsManager;
  38476. }
  38477. }
  38478. /**
  38479. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38481. */
  38482. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38483. /**
  38484. * Defines the camera the input is attached to.
  38485. */
  38486. camera: FreeCamera;
  38487. private _leftjoystick;
  38488. private _rightjoystick;
  38489. /**
  38490. * Gets the left stick of the virtual joystick.
  38491. * @returns The virtual Joystick
  38492. */
  38493. getLeftJoystick(): VirtualJoystick;
  38494. /**
  38495. * Gets the right stick of the virtual joystick.
  38496. * @returns The virtual Joystick
  38497. */
  38498. getRightJoystick(): VirtualJoystick;
  38499. /**
  38500. * Update the current camera state depending on the inputs that have been used this frame.
  38501. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38502. */
  38503. checkInputs(): void;
  38504. /**
  38505. * Attach the input controls to a specific dom element to get the input from.
  38506. * @param element Defines the element the controls should be listened from
  38507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38508. */
  38509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38510. /**
  38511. * Detach the current controls from the specified dom element.
  38512. * @param element Defines the element to stop listening the inputs from
  38513. */
  38514. detachControl(element: Nullable<HTMLElement>): void;
  38515. /**
  38516. * Gets the class name of the current intput.
  38517. * @returns the class name
  38518. */
  38519. getClassName(): string;
  38520. /**
  38521. * Get the friendly name associated with the input class.
  38522. * @returns the input friendly name
  38523. */
  38524. getSimpleName(): string;
  38525. }
  38526. }
  38527. declare module "babylonjs/Cameras/Inputs/index" {
  38528. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38529. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38530. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38531. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38532. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38533. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38534. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38535. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38536. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38537. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38538. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38539. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38540. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38541. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38542. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38543. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38544. }
  38545. declare module "babylonjs/Cameras/touchCamera" {
  38546. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38547. import { Scene } from "babylonjs/scene";
  38548. import { Vector3 } from "babylonjs/Maths/math";
  38549. /**
  38550. * This represents a FPS type of camera controlled by touch.
  38551. * This is like a universal camera minus the Gamepad controls.
  38552. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38553. */
  38554. export class TouchCamera extends FreeCamera {
  38555. /**
  38556. * Defines the touch sensibility for rotation.
  38557. * The higher the faster.
  38558. */
  38559. touchAngularSensibility: number;
  38560. /**
  38561. * Defines the touch sensibility for move.
  38562. * The higher the faster.
  38563. */
  38564. touchMoveSensibility: number;
  38565. /**
  38566. * Instantiates a new touch camera.
  38567. * This represents a FPS type of camera controlled by touch.
  38568. * This is like a universal camera minus the Gamepad controls.
  38569. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38570. * @param name Define the name of the camera in the scene
  38571. * @param position Define the start position of the camera in the scene
  38572. * @param scene Define the scene the camera belongs to
  38573. */
  38574. constructor(name: string, position: Vector3, scene: Scene);
  38575. /**
  38576. * Gets the current object class name.
  38577. * @return the class name
  38578. */
  38579. getClassName(): string;
  38580. /** @hidden */
  38581. _setupInputs(): void;
  38582. }
  38583. }
  38584. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38585. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38586. import { Scene } from "babylonjs/scene";
  38587. import { Vector3, Axis } from "babylonjs/Maths/math";
  38588. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38589. /**
  38590. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38591. * being tilted forward or back and left or right.
  38592. */
  38593. export class DeviceOrientationCamera extends FreeCamera {
  38594. private _initialQuaternion;
  38595. private _quaternionCache;
  38596. private _tmpDragQuaternion;
  38597. /**
  38598. * Creates a new device orientation camera
  38599. * @param name The name of the camera
  38600. * @param position The start position camera
  38601. * @param scene The scene the camera belongs to
  38602. */
  38603. constructor(name: string, position: Vector3, scene: Scene);
  38604. /**
  38605. * @hidden
  38606. * Disabled pointer input on first orientation sensor update (Default: true)
  38607. */
  38608. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38609. private _dragFactor;
  38610. /**
  38611. * Enabled turning on the y axis when the orientation sensor is active
  38612. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38613. */
  38614. enableHorizontalDragging(dragFactor?: number): void;
  38615. /**
  38616. * Gets the current instance class name ("DeviceOrientationCamera").
  38617. * This helps avoiding instanceof at run time.
  38618. * @returns the class name
  38619. */
  38620. getClassName(): string;
  38621. /**
  38622. * @hidden
  38623. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38624. */
  38625. _checkInputs(): void;
  38626. /**
  38627. * Reset the camera to its default orientation on the specified axis only.
  38628. * @param axis The axis to reset
  38629. */
  38630. resetToCurrentRotation(axis?: Axis): void;
  38631. }
  38632. }
  38633. declare module "babylonjs/Gamepads/xboxGamepad" {
  38634. import { Observable } from "babylonjs/Misc/observable";
  38635. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38636. /**
  38637. * Defines supported buttons for XBox360 compatible gamepads
  38638. */
  38639. export enum Xbox360Button {
  38640. /** A */
  38641. A = 0,
  38642. /** B */
  38643. B = 1,
  38644. /** X */
  38645. X = 2,
  38646. /** Y */
  38647. Y = 3,
  38648. /** Start */
  38649. Start = 4,
  38650. /** Back */
  38651. Back = 5,
  38652. /** Left button */
  38653. LB = 6,
  38654. /** Right button */
  38655. RB = 7,
  38656. /** Left stick */
  38657. LeftStick = 8,
  38658. /** Right stick */
  38659. RightStick = 9
  38660. }
  38661. /** Defines values for XBox360 DPad */
  38662. export enum Xbox360Dpad {
  38663. /** Up */
  38664. Up = 0,
  38665. /** Down */
  38666. Down = 1,
  38667. /** Left */
  38668. Left = 2,
  38669. /** Right */
  38670. Right = 3
  38671. }
  38672. /**
  38673. * Defines a XBox360 gamepad
  38674. */
  38675. export class Xbox360Pad extends Gamepad {
  38676. private _leftTrigger;
  38677. private _rightTrigger;
  38678. private _onlefttriggerchanged;
  38679. private _onrighttriggerchanged;
  38680. private _onbuttondown;
  38681. private _onbuttonup;
  38682. private _ondpaddown;
  38683. private _ondpadup;
  38684. /** Observable raised when a button is pressed */
  38685. onButtonDownObservable: Observable<Xbox360Button>;
  38686. /** Observable raised when a button is released */
  38687. onButtonUpObservable: Observable<Xbox360Button>;
  38688. /** Observable raised when a pad is pressed */
  38689. onPadDownObservable: Observable<Xbox360Dpad>;
  38690. /** Observable raised when a pad is released */
  38691. onPadUpObservable: Observable<Xbox360Dpad>;
  38692. private _buttonA;
  38693. private _buttonB;
  38694. private _buttonX;
  38695. private _buttonY;
  38696. private _buttonBack;
  38697. private _buttonStart;
  38698. private _buttonLB;
  38699. private _buttonRB;
  38700. private _buttonLeftStick;
  38701. private _buttonRightStick;
  38702. private _dPadUp;
  38703. private _dPadDown;
  38704. private _dPadLeft;
  38705. private _dPadRight;
  38706. private _isXboxOnePad;
  38707. /**
  38708. * Creates a new XBox360 gamepad object
  38709. * @param id defines the id of this gamepad
  38710. * @param index defines its index
  38711. * @param gamepad defines the internal HTML gamepad object
  38712. * @param xboxOne defines if it is a XBox One gamepad
  38713. */
  38714. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38715. /**
  38716. * Defines the callback to call when left trigger is pressed
  38717. * @param callback defines the callback to use
  38718. */
  38719. onlefttriggerchanged(callback: (value: number) => void): void;
  38720. /**
  38721. * Defines the callback to call when right trigger is pressed
  38722. * @param callback defines the callback to use
  38723. */
  38724. onrighttriggerchanged(callback: (value: number) => void): void;
  38725. /**
  38726. * Gets the left trigger value
  38727. */
  38728. /**
  38729. * Sets the left trigger value
  38730. */
  38731. leftTrigger: number;
  38732. /**
  38733. * Gets the right trigger value
  38734. */
  38735. /**
  38736. * Sets the right trigger value
  38737. */
  38738. rightTrigger: number;
  38739. /**
  38740. * Defines the callback to call when a button is pressed
  38741. * @param callback defines the callback to use
  38742. */
  38743. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38744. /**
  38745. * Defines the callback to call when a button is released
  38746. * @param callback defines the callback to use
  38747. */
  38748. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38749. /**
  38750. * Defines the callback to call when a pad is pressed
  38751. * @param callback defines the callback to use
  38752. */
  38753. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38754. /**
  38755. * Defines the callback to call when a pad is released
  38756. * @param callback defines the callback to use
  38757. */
  38758. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38759. private _setButtonValue;
  38760. private _setDPadValue;
  38761. /**
  38762. * Gets the value of the `A` button
  38763. */
  38764. /**
  38765. * Sets the value of the `A` button
  38766. */
  38767. buttonA: number;
  38768. /**
  38769. * Gets the value of the `B` button
  38770. */
  38771. /**
  38772. * Sets the value of the `B` button
  38773. */
  38774. buttonB: number;
  38775. /**
  38776. * Gets the value of the `X` button
  38777. */
  38778. /**
  38779. * Sets the value of the `X` button
  38780. */
  38781. buttonX: number;
  38782. /**
  38783. * Gets the value of the `Y` button
  38784. */
  38785. /**
  38786. * Sets the value of the `Y` button
  38787. */
  38788. buttonY: number;
  38789. /**
  38790. * Gets the value of the `Start` button
  38791. */
  38792. /**
  38793. * Sets the value of the `Start` button
  38794. */
  38795. buttonStart: number;
  38796. /**
  38797. * Gets the value of the `Back` button
  38798. */
  38799. /**
  38800. * Sets the value of the `Back` button
  38801. */
  38802. buttonBack: number;
  38803. /**
  38804. * Gets the value of the `Left` button
  38805. */
  38806. /**
  38807. * Sets the value of the `Left` button
  38808. */
  38809. buttonLB: number;
  38810. /**
  38811. * Gets the value of the `Right` button
  38812. */
  38813. /**
  38814. * Sets the value of the `Right` button
  38815. */
  38816. buttonRB: number;
  38817. /**
  38818. * Gets the value of the Left joystick
  38819. */
  38820. /**
  38821. * Sets the value of the Left joystick
  38822. */
  38823. buttonLeftStick: number;
  38824. /**
  38825. * Gets the value of the Right joystick
  38826. */
  38827. /**
  38828. * Sets the value of the Right joystick
  38829. */
  38830. buttonRightStick: number;
  38831. /**
  38832. * Gets the value of D-pad up
  38833. */
  38834. /**
  38835. * Sets the value of D-pad up
  38836. */
  38837. dPadUp: number;
  38838. /**
  38839. * Gets the value of D-pad down
  38840. */
  38841. /**
  38842. * Sets the value of D-pad down
  38843. */
  38844. dPadDown: number;
  38845. /**
  38846. * Gets the value of D-pad left
  38847. */
  38848. /**
  38849. * Sets the value of D-pad left
  38850. */
  38851. dPadLeft: number;
  38852. /**
  38853. * Gets the value of D-pad right
  38854. */
  38855. /**
  38856. * Sets the value of D-pad right
  38857. */
  38858. dPadRight: number;
  38859. /**
  38860. * Force the gamepad to synchronize with device values
  38861. */
  38862. update(): void;
  38863. /**
  38864. * Disposes the gamepad
  38865. */
  38866. dispose(): void;
  38867. }
  38868. }
  38869. declare module "babylonjs/Gamepads/gamepadManager" {
  38870. import { Observable } from "babylonjs/Misc/observable";
  38871. import { Nullable } from "babylonjs/types";
  38872. import { Scene } from "babylonjs/scene";
  38873. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38874. /**
  38875. * Manager for handling gamepads
  38876. */
  38877. export class GamepadManager {
  38878. private _scene?;
  38879. private _babylonGamepads;
  38880. private _oneGamepadConnected;
  38881. /** @hidden */
  38882. _isMonitoring: boolean;
  38883. private _gamepadEventSupported;
  38884. private _gamepadSupport;
  38885. /**
  38886. * observable to be triggered when the gamepad controller has been connected
  38887. */
  38888. onGamepadConnectedObservable: Observable<Gamepad>;
  38889. /**
  38890. * observable to be triggered when the gamepad controller has been disconnected
  38891. */
  38892. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38893. private _onGamepadConnectedEvent;
  38894. private _onGamepadDisconnectedEvent;
  38895. /**
  38896. * Initializes the gamepad manager
  38897. * @param _scene BabylonJS scene
  38898. */
  38899. constructor(_scene?: Scene | undefined);
  38900. /**
  38901. * The gamepads in the game pad manager
  38902. */
  38903. readonly gamepads: Gamepad[];
  38904. /**
  38905. * Get the gamepad controllers based on type
  38906. * @param type The type of gamepad controller
  38907. * @returns Nullable gamepad
  38908. */
  38909. getGamepadByType(type?: number): Nullable<Gamepad>;
  38910. /**
  38911. * Disposes the gamepad manager
  38912. */
  38913. dispose(): void;
  38914. private _addNewGamepad;
  38915. private _startMonitoringGamepads;
  38916. private _stopMonitoringGamepads;
  38917. /** @hidden */
  38918. _checkGamepadsStatus(): void;
  38919. private _updateGamepadObjects;
  38920. }
  38921. }
  38922. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  38923. import { Nullable } from "babylonjs/types";
  38924. import { Scene } from "babylonjs/scene";
  38925. import { ISceneComponent } from "babylonjs/sceneComponent";
  38926. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  38927. module "babylonjs/scene" {
  38928. interface Scene {
  38929. /** @hidden */
  38930. _gamepadManager: Nullable<GamepadManager>;
  38931. /**
  38932. * Gets the gamepad manager associated with the scene
  38933. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38934. */
  38935. gamepadManager: GamepadManager;
  38936. }
  38937. }
  38938. module "babylonjs/Cameras/freeCameraInputsManager" {
  38939. /**
  38940. * Interface representing a free camera inputs manager
  38941. */
  38942. interface FreeCameraInputsManager {
  38943. /**
  38944. * Adds gamepad input support to the FreeCameraInputsManager.
  38945. * @returns the FreeCameraInputsManager
  38946. */
  38947. addGamepad(): FreeCameraInputsManager;
  38948. }
  38949. }
  38950. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38951. /**
  38952. * Interface representing an arc rotate camera inputs manager
  38953. */
  38954. interface ArcRotateCameraInputsManager {
  38955. /**
  38956. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38957. * @returns the camera inputs manager
  38958. */
  38959. addGamepad(): ArcRotateCameraInputsManager;
  38960. }
  38961. }
  38962. /**
  38963. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38964. */
  38965. export class GamepadSystemSceneComponent implements ISceneComponent {
  38966. /**
  38967. * The component name helpfull to identify the component in the list of scene components.
  38968. */
  38969. readonly name: string;
  38970. /**
  38971. * The scene the component belongs to.
  38972. */
  38973. scene: Scene;
  38974. /**
  38975. * Creates a new instance of the component for the given scene
  38976. * @param scene Defines the scene to register the component in
  38977. */
  38978. constructor(scene: Scene);
  38979. /**
  38980. * Registers the component in a given scene
  38981. */
  38982. register(): void;
  38983. /**
  38984. * Rebuilds the elements related to this component in case of
  38985. * context lost for instance.
  38986. */
  38987. rebuild(): void;
  38988. /**
  38989. * Disposes the component and the associated ressources
  38990. */
  38991. dispose(): void;
  38992. private _beforeCameraUpdate;
  38993. }
  38994. }
  38995. declare module "babylonjs/Cameras/universalCamera" {
  38996. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38997. import { Scene } from "babylonjs/scene";
  38998. import { Vector3 } from "babylonjs/Maths/math";
  38999. import "babylonjs/Gamepads/gamepadSceneComponent";
  39000. /**
  39001. * 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,
  39002. * which still works and will still be found in many Playgrounds.
  39003. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39004. */
  39005. export class UniversalCamera extends TouchCamera {
  39006. /**
  39007. * Defines the gamepad rotation sensiblity.
  39008. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39009. */
  39010. gamepadAngularSensibility: number;
  39011. /**
  39012. * Defines the gamepad move sensiblity.
  39013. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39014. */
  39015. gamepadMoveSensibility: number;
  39016. /**
  39017. * 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,
  39018. * which still works and will still be found in many Playgrounds.
  39019. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39020. * @param name Define the name of the camera in the scene
  39021. * @param position Define the start position of the camera in the scene
  39022. * @param scene Define the scene the camera belongs to
  39023. */
  39024. constructor(name: string, position: Vector3, scene: Scene);
  39025. /**
  39026. * Gets the current object class name.
  39027. * @return the class name
  39028. */
  39029. getClassName(): string;
  39030. }
  39031. }
  39032. declare module "babylonjs/Cameras/gamepadCamera" {
  39033. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39034. import { Scene } from "babylonjs/scene";
  39035. import { Vector3 } from "babylonjs/Maths/math";
  39036. /**
  39037. * This represents a FPS type of camera. This is only here for back compat purpose.
  39038. * Please use the UniversalCamera instead as both are identical.
  39039. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39040. */
  39041. export class GamepadCamera extends UniversalCamera {
  39042. /**
  39043. * Instantiates a new Gamepad Camera
  39044. * This represents a FPS type of camera. This is only here for back compat purpose.
  39045. * Please use the UniversalCamera instead as both are identical.
  39046. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39047. * @param name Define the name of the camera in the scene
  39048. * @param position Define the start position of the camera in the scene
  39049. * @param scene Define the scene the camera belongs to
  39050. */
  39051. constructor(name: string, position: Vector3, scene: Scene);
  39052. /**
  39053. * Gets the current object class name.
  39054. * @return the class name
  39055. */
  39056. getClassName(): string;
  39057. }
  39058. }
  39059. declare module "babylonjs/Shaders/pass.fragment" {
  39060. /** @hidden */
  39061. export var passPixelShader: {
  39062. name: string;
  39063. shader: string;
  39064. };
  39065. }
  39066. declare module "babylonjs/Shaders/passCube.fragment" {
  39067. /** @hidden */
  39068. export var passCubePixelShader: {
  39069. name: string;
  39070. shader: string;
  39071. };
  39072. }
  39073. declare module "babylonjs/PostProcesses/passPostProcess" {
  39074. import { Nullable } from "babylonjs/types";
  39075. import { Camera } from "babylonjs/Cameras/camera";
  39076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39077. import { Engine } from "babylonjs/Engines/engine";
  39078. import "babylonjs/Shaders/pass.fragment";
  39079. import "babylonjs/Shaders/passCube.fragment";
  39080. /**
  39081. * PassPostProcess which produces an output the same as it's input
  39082. */
  39083. export class PassPostProcess extends PostProcess {
  39084. /**
  39085. * Creates the PassPostProcess
  39086. * @param name The name of the effect.
  39087. * @param options The required width/height ratio to downsize to before computing the render pass.
  39088. * @param camera The camera to apply the render pass to.
  39089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39090. * @param engine The engine which the post process will be applied. (default: current engine)
  39091. * @param reusable If the post process can be reused on the same frame. (default: false)
  39092. * @param textureType The type of texture to be used when performing the post processing.
  39093. * @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)
  39094. */
  39095. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39096. }
  39097. /**
  39098. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39099. */
  39100. export class PassCubePostProcess extends PostProcess {
  39101. private _face;
  39102. /**
  39103. * Gets or sets the cube face to display.
  39104. * * 0 is +X
  39105. * * 1 is -X
  39106. * * 2 is +Y
  39107. * * 3 is -Y
  39108. * * 4 is +Z
  39109. * * 5 is -Z
  39110. */
  39111. face: number;
  39112. /**
  39113. * Creates the PassCubePostProcess
  39114. * @param name The name of the effect.
  39115. * @param options The required width/height ratio to downsize to before computing the render pass.
  39116. * @param camera The camera to apply the render pass to.
  39117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39118. * @param engine The engine which the post process will be applied. (default: current engine)
  39119. * @param reusable If the post process can be reused on the same frame. (default: false)
  39120. * @param textureType The type of texture to be used when performing the post processing.
  39121. * @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)
  39122. */
  39123. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39124. }
  39125. }
  39126. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39127. /** @hidden */
  39128. export var anaglyphPixelShader: {
  39129. name: string;
  39130. shader: string;
  39131. };
  39132. }
  39133. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39134. import { Engine } from "babylonjs/Engines/engine";
  39135. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39136. import { Camera } from "babylonjs/Cameras/camera";
  39137. import "babylonjs/Shaders/anaglyph.fragment";
  39138. /**
  39139. * Postprocess used to generate anaglyphic rendering
  39140. */
  39141. export class AnaglyphPostProcess extends PostProcess {
  39142. private _passedProcess;
  39143. /**
  39144. * Creates a new AnaglyphPostProcess
  39145. * @param name defines postprocess name
  39146. * @param options defines creation options or target ratio scale
  39147. * @param rigCameras defines cameras using this postprocess
  39148. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39149. * @param engine defines hosting engine
  39150. * @param reusable defines if the postprocess will be reused multiple times per frame
  39151. */
  39152. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39153. }
  39154. }
  39155. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39156. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39157. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39158. import { Scene } from "babylonjs/scene";
  39159. import { Vector3 } from "babylonjs/Maths/math";
  39160. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39161. /**
  39162. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39163. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39164. */
  39165. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39166. /**
  39167. * Creates a new AnaglyphArcRotateCamera
  39168. * @param name defines camera name
  39169. * @param alpha defines alpha angle (in radians)
  39170. * @param beta defines beta angle (in radians)
  39171. * @param radius defines radius
  39172. * @param target defines camera target
  39173. * @param interaxialDistance defines distance between each color axis
  39174. * @param scene defines the hosting scene
  39175. */
  39176. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39177. /**
  39178. * Gets camera class name
  39179. * @returns AnaglyphArcRotateCamera
  39180. */
  39181. getClassName(): string;
  39182. }
  39183. }
  39184. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39185. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39186. import { Scene } from "babylonjs/scene";
  39187. import { Vector3 } from "babylonjs/Maths/math";
  39188. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39189. /**
  39190. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39191. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39192. */
  39193. export class AnaglyphFreeCamera extends FreeCamera {
  39194. /**
  39195. * Creates a new AnaglyphFreeCamera
  39196. * @param name defines camera name
  39197. * @param position defines initial position
  39198. * @param interaxialDistance defines distance between each color axis
  39199. * @param scene defines the hosting scene
  39200. */
  39201. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39202. /**
  39203. * Gets camera class name
  39204. * @returns AnaglyphFreeCamera
  39205. */
  39206. getClassName(): string;
  39207. }
  39208. }
  39209. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39210. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39211. import { Scene } from "babylonjs/scene";
  39212. import { Vector3 } from "babylonjs/Maths/math";
  39213. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39214. /**
  39215. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39216. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39217. */
  39218. export class AnaglyphGamepadCamera extends GamepadCamera {
  39219. /**
  39220. * Creates a new AnaglyphGamepadCamera
  39221. * @param name defines camera name
  39222. * @param position defines initial position
  39223. * @param interaxialDistance defines distance between each color axis
  39224. * @param scene defines the hosting scene
  39225. */
  39226. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39227. /**
  39228. * Gets camera class name
  39229. * @returns AnaglyphGamepadCamera
  39230. */
  39231. getClassName(): string;
  39232. }
  39233. }
  39234. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39235. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39236. import { Scene } from "babylonjs/scene";
  39237. import { Vector3 } from "babylonjs/Maths/math";
  39238. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39239. /**
  39240. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39241. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39242. */
  39243. export class AnaglyphUniversalCamera extends UniversalCamera {
  39244. /**
  39245. * Creates a new AnaglyphUniversalCamera
  39246. * @param name defines camera name
  39247. * @param position defines initial position
  39248. * @param interaxialDistance defines distance between each color axis
  39249. * @param scene defines the hosting scene
  39250. */
  39251. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39252. /**
  39253. * Gets camera class name
  39254. * @returns AnaglyphUniversalCamera
  39255. */
  39256. getClassName(): string;
  39257. }
  39258. }
  39259. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39260. /** @hidden */
  39261. export var stereoscopicInterlacePixelShader: {
  39262. name: string;
  39263. shader: string;
  39264. };
  39265. }
  39266. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39267. import { Camera } from "babylonjs/Cameras/camera";
  39268. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39269. import { Engine } from "babylonjs/Engines/engine";
  39270. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39271. /**
  39272. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39273. */
  39274. export class StereoscopicInterlacePostProcess extends PostProcess {
  39275. private _stepSize;
  39276. private _passedProcess;
  39277. /**
  39278. * Initializes a StereoscopicInterlacePostProcess
  39279. * @param name The name of the effect.
  39280. * @param rigCameras The rig cameras to be appled to the post process
  39281. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39283. * @param engine The engine which the post process will be applied. (default: current engine)
  39284. * @param reusable If the post process can be reused on the same frame. (default: false)
  39285. */
  39286. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39287. }
  39288. }
  39289. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39290. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39291. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39292. import { Scene } from "babylonjs/scene";
  39293. import { Vector3 } from "babylonjs/Maths/math";
  39294. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39295. /**
  39296. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39297. * @see http://doc.babylonjs.com/features/cameras
  39298. */
  39299. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39300. /**
  39301. * Creates a new StereoscopicArcRotateCamera
  39302. * @param name defines camera name
  39303. * @param alpha defines alpha angle (in radians)
  39304. * @param beta defines beta angle (in radians)
  39305. * @param radius defines radius
  39306. * @param target defines camera target
  39307. * @param interaxialDistance defines distance between each color axis
  39308. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39309. * @param scene defines the hosting scene
  39310. */
  39311. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39312. /**
  39313. * Gets camera class name
  39314. * @returns StereoscopicArcRotateCamera
  39315. */
  39316. getClassName(): string;
  39317. }
  39318. }
  39319. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39320. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39321. import { Scene } from "babylonjs/scene";
  39322. import { Vector3 } from "babylonjs/Maths/math";
  39323. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39324. /**
  39325. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39326. * @see http://doc.babylonjs.com/features/cameras
  39327. */
  39328. export class StereoscopicFreeCamera extends FreeCamera {
  39329. /**
  39330. * Creates a new StereoscopicFreeCamera
  39331. * @param name defines camera name
  39332. * @param position defines initial position
  39333. * @param interaxialDistance defines distance between each color axis
  39334. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39335. * @param scene defines the hosting scene
  39336. */
  39337. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39338. /**
  39339. * Gets camera class name
  39340. * @returns StereoscopicFreeCamera
  39341. */
  39342. getClassName(): string;
  39343. }
  39344. }
  39345. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39346. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39347. import { Scene } from "babylonjs/scene";
  39348. import { Vector3 } from "babylonjs/Maths/math";
  39349. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39350. /**
  39351. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39352. * @see http://doc.babylonjs.com/features/cameras
  39353. */
  39354. export class StereoscopicGamepadCamera extends GamepadCamera {
  39355. /**
  39356. * Creates a new StereoscopicGamepadCamera
  39357. * @param name defines camera name
  39358. * @param position defines initial position
  39359. * @param interaxialDistance defines distance between each color axis
  39360. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39361. * @param scene defines the hosting scene
  39362. */
  39363. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39364. /**
  39365. * Gets camera class name
  39366. * @returns StereoscopicGamepadCamera
  39367. */
  39368. getClassName(): string;
  39369. }
  39370. }
  39371. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39372. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39373. import { Scene } from "babylonjs/scene";
  39374. import { Vector3 } from "babylonjs/Maths/math";
  39375. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39376. /**
  39377. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39378. * @see http://doc.babylonjs.com/features/cameras
  39379. */
  39380. export class StereoscopicUniversalCamera extends UniversalCamera {
  39381. /**
  39382. * Creates a new StereoscopicUniversalCamera
  39383. * @param name defines camera name
  39384. * @param position defines initial position
  39385. * @param interaxialDistance defines distance between each color axis
  39386. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39387. * @param scene defines the hosting scene
  39388. */
  39389. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39390. /**
  39391. * Gets camera class name
  39392. * @returns StereoscopicUniversalCamera
  39393. */
  39394. getClassName(): string;
  39395. }
  39396. }
  39397. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39398. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39399. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39400. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39401. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39402. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39403. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39404. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39405. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39406. }
  39407. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39408. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39409. import { Scene } from "babylonjs/scene";
  39410. import { Vector3 } from "babylonjs/Maths/math";
  39411. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39412. /**
  39413. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39414. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39415. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39416. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39417. */
  39418. export class VirtualJoysticksCamera extends FreeCamera {
  39419. /**
  39420. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39421. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39422. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39423. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39424. * @param name Define the name of the camera in the scene
  39425. * @param position Define the start position of the camera in the scene
  39426. * @param scene Define the scene the camera belongs to
  39427. */
  39428. constructor(name: string, position: Vector3, scene: Scene);
  39429. /**
  39430. * Gets the current object class name.
  39431. * @return the class name
  39432. */
  39433. getClassName(): string;
  39434. }
  39435. }
  39436. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39437. import { Matrix } from "babylonjs/Maths/math";
  39438. /**
  39439. * This represents all the required metrics to create a VR camera.
  39440. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39441. */
  39442. export class VRCameraMetrics {
  39443. /**
  39444. * Define the horizontal resolution off the screen.
  39445. */
  39446. hResolution: number;
  39447. /**
  39448. * Define the vertical resolution off the screen.
  39449. */
  39450. vResolution: number;
  39451. /**
  39452. * Define the horizontal screen size.
  39453. */
  39454. hScreenSize: number;
  39455. /**
  39456. * Define the vertical screen size.
  39457. */
  39458. vScreenSize: number;
  39459. /**
  39460. * Define the vertical screen center position.
  39461. */
  39462. vScreenCenter: number;
  39463. /**
  39464. * Define the distance of the eyes to the screen.
  39465. */
  39466. eyeToScreenDistance: number;
  39467. /**
  39468. * Define the distance between both lenses
  39469. */
  39470. lensSeparationDistance: number;
  39471. /**
  39472. * Define the distance between both viewer's eyes.
  39473. */
  39474. interpupillaryDistance: number;
  39475. /**
  39476. * Define the distortion factor of the VR postprocess.
  39477. * Please, touch with care.
  39478. */
  39479. distortionK: number[];
  39480. /**
  39481. * Define the chromatic aberration correction factors for the VR post process.
  39482. */
  39483. chromaAbCorrection: number[];
  39484. /**
  39485. * Define the scale factor of the post process.
  39486. * The smaller the better but the slower.
  39487. */
  39488. postProcessScaleFactor: number;
  39489. /**
  39490. * Define an offset for the lens center.
  39491. */
  39492. lensCenterOffset: number;
  39493. /**
  39494. * Define if the current vr camera should compensate the distortion of the lense or not.
  39495. */
  39496. compensateDistortion: boolean;
  39497. /**
  39498. * Defines if multiview should be enabled when rendering (Default: false)
  39499. */
  39500. multiviewEnabled: boolean;
  39501. /**
  39502. * Gets the rendering aspect ratio based on the provided resolutions.
  39503. */
  39504. readonly aspectRatio: number;
  39505. /**
  39506. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39507. */
  39508. readonly aspectRatioFov: number;
  39509. /**
  39510. * @hidden
  39511. */
  39512. readonly leftHMatrix: Matrix;
  39513. /**
  39514. * @hidden
  39515. */
  39516. readonly rightHMatrix: Matrix;
  39517. /**
  39518. * @hidden
  39519. */
  39520. readonly leftPreViewMatrix: Matrix;
  39521. /**
  39522. * @hidden
  39523. */
  39524. readonly rightPreViewMatrix: Matrix;
  39525. /**
  39526. * Get the default VRMetrics based on the most generic setup.
  39527. * @returns the default vr metrics
  39528. */
  39529. static GetDefault(): VRCameraMetrics;
  39530. }
  39531. }
  39532. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39533. /** @hidden */
  39534. export var vrDistortionCorrectionPixelShader: {
  39535. name: string;
  39536. shader: string;
  39537. };
  39538. }
  39539. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39540. import { Camera } from "babylonjs/Cameras/camera";
  39541. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39542. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39543. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39544. /**
  39545. * VRDistortionCorrectionPostProcess used for mobile VR
  39546. */
  39547. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39548. private _isRightEye;
  39549. private _distortionFactors;
  39550. private _postProcessScaleFactor;
  39551. private _lensCenterOffset;
  39552. private _scaleIn;
  39553. private _scaleFactor;
  39554. private _lensCenter;
  39555. /**
  39556. * Initializes the VRDistortionCorrectionPostProcess
  39557. * @param name The name of the effect.
  39558. * @param camera The camera to apply the render pass to.
  39559. * @param isRightEye If this is for the right eye distortion
  39560. * @param vrMetrics All the required metrics for the VR camera
  39561. */
  39562. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39563. }
  39564. }
  39565. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39566. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39568. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39569. import { Scene } from "babylonjs/scene";
  39570. import { Vector3 } from "babylonjs/Maths/math";
  39571. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39572. import "babylonjs/Cameras/RigModes/vrRigMode";
  39573. /**
  39574. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39575. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39576. */
  39577. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39578. /**
  39579. * Creates a new VRDeviceOrientationArcRotateCamera
  39580. * @param name defines camera name
  39581. * @param alpha defines the camera rotation along the logitudinal axis
  39582. * @param beta defines the camera rotation along the latitudinal axis
  39583. * @param radius defines the camera distance from its target
  39584. * @param target defines the camera target
  39585. * @param scene defines the scene the camera belongs to
  39586. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39587. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39588. */
  39589. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39590. /**
  39591. * Gets camera class name
  39592. * @returns VRDeviceOrientationArcRotateCamera
  39593. */
  39594. getClassName(): string;
  39595. }
  39596. }
  39597. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39598. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39599. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39600. import { Scene } from "babylonjs/scene";
  39601. import { Vector3 } from "babylonjs/Maths/math";
  39602. import "babylonjs/Cameras/RigModes/vrRigMode";
  39603. /**
  39604. * Camera used to simulate VR rendering (based on FreeCamera)
  39605. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39606. */
  39607. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39608. /**
  39609. * Creates a new VRDeviceOrientationFreeCamera
  39610. * @param name defines camera name
  39611. * @param position defines the start position of the camera
  39612. * @param scene defines the scene the camera belongs to
  39613. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39614. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39615. */
  39616. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39617. /**
  39618. * Gets camera class name
  39619. * @returns VRDeviceOrientationFreeCamera
  39620. */
  39621. getClassName(): string;
  39622. }
  39623. }
  39624. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39625. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39626. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39627. import { Scene } from "babylonjs/scene";
  39628. import { Vector3 } from "babylonjs/Maths/math";
  39629. import "babylonjs/Gamepads/gamepadSceneComponent";
  39630. /**
  39631. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39632. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39633. */
  39634. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39635. /**
  39636. * Creates a new VRDeviceOrientationGamepadCamera
  39637. * @param name defines camera name
  39638. * @param position defines the start position of the camera
  39639. * @param scene defines the scene the camera belongs to
  39640. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39641. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39642. */
  39643. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39644. /**
  39645. * Gets camera class name
  39646. * @returns VRDeviceOrientationGamepadCamera
  39647. */
  39648. getClassName(): string;
  39649. }
  39650. }
  39651. declare module "babylonjs/Materials/pushMaterial" {
  39652. import { Nullable } from "babylonjs/types";
  39653. import { Scene } from "babylonjs/scene";
  39654. import { Matrix } from "babylonjs/Maths/math";
  39655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39656. import { Mesh } from "babylonjs/Meshes/mesh";
  39657. import { Material } from "babylonjs/Materials/material";
  39658. import { Effect } from "babylonjs/Materials/effect";
  39659. /**
  39660. * Base class of materials working in push mode in babylon JS
  39661. * @hidden
  39662. */
  39663. export class PushMaterial extends Material {
  39664. protected _activeEffect: Effect;
  39665. protected _normalMatrix: Matrix;
  39666. /**
  39667. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39668. * This means that the material can keep using a previous shader while a new one is being compiled.
  39669. * This is mostly used when shader parallel compilation is supported (true by default)
  39670. */
  39671. allowShaderHotSwapping: boolean;
  39672. constructor(name: string, scene: Scene);
  39673. getEffect(): Effect;
  39674. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39675. /**
  39676. * Binds the given world matrix to the active effect
  39677. *
  39678. * @param world the matrix to bind
  39679. */
  39680. bindOnlyWorldMatrix(world: Matrix): void;
  39681. /**
  39682. * Binds the given normal matrix to the active effect
  39683. *
  39684. * @param normalMatrix the matrix to bind
  39685. */
  39686. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39687. bind(world: Matrix, mesh?: Mesh): void;
  39688. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39689. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39690. }
  39691. }
  39692. declare module "babylonjs/Materials/materialFlags" {
  39693. /**
  39694. * This groups all the flags used to control the materials channel.
  39695. */
  39696. export class MaterialFlags {
  39697. private static _DiffuseTextureEnabled;
  39698. /**
  39699. * Are diffuse textures enabled in the application.
  39700. */
  39701. static DiffuseTextureEnabled: boolean;
  39702. private static _AmbientTextureEnabled;
  39703. /**
  39704. * Are ambient textures enabled in the application.
  39705. */
  39706. static AmbientTextureEnabled: boolean;
  39707. private static _OpacityTextureEnabled;
  39708. /**
  39709. * Are opacity textures enabled in the application.
  39710. */
  39711. static OpacityTextureEnabled: boolean;
  39712. private static _ReflectionTextureEnabled;
  39713. /**
  39714. * Are reflection textures enabled in the application.
  39715. */
  39716. static ReflectionTextureEnabled: boolean;
  39717. private static _EmissiveTextureEnabled;
  39718. /**
  39719. * Are emissive textures enabled in the application.
  39720. */
  39721. static EmissiveTextureEnabled: boolean;
  39722. private static _SpecularTextureEnabled;
  39723. /**
  39724. * Are specular textures enabled in the application.
  39725. */
  39726. static SpecularTextureEnabled: boolean;
  39727. private static _BumpTextureEnabled;
  39728. /**
  39729. * Are bump textures enabled in the application.
  39730. */
  39731. static BumpTextureEnabled: boolean;
  39732. private static _LightmapTextureEnabled;
  39733. /**
  39734. * Are lightmap textures enabled in the application.
  39735. */
  39736. static LightmapTextureEnabled: boolean;
  39737. private static _RefractionTextureEnabled;
  39738. /**
  39739. * Are refraction textures enabled in the application.
  39740. */
  39741. static RefractionTextureEnabled: boolean;
  39742. private static _ColorGradingTextureEnabled;
  39743. /**
  39744. * Are color grading textures enabled in the application.
  39745. */
  39746. static ColorGradingTextureEnabled: boolean;
  39747. private static _FresnelEnabled;
  39748. /**
  39749. * Are fresnels enabled in the application.
  39750. */
  39751. static FresnelEnabled: boolean;
  39752. private static _ClearCoatTextureEnabled;
  39753. /**
  39754. * Are clear coat textures enabled in the application.
  39755. */
  39756. static ClearCoatTextureEnabled: boolean;
  39757. private static _ClearCoatBumpTextureEnabled;
  39758. /**
  39759. * Are clear coat bump textures enabled in the application.
  39760. */
  39761. static ClearCoatBumpTextureEnabled: boolean;
  39762. private static _ClearCoatTintTextureEnabled;
  39763. /**
  39764. * Are clear coat tint textures enabled in the application.
  39765. */
  39766. static ClearCoatTintTextureEnabled: boolean;
  39767. private static _SheenTextureEnabled;
  39768. /**
  39769. * Are sheen textures enabled in the application.
  39770. */
  39771. static SheenTextureEnabled: boolean;
  39772. private static _AnisotropicTextureEnabled;
  39773. /**
  39774. * Are anisotropic textures enabled in the application.
  39775. */
  39776. static AnisotropicTextureEnabled: boolean;
  39777. private static _ThicknessTextureEnabled;
  39778. /**
  39779. * Are thickness textures enabled in the application.
  39780. */
  39781. static ThicknessTextureEnabled: boolean;
  39782. }
  39783. }
  39784. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39785. /** @hidden */
  39786. export var defaultFragmentDeclaration: {
  39787. name: string;
  39788. shader: string;
  39789. };
  39790. }
  39791. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39792. /** @hidden */
  39793. export var defaultUboDeclaration: {
  39794. name: string;
  39795. shader: string;
  39796. };
  39797. }
  39798. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39799. /** @hidden */
  39800. export var lightFragmentDeclaration: {
  39801. name: string;
  39802. shader: string;
  39803. };
  39804. }
  39805. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39806. /** @hidden */
  39807. export var lightUboDeclaration: {
  39808. name: string;
  39809. shader: string;
  39810. };
  39811. }
  39812. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39813. /** @hidden */
  39814. export var lightsFragmentFunctions: {
  39815. name: string;
  39816. shader: string;
  39817. };
  39818. }
  39819. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39820. /** @hidden */
  39821. export var shadowsFragmentFunctions: {
  39822. name: string;
  39823. shader: string;
  39824. };
  39825. }
  39826. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39827. /** @hidden */
  39828. export var fresnelFunction: {
  39829. name: string;
  39830. shader: string;
  39831. };
  39832. }
  39833. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39834. /** @hidden */
  39835. export var reflectionFunction: {
  39836. name: string;
  39837. shader: string;
  39838. };
  39839. }
  39840. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39841. /** @hidden */
  39842. export var bumpFragmentFunctions: {
  39843. name: string;
  39844. shader: string;
  39845. };
  39846. }
  39847. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39848. /** @hidden */
  39849. export var logDepthDeclaration: {
  39850. name: string;
  39851. shader: string;
  39852. };
  39853. }
  39854. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39855. /** @hidden */
  39856. export var bumpFragment: {
  39857. name: string;
  39858. shader: string;
  39859. };
  39860. }
  39861. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39862. /** @hidden */
  39863. export var depthPrePass: {
  39864. name: string;
  39865. shader: string;
  39866. };
  39867. }
  39868. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39869. /** @hidden */
  39870. export var lightFragment: {
  39871. name: string;
  39872. shader: string;
  39873. };
  39874. }
  39875. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39876. /** @hidden */
  39877. export var logDepthFragment: {
  39878. name: string;
  39879. shader: string;
  39880. };
  39881. }
  39882. declare module "babylonjs/Shaders/default.fragment" {
  39883. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39884. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39885. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39886. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39887. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39888. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39889. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39890. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39891. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39892. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39893. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39894. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39895. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39896. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39897. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39898. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39899. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39900. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39901. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39902. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39903. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39904. /** @hidden */
  39905. export var defaultPixelShader: {
  39906. name: string;
  39907. shader: string;
  39908. };
  39909. }
  39910. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39911. /** @hidden */
  39912. export var defaultVertexDeclaration: {
  39913. name: string;
  39914. shader: string;
  39915. };
  39916. }
  39917. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39918. /** @hidden */
  39919. export var bumpVertexDeclaration: {
  39920. name: string;
  39921. shader: string;
  39922. };
  39923. }
  39924. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39925. /** @hidden */
  39926. export var bumpVertex: {
  39927. name: string;
  39928. shader: string;
  39929. };
  39930. }
  39931. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39932. /** @hidden */
  39933. export var fogVertex: {
  39934. name: string;
  39935. shader: string;
  39936. };
  39937. }
  39938. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39939. /** @hidden */
  39940. export var shadowsVertex: {
  39941. name: string;
  39942. shader: string;
  39943. };
  39944. }
  39945. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39946. /** @hidden */
  39947. export var pointCloudVertex: {
  39948. name: string;
  39949. shader: string;
  39950. };
  39951. }
  39952. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39953. /** @hidden */
  39954. export var logDepthVertex: {
  39955. name: string;
  39956. shader: string;
  39957. };
  39958. }
  39959. declare module "babylonjs/Shaders/default.vertex" {
  39960. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39961. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39962. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39963. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39964. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39965. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39966. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39967. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39968. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39969. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39970. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39971. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39972. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39973. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39974. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39975. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39976. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39977. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39978. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39979. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39980. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39981. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39982. /** @hidden */
  39983. export var defaultVertexShader: {
  39984. name: string;
  39985. shader: string;
  39986. };
  39987. }
  39988. declare module "babylonjs/Materials/standardMaterial" {
  39989. import { SmartArray } from "babylonjs/Misc/smartArray";
  39990. import { IAnimatable } from "babylonjs/Misc/tools";
  39991. import { Nullable } from "babylonjs/types";
  39992. import { Scene } from "babylonjs/scene";
  39993. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39994. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39996. import { Mesh } from "babylonjs/Meshes/mesh";
  39997. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39998. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39999. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40000. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40001. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40003. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40004. import "babylonjs/Shaders/default.fragment";
  40005. import "babylonjs/Shaders/default.vertex";
  40006. /** @hidden */
  40007. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40008. MAINUV1: boolean;
  40009. MAINUV2: boolean;
  40010. DIFFUSE: boolean;
  40011. DIFFUSEDIRECTUV: number;
  40012. AMBIENT: boolean;
  40013. AMBIENTDIRECTUV: number;
  40014. OPACITY: boolean;
  40015. OPACITYDIRECTUV: number;
  40016. OPACITYRGB: boolean;
  40017. REFLECTION: boolean;
  40018. EMISSIVE: boolean;
  40019. EMISSIVEDIRECTUV: number;
  40020. SPECULAR: boolean;
  40021. SPECULARDIRECTUV: number;
  40022. BUMP: boolean;
  40023. BUMPDIRECTUV: number;
  40024. PARALLAX: boolean;
  40025. PARALLAXOCCLUSION: boolean;
  40026. SPECULAROVERALPHA: boolean;
  40027. CLIPPLANE: boolean;
  40028. CLIPPLANE2: boolean;
  40029. CLIPPLANE3: boolean;
  40030. CLIPPLANE4: boolean;
  40031. ALPHATEST: boolean;
  40032. DEPTHPREPASS: boolean;
  40033. ALPHAFROMDIFFUSE: boolean;
  40034. POINTSIZE: boolean;
  40035. FOG: boolean;
  40036. SPECULARTERM: boolean;
  40037. DIFFUSEFRESNEL: boolean;
  40038. OPACITYFRESNEL: boolean;
  40039. REFLECTIONFRESNEL: boolean;
  40040. REFRACTIONFRESNEL: boolean;
  40041. EMISSIVEFRESNEL: boolean;
  40042. FRESNEL: boolean;
  40043. NORMAL: boolean;
  40044. UV1: boolean;
  40045. UV2: boolean;
  40046. VERTEXCOLOR: boolean;
  40047. VERTEXALPHA: boolean;
  40048. NUM_BONE_INFLUENCERS: number;
  40049. BonesPerMesh: number;
  40050. BONETEXTURE: boolean;
  40051. INSTANCES: boolean;
  40052. GLOSSINESS: boolean;
  40053. ROUGHNESS: boolean;
  40054. EMISSIVEASILLUMINATION: boolean;
  40055. LINKEMISSIVEWITHDIFFUSE: boolean;
  40056. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40057. LIGHTMAP: boolean;
  40058. LIGHTMAPDIRECTUV: number;
  40059. OBJECTSPACE_NORMALMAP: boolean;
  40060. USELIGHTMAPASSHADOWMAP: boolean;
  40061. REFLECTIONMAP_3D: boolean;
  40062. REFLECTIONMAP_SPHERICAL: boolean;
  40063. REFLECTIONMAP_PLANAR: boolean;
  40064. REFLECTIONMAP_CUBIC: boolean;
  40065. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40066. REFLECTIONMAP_PROJECTION: boolean;
  40067. REFLECTIONMAP_SKYBOX: boolean;
  40068. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40069. REFLECTIONMAP_EXPLICIT: boolean;
  40070. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40071. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40072. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40073. INVERTCUBICMAP: boolean;
  40074. LOGARITHMICDEPTH: boolean;
  40075. REFRACTION: boolean;
  40076. REFRACTIONMAP_3D: boolean;
  40077. REFLECTIONOVERALPHA: boolean;
  40078. TWOSIDEDLIGHTING: boolean;
  40079. SHADOWFLOAT: boolean;
  40080. MORPHTARGETS: boolean;
  40081. MORPHTARGETS_NORMAL: boolean;
  40082. MORPHTARGETS_TANGENT: boolean;
  40083. NUM_MORPH_INFLUENCERS: number;
  40084. NONUNIFORMSCALING: boolean;
  40085. PREMULTIPLYALPHA: boolean;
  40086. IMAGEPROCESSING: boolean;
  40087. VIGNETTE: boolean;
  40088. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40089. VIGNETTEBLENDMODEOPAQUE: boolean;
  40090. TONEMAPPING: boolean;
  40091. TONEMAPPING_ACES: boolean;
  40092. CONTRAST: boolean;
  40093. COLORCURVES: boolean;
  40094. COLORGRADING: boolean;
  40095. COLORGRADING3D: boolean;
  40096. SAMPLER3DGREENDEPTH: boolean;
  40097. SAMPLER3DBGRMAP: boolean;
  40098. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40099. MULTIVIEW: boolean;
  40100. /**
  40101. * If the reflection texture on this material is in linear color space
  40102. * @hidden
  40103. */
  40104. IS_REFLECTION_LINEAR: boolean;
  40105. /**
  40106. * If the refraction texture on this material is in linear color space
  40107. * @hidden
  40108. */
  40109. IS_REFRACTION_LINEAR: boolean;
  40110. EXPOSURE: boolean;
  40111. constructor();
  40112. setReflectionMode(modeToEnable: string): void;
  40113. }
  40114. /**
  40115. * This is the default material used in Babylon. It is the best trade off between quality
  40116. * and performances.
  40117. * @see http://doc.babylonjs.com/babylon101/materials
  40118. */
  40119. export class StandardMaterial extends PushMaterial {
  40120. private _diffuseTexture;
  40121. /**
  40122. * The basic texture of the material as viewed under a light.
  40123. */
  40124. diffuseTexture: Nullable<BaseTexture>;
  40125. private _ambientTexture;
  40126. /**
  40127. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40128. */
  40129. ambientTexture: Nullable<BaseTexture>;
  40130. private _opacityTexture;
  40131. /**
  40132. * Define the transparency of the material from a texture.
  40133. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40134. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40135. */
  40136. opacityTexture: Nullable<BaseTexture>;
  40137. private _reflectionTexture;
  40138. /**
  40139. * Define the texture used to display the reflection.
  40140. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40141. */
  40142. reflectionTexture: Nullable<BaseTexture>;
  40143. private _emissiveTexture;
  40144. /**
  40145. * Define texture of the material as if self lit.
  40146. * This will be mixed in the final result even in the absence of light.
  40147. */
  40148. emissiveTexture: Nullable<BaseTexture>;
  40149. private _specularTexture;
  40150. /**
  40151. * Define how the color and intensity of the highlight given by the light in the material.
  40152. */
  40153. specularTexture: Nullable<BaseTexture>;
  40154. private _bumpTexture;
  40155. /**
  40156. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40157. * 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.
  40158. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40159. */
  40160. bumpTexture: Nullable<BaseTexture>;
  40161. private _lightmapTexture;
  40162. /**
  40163. * Complex lighting can be computationally expensive to compute at runtime.
  40164. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40165. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40166. */
  40167. lightmapTexture: Nullable<BaseTexture>;
  40168. private _refractionTexture;
  40169. /**
  40170. * Define the texture used to display the refraction.
  40171. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40172. */
  40173. refractionTexture: Nullable<BaseTexture>;
  40174. /**
  40175. * The color of the material lit by the environmental background lighting.
  40176. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40177. */
  40178. ambientColor: Color3;
  40179. /**
  40180. * The basic color of the material as viewed under a light.
  40181. */
  40182. diffuseColor: Color3;
  40183. /**
  40184. * Define how the color and intensity of the highlight given by the light in the material.
  40185. */
  40186. specularColor: Color3;
  40187. /**
  40188. * Define the color of the material as if self lit.
  40189. * This will be mixed in the final result even in the absence of light.
  40190. */
  40191. emissiveColor: Color3;
  40192. /**
  40193. * Defines how sharp are the highlights in the material.
  40194. * The bigger the value the sharper giving a more glossy feeling to the result.
  40195. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40196. */
  40197. specularPower: number;
  40198. private _useAlphaFromDiffuseTexture;
  40199. /**
  40200. * Does the transparency come from the diffuse texture alpha channel.
  40201. */
  40202. useAlphaFromDiffuseTexture: boolean;
  40203. private _useEmissiveAsIllumination;
  40204. /**
  40205. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40206. */
  40207. useEmissiveAsIllumination: boolean;
  40208. private _linkEmissiveWithDiffuse;
  40209. /**
  40210. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40211. * the emissive level when the final color is close to one.
  40212. */
  40213. linkEmissiveWithDiffuse: boolean;
  40214. private _useSpecularOverAlpha;
  40215. /**
  40216. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40217. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40218. */
  40219. useSpecularOverAlpha: boolean;
  40220. private _useReflectionOverAlpha;
  40221. /**
  40222. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40223. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40224. */
  40225. useReflectionOverAlpha: boolean;
  40226. private _disableLighting;
  40227. /**
  40228. * Does lights from the scene impacts this material.
  40229. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40230. */
  40231. disableLighting: boolean;
  40232. private _useObjectSpaceNormalMap;
  40233. /**
  40234. * Allows using an object space normal map (instead of tangent space).
  40235. */
  40236. useObjectSpaceNormalMap: boolean;
  40237. private _useParallax;
  40238. /**
  40239. * Is parallax enabled or not.
  40240. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40241. */
  40242. useParallax: boolean;
  40243. private _useParallaxOcclusion;
  40244. /**
  40245. * Is parallax occlusion enabled or not.
  40246. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40247. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40248. */
  40249. useParallaxOcclusion: boolean;
  40250. /**
  40251. * 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.
  40252. */
  40253. parallaxScaleBias: number;
  40254. private _roughness;
  40255. /**
  40256. * Helps to define how blurry the reflections should appears in the material.
  40257. */
  40258. roughness: number;
  40259. /**
  40260. * In case of refraction, define the value of the indice of refraction.
  40261. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40262. */
  40263. indexOfRefraction: number;
  40264. /**
  40265. * Invert the refraction texture alongside the y axis.
  40266. * It can be useful with procedural textures or probe for instance.
  40267. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40268. */
  40269. invertRefractionY: boolean;
  40270. /**
  40271. * Defines the alpha limits in alpha test mode.
  40272. */
  40273. alphaCutOff: number;
  40274. private _useLightmapAsShadowmap;
  40275. /**
  40276. * In case of light mapping, define whether the map contains light or shadow informations.
  40277. */
  40278. useLightmapAsShadowmap: boolean;
  40279. private _diffuseFresnelParameters;
  40280. /**
  40281. * Define the diffuse fresnel parameters of the material.
  40282. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40283. */
  40284. diffuseFresnelParameters: FresnelParameters;
  40285. private _opacityFresnelParameters;
  40286. /**
  40287. * Define the opacity fresnel parameters of the material.
  40288. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40289. */
  40290. opacityFresnelParameters: FresnelParameters;
  40291. private _reflectionFresnelParameters;
  40292. /**
  40293. * Define the reflection fresnel parameters of the material.
  40294. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40295. */
  40296. reflectionFresnelParameters: FresnelParameters;
  40297. private _refractionFresnelParameters;
  40298. /**
  40299. * Define the refraction fresnel parameters of the material.
  40300. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40301. */
  40302. refractionFresnelParameters: FresnelParameters;
  40303. private _emissiveFresnelParameters;
  40304. /**
  40305. * Define the emissive fresnel parameters of the material.
  40306. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40307. */
  40308. emissiveFresnelParameters: FresnelParameters;
  40309. private _useReflectionFresnelFromSpecular;
  40310. /**
  40311. * If true automatically deducts the fresnels values from the material specularity.
  40312. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40313. */
  40314. useReflectionFresnelFromSpecular: boolean;
  40315. private _useGlossinessFromSpecularMapAlpha;
  40316. /**
  40317. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40318. */
  40319. useGlossinessFromSpecularMapAlpha: boolean;
  40320. private _maxSimultaneousLights;
  40321. /**
  40322. * Defines the maximum number of lights that can be used in the material
  40323. */
  40324. maxSimultaneousLights: number;
  40325. private _invertNormalMapX;
  40326. /**
  40327. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40328. */
  40329. invertNormalMapX: boolean;
  40330. private _invertNormalMapY;
  40331. /**
  40332. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40333. */
  40334. invertNormalMapY: boolean;
  40335. private _twoSidedLighting;
  40336. /**
  40337. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40338. */
  40339. twoSidedLighting: boolean;
  40340. /**
  40341. * Default configuration related to image processing available in the standard Material.
  40342. */
  40343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40344. /**
  40345. * Gets the image processing configuration used either in this material.
  40346. */
  40347. /**
  40348. * Sets the Default image processing configuration used either in the this material.
  40349. *
  40350. * If sets to null, the scene one is in use.
  40351. */
  40352. imageProcessingConfiguration: ImageProcessingConfiguration;
  40353. /**
  40354. * Keep track of the image processing observer to allow dispose and replace.
  40355. */
  40356. private _imageProcessingObserver;
  40357. /**
  40358. * Attaches a new image processing configuration to the Standard Material.
  40359. * @param configuration
  40360. */
  40361. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40362. /**
  40363. * Gets wether the color curves effect is enabled.
  40364. */
  40365. /**
  40366. * Sets wether the color curves effect is enabled.
  40367. */
  40368. cameraColorCurvesEnabled: boolean;
  40369. /**
  40370. * Gets wether the color grading effect is enabled.
  40371. */
  40372. /**
  40373. * Gets wether the color grading effect is enabled.
  40374. */
  40375. cameraColorGradingEnabled: boolean;
  40376. /**
  40377. * Gets wether tonemapping is enabled or not.
  40378. */
  40379. /**
  40380. * Sets wether tonemapping is enabled or not
  40381. */
  40382. cameraToneMappingEnabled: boolean;
  40383. /**
  40384. * The camera exposure used on this material.
  40385. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40386. * This corresponds to a photographic exposure.
  40387. */
  40388. /**
  40389. * The camera exposure used on this material.
  40390. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40391. * This corresponds to a photographic exposure.
  40392. */
  40393. cameraExposure: number;
  40394. /**
  40395. * Gets The camera contrast used on this material.
  40396. */
  40397. /**
  40398. * Sets The camera contrast used on this material.
  40399. */
  40400. cameraContrast: number;
  40401. /**
  40402. * Gets the Color Grading 2D Lookup Texture.
  40403. */
  40404. /**
  40405. * Sets the Color Grading 2D Lookup Texture.
  40406. */
  40407. cameraColorGradingTexture: Nullable<BaseTexture>;
  40408. /**
  40409. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40410. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40411. * 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;
  40412. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40413. */
  40414. /**
  40415. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40416. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40417. * 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;
  40418. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40419. */
  40420. cameraColorCurves: Nullable<ColorCurves>;
  40421. /**
  40422. * Custom callback helping to override the default shader used in the material.
  40423. */
  40424. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40425. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40426. protected _worldViewProjectionMatrix: Matrix;
  40427. protected _globalAmbientColor: Color3;
  40428. protected _useLogarithmicDepth: boolean;
  40429. /**
  40430. * Instantiates a new standard material.
  40431. * This is the default material used in Babylon. It is the best trade off between quality
  40432. * and performances.
  40433. * @see http://doc.babylonjs.com/babylon101/materials
  40434. * @param name Define the name of the material in the scene
  40435. * @param scene Define the scene the material belong to
  40436. */
  40437. constructor(name: string, scene: Scene);
  40438. /**
  40439. * Gets a boolean indicating that current material needs to register RTT
  40440. */
  40441. readonly hasRenderTargetTextures: boolean;
  40442. /**
  40443. * Gets the current class name of the material e.g. "StandardMaterial"
  40444. * Mainly use in serialization.
  40445. * @returns the class name
  40446. */
  40447. getClassName(): string;
  40448. /**
  40449. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40450. * You can try switching to logarithmic depth.
  40451. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40452. */
  40453. useLogarithmicDepth: boolean;
  40454. /**
  40455. * Specifies if the material will require alpha blending
  40456. * @returns a boolean specifying if alpha blending is needed
  40457. */
  40458. needAlphaBlending(): boolean;
  40459. /**
  40460. * Specifies if this material should be rendered in alpha test mode
  40461. * @returns a boolean specifying if an alpha test is needed.
  40462. */
  40463. needAlphaTesting(): boolean;
  40464. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40465. /**
  40466. * Get the texture used for alpha test purpose.
  40467. * @returns the diffuse texture in case of the standard material.
  40468. */
  40469. getAlphaTestTexture(): Nullable<BaseTexture>;
  40470. /**
  40471. * Get if the submesh is ready to be used and all its information available.
  40472. * Child classes can use it to update shaders
  40473. * @param mesh defines the mesh to check
  40474. * @param subMesh defines which submesh to check
  40475. * @param useInstances specifies that instances should be used
  40476. * @returns a boolean indicating that the submesh is ready or not
  40477. */
  40478. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40479. /**
  40480. * Builds the material UBO layouts.
  40481. * Used internally during the effect preparation.
  40482. */
  40483. buildUniformLayout(): void;
  40484. /**
  40485. * Unbinds the material from the mesh
  40486. */
  40487. unbind(): void;
  40488. /**
  40489. * Binds the submesh to this material by preparing the effect and shader to draw
  40490. * @param world defines the world transformation matrix
  40491. * @param mesh defines the mesh containing the submesh
  40492. * @param subMesh defines the submesh to bind the material to
  40493. */
  40494. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40495. /**
  40496. * Get the list of animatables in the material.
  40497. * @returns the list of animatables object used in the material
  40498. */
  40499. getAnimatables(): IAnimatable[];
  40500. /**
  40501. * Gets the active textures from the material
  40502. * @returns an array of textures
  40503. */
  40504. getActiveTextures(): BaseTexture[];
  40505. /**
  40506. * Specifies if the material uses a texture
  40507. * @param texture defines the texture to check against the material
  40508. * @returns a boolean specifying if the material uses the texture
  40509. */
  40510. hasTexture(texture: BaseTexture): boolean;
  40511. /**
  40512. * Disposes the material
  40513. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40514. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40515. */
  40516. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40517. /**
  40518. * Makes a duplicate of the material, and gives it a new name
  40519. * @param name defines the new name for the duplicated material
  40520. * @returns the cloned material
  40521. */
  40522. clone(name: string): StandardMaterial;
  40523. /**
  40524. * Serializes this material in a JSON representation
  40525. * @returns the serialized material object
  40526. */
  40527. serialize(): any;
  40528. /**
  40529. * Creates a standard material from parsed material data
  40530. * @param source defines the JSON representation of the material
  40531. * @param scene defines the hosting scene
  40532. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40533. * @returns a new standard material
  40534. */
  40535. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40536. /**
  40537. * Are diffuse textures enabled in the application.
  40538. */
  40539. static DiffuseTextureEnabled: boolean;
  40540. /**
  40541. * Are ambient textures enabled in the application.
  40542. */
  40543. static AmbientTextureEnabled: boolean;
  40544. /**
  40545. * Are opacity textures enabled in the application.
  40546. */
  40547. static OpacityTextureEnabled: boolean;
  40548. /**
  40549. * Are reflection textures enabled in the application.
  40550. */
  40551. static ReflectionTextureEnabled: boolean;
  40552. /**
  40553. * Are emissive textures enabled in the application.
  40554. */
  40555. static EmissiveTextureEnabled: boolean;
  40556. /**
  40557. * Are specular textures enabled in the application.
  40558. */
  40559. static SpecularTextureEnabled: boolean;
  40560. /**
  40561. * Are bump textures enabled in the application.
  40562. */
  40563. static BumpTextureEnabled: boolean;
  40564. /**
  40565. * Are lightmap textures enabled in the application.
  40566. */
  40567. static LightmapTextureEnabled: boolean;
  40568. /**
  40569. * Are refraction textures enabled in the application.
  40570. */
  40571. static RefractionTextureEnabled: boolean;
  40572. /**
  40573. * Are color grading textures enabled in the application.
  40574. */
  40575. static ColorGradingTextureEnabled: boolean;
  40576. /**
  40577. * Are fresnels enabled in the application.
  40578. */
  40579. static FresnelEnabled: boolean;
  40580. }
  40581. }
  40582. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40583. import { Scene } from "babylonjs/scene";
  40584. import { Texture } from "babylonjs/Materials/Textures/texture";
  40585. /**
  40586. * A class extending Texture allowing drawing on a texture
  40587. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40588. */
  40589. export class DynamicTexture extends Texture {
  40590. private _generateMipMaps;
  40591. private _canvas;
  40592. private _context;
  40593. private _engine;
  40594. /**
  40595. * Creates a DynamicTexture
  40596. * @param name defines the name of the texture
  40597. * @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
  40598. * @param scene defines the scene where you want the texture
  40599. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40600. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40601. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40602. */
  40603. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40604. /**
  40605. * Get the current class name of the texture useful for serialization or dynamic coding.
  40606. * @returns "DynamicTexture"
  40607. */
  40608. getClassName(): string;
  40609. /**
  40610. * Gets the current state of canRescale
  40611. */
  40612. readonly canRescale: boolean;
  40613. private _recreate;
  40614. /**
  40615. * Scales the texture
  40616. * @param ratio the scale factor to apply to both width and height
  40617. */
  40618. scale(ratio: number): void;
  40619. /**
  40620. * Resizes the texture
  40621. * @param width the new width
  40622. * @param height the new height
  40623. */
  40624. scaleTo(width: number, height: number): void;
  40625. /**
  40626. * Gets the context of the canvas used by the texture
  40627. * @returns the canvas context of the dynamic texture
  40628. */
  40629. getContext(): CanvasRenderingContext2D;
  40630. /**
  40631. * Clears the texture
  40632. */
  40633. clear(): void;
  40634. /**
  40635. * Updates the texture
  40636. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40637. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40638. */
  40639. update(invertY?: boolean, premulAlpha?: boolean): void;
  40640. /**
  40641. * Draws text onto the texture
  40642. * @param text defines the text to be drawn
  40643. * @param x defines the placement of the text from the left
  40644. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40645. * @param font defines the font to be used with font-style, font-size, font-name
  40646. * @param color defines the color used for the text
  40647. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40648. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40649. * @param update defines whether texture is immediately update (default is true)
  40650. */
  40651. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40652. /**
  40653. * Clones the texture
  40654. * @returns the clone of the texture.
  40655. */
  40656. clone(): DynamicTexture;
  40657. /**
  40658. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40659. * @returns a serialized dynamic texture object
  40660. */
  40661. serialize(): any;
  40662. /** @hidden */
  40663. _rebuild(): void;
  40664. }
  40665. }
  40666. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40667. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40668. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40669. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40670. /** @hidden */
  40671. export var imageProcessingPixelShader: {
  40672. name: string;
  40673. shader: string;
  40674. };
  40675. }
  40676. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40677. import { Nullable } from "babylonjs/types";
  40678. import { Color4 } from "babylonjs/Maths/math";
  40679. import { Camera } from "babylonjs/Cameras/camera";
  40680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40681. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40682. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40683. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40684. import { Engine } from "babylonjs/Engines/engine";
  40685. import "babylonjs/Shaders/imageProcessing.fragment";
  40686. import "babylonjs/Shaders/postprocess.vertex";
  40687. /**
  40688. * ImageProcessingPostProcess
  40689. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40690. */
  40691. export class ImageProcessingPostProcess extends PostProcess {
  40692. /**
  40693. * Default configuration related to image processing available in the PBR Material.
  40694. */
  40695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40696. /**
  40697. * Gets the image processing configuration used either in this material.
  40698. */
  40699. /**
  40700. * Sets the Default image processing configuration used either in the this material.
  40701. *
  40702. * If sets to null, the scene one is in use.
  40703. */
  40704. imageProcessingConfiguration: ImageProcessingConfiguration;
  40705. /**
  40706. * Keep track of the image processing observer to allow dispose and replace.
  40707. */
  40708. private _imageProcessingObserver;
  40709. /**
  40710. * Attaches a new image processing configuration to the PBR Material.
  40711. * @param configuration
  40712. */
  40713. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40714. /**
  40715. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40716. */
  40717. /**
  40718. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40719. */
  40720. colorCurves: Nullable<ColorCurves>;
  40721. /**
  40722. * Gets wether the color curves effect is enabled.
  40723. */
  40724. /**
  40725. * Sets wether the color curves effect is enabled.
  40726. */
  40727. colorCurvesEnabled: boolean;
  40728. /**
  40729. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40730. */
  40731. /**
  40732. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40733. */
  40734. colorGradingTexture: Nullable<BaseTexture>;
  40735. /**
  40736. * Gets wether the color grading effect is enabled.
  40737. */
  40738. /**
  40739. * Gets wether the color grading effect is enabled.
  40740. */
  40741. colorGradingEnabled: boolean;
  40742. /**
  40743. * Gets exposure used in the effect.
  40744. */
  40745. /**
  40746. * Sets exposure used in the effect.
  40747. */
  40748. exposure: number;
  40749. /**
  40750. * Gets wether tonemapping is enabled or not.
  40751. */
  40752. /**
  40753. * Sets wether tonemapping is enabled or not
  40754. */
  40755. toneMappingEnabled: boolean;
  40756. /**
  40757. * Gets the type of tone mapping effect.
  40758. */
  40759. /**
  40760. * Sets the type of tone mapping effect.
  40761. */
  40762. toneMappingType: number;
  40763. /**
  40764. * Gets contrast used in the effect.
  40765. */
  40766. /**
  40767. * Sets contrast used in the effect.
  40768. */
  40769. contrast: number;
  40770. /**
  40771. * Gets Vignette stretch size.
  40772. */
  40773. /**
  40774. * Sets Vignette stretch size.
  40775. */
  40776. vignetteStretch: number;
  40777. /**
  40778. * Gets Vignette centre X Offset.
  40779. */
  40780. /**
  40781. * Sets Vignette centre X Offset.
  40782. */
  40783. vignetteCentreX: number;
  40784. /**
  40785. * Gets Vignette centre Y Offset.
  40786. */
  40787. /**
  40788. * Sets Vignette centre Y Offset.
  40789. */
  40790. vignetteCentreY: number;
  40791. /**
  40792. * Gets Vignette weight or intensity of the vignette effect.
  40793. */
  40794. /**
  40795. * Sets Vignette weight or intensity of the vignette effect.
  40796. */
  40797. vignetteWeight: number;
  40798. /**
  40799. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40800. * if vignetteEnabled is set to true.
  40801. */
  40802. /**
  40803. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40804. * if vignetteEnabled is set to true.
  40805. */
  40806. vignetteColor: Color4;
  40807. /**
  40808. * Gets Camera field of view used by the Vignette effect.
  40809. */
  40810. /**
  40811. * Sets Camera field of view used by the Vignette effect.
  40812. */
  40813. vignetteCameraFov: number;
  40814. /**
  40815. * Gets the vignette blend mode allowing different kind of effect.
  40816. */
  40817. /**
  40818. * Sets the vignette blend mode allowing different kind of effect.
  40819. */
  40820. vignetteBlendMode: number;
  40821. /**
  40822. * Gets wether the vignette effect is enabled.
  40823. */
  40824. /**
  40825. * Sets wether the vignette effect is enabled.
  40826. */
  40827. vignetteEnabled: boolean;
  40828. private _fromLinearSpace;
  40829. /**
  40830. * Gets wether the input of the processing is in Gamma or Linear Space.
  40831. */
  40832. /**
  40833. * Sets wether the input of the processing is in Gamma or Linear Space.
  40834. */
  40835. fromLinearSpace: boolean;
  40836. /**
  40837. * Defines cache preventing GC.
  40838. */
  40839. private _defines;
  40840. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40841. /**
  40842. * "ImageProcessingPostProcess"
  40843. * @returns "ImageProcessingPostProcess"
  40844. */
  40845. getClassName(): string;
  40846. protected _updateParameters(): void;
  40847. dispose(camera?: Camera): void;
  40848. }
  40849. }
  40850. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40851. import { Scene } from "babylonjs/scene";
  40852. import { Color3 } from "babylonjs/Maths/math";
  40853. import { Mesh } from "babylonjs/Meshes/mesh";
  40854. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40855. import { Nullable } from "babylonjs/types";
  40856. /**
  40857. * Class containing static functions to help procedurally build meshes
  40858. */
  40859. export class GroundBuilder {
  40860. /**
  40861. * Creates a ground mesh
  40862. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40863. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40865. * @param name defines the name of the mesh
  40866. * @param options defines the options used to create the mesh
  40867. * @param scene defines the hosting scene
  40868. * @returns the ground mesh
  40869. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40870. */
  40871. static CreateGround(name: string, options: {
  40872. width?: number;
  40873. height?: number;
  40874. subdivisions?: number;
  40875. subdivisionsX?: number;
  40876. subdivisionsY?: number;
  40877. updatable?: boolean;
  40878. }, scene: any): Mesh;
  40879. /**
  40880. * Creates a tiled ground mesh
  40881. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40882. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40883. * * 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
  40884. * * 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
  40885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40886. * @param name defines the name of the mesh
  40887. * @param options defines the options used to create the mesh
  40888. * @param scene defines the hosting scene
  40889. * @returns the tiled ground mesh
  40890. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40891. */
  40892. static CreateTiledGround(name: string, options: {
  40893. xmin: number;
  40894. zmin: number;
  40895. xmax: number;
  40896. zmax: number;
  40897. subdivisions?: {
  40898. w: number;
  40899. h: number;
  40900. };
  40901. precision?: {
  40902. w: number;
  40903. h: number;
  40904. };
  40905. updatable?: boolean;
  40906. }, scene?: Nullable<Scene>): Mesh;
  40907. /**
  40908. * Creates a ground mesh from a height map
  40909. * * The parameter `url` sets the URL of the height map image resource.
  40910. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40911. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40912. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40913. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40914. * * 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.
  40915. * * 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).
  40916. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40918. * @param name defines the name of the mesh
  40919. * @param url defines the url to the height map
  40920. * @param options defines the options used to create the mesh
  40921. * @param scene defines the hosting scene
  40922. * @returns the ground mesh
  40923. * @see https://doc.babylonjs.com/babylon101/height_map
  40924. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40925. */
  40926. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40927. width?: number;
  40928. height?: number;
  40929. subdivisions?: number;
  40930. minHeight?: number;
  40931. maxHeight?: number;
  40932. colorFilter?: Color3;
  40933. alphaFilter?: number;
  40934. updatable?: boolean;
  40935. onReady?: (mesh: GroundMesh) => void;
  40936. }, scene?: Nullable<Scene>): GroundMesh;
  40937. }
  40938. }
  40939. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40940. import { Vector4 } from "babylonjs/Maths/math";
  40941. import { Mesh } from "babylonjs/Meshes/mesh";
  40942. /**
  40943. * Class containing static functions to help procedurally build meshes
  40944. */
  40945. export class TorusBuilder {
  40946. /**
  40947. * Creates a torus mesh
  40948. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40949. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40950. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40954. * @param name defines the name of the mesh
  40955. * @param options defines the options used to create the mesh
  40956. * @param scene defines the hosting scene
  40957. * @returns the torus mesh
  40958. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40959. */
  40960. static CreateTorus(name: string, options: {
  40961. diameter?: number;
  40962. thickness?: number;
  40963. tessellation?: number;
  40964. updatable?: boolean;
  40965. sideOrientation?: number;
  40966. frontUVs?: Vector4;
  40967. backUVs?: Vector4;
  40968. }, scene: any): Mesh;
  40969. }
  40970. }
  40971. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40972. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40973. import { Mesh } from "babylonjs/Meshes/mesh";
  40974. /**
  40975. * Class containing static functions to help procedurally build meshes
  40976. */
  40977. export class CylinderBuilder {
  40978. /**
  40979. * Creates a cylinder or a cone mesh
  40980. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40981. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40982. * * 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.
  40983. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40984. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40985. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40986. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40987. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40988. * * 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).
  40989. * * 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
  40990. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40991. * * 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
  40992. * * 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.
  40993. * * If `enclose` is false, a ring surface is one element.
  40994. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40995. * * 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
  40996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40999. * @param name defines the name of the mesh
  41000. * @param options defines the options used to create the mesh
  41001. * @param scene defines the hosting scene
  41002. * @returns the cylinder mesh
  41003. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41004. */
  41005. static CreateCylinder(name: string, options: {
  41006. height?: number;
  41007. diameterTop?: number;
  41008. diameterBottom?: number;
  41009. diameter?: number;
  41010. tessellation?: number;
  41011. subdivisions?: number;
  41012. arc?: number;
  41013. faceColors?: Color4[];
  41014. faceUV?: Vector4[];
  41015. updatable?: boolean;
  41016. hasRings?: boolean;
  41017. enclose?: boolean;
  41018. sideOrientation?: number;
  41019. frontUVs?: Vector4;
  41020. backUVs?: Vector4;
  41021. }, scene: any): Mesh;
  41022. }
  41023. }
  41024. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41025. import { Observable } from "babylonjs/Misc/observable";
  41026. import { Nullable } from "babylonjs/types";
  41027. import { Camera } from "babylonjs/Cameras/camera";
  41028. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41029. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41030. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41031. import { Scene } from "babylonjs/scene";
  41032. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41033. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41035. import { Mesh } from "babylonjs/Meshes/mesh";
  41036. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41037. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41038. import "babylonjs/Meshes/Builders/groundBuilder";
  41039. import "babylonjs/Meshes/Builders/torusBuilder";
  41040. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41041. import "babylonjs/Gamepads/gamepadSceneComponent";
  41042. import "babylonjs/Animations/animatable";
  41043. /**
  41044. * Options to modify the vr teleportation behavior.
  41045. */
  41046. export interface VRTeleportationOptions {
  41047. /**
  41048. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41049. */
  41050. floorMeshName?: string;
  41051. /**
  41052. * A list of meshes to be used as the teleportation floor. (default: empty)
  41053. */
  41054. floorMeshes?: Mesh[];
  41055. }
  41056. /**
  41057. * Options to modify the vr experience helper's behavior.
  41058. */
  41059. export interface VRExperienceHelperOptions extends WebVROptions {
  41060. /**
  41061. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41062. */
  41063. createDeviceOrientationCamera?: boolean;
  41064. /**
  41065. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41066. */
  41067. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41068. /**
  41069. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41070. */
  41071. laserToggle?: boolean;
  41072. /**
  41073. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41074. */
  41075. floorMeshes?: Mesh[];
  41076. /**
  41077. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41078. */
  41079. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41080. }
  41081. /**
  41082. * Event containing information after VR has been entered
  41083. */
  41084. export class OnAfterEnteringVRObservableEvent {
  41085. /**
  41086. * If entering vr was successful
  41087. */
  41088. success: boolean;
  41089. }
  41090. /**
  41091. * Helps to quickly add VR support to an existing scene.
  41092. * See http://doc.babylonjs.com/how_to/webvr_helper
  41093. */
  41094. export class VRExperienceHelper {
  41095. /** Options to modify the vr experience helper's behavior. */
  41096. webVROptions: VRExperienceHelperOptions;
  41097. private _scene;
  41098. private _position;
  41099. private _btnVR;
  41100. private _btnVRDisplayed;
  41101. private _webVRsupported;
  41102. private _webVRready;
  41103. private _webVRrequesting;
  41104. private _webVRpresenting;
  41105. private _hasEnteredVR;
  41106. private _fullscreenVRpresenting;
  41107. private _canvas;
  41108. private _webVRCamera;
  41109. private _vrDeviceOrientationCamera;
  41110. private _deviceOrientationCamera;
  41111. private _existingCamera;
  41112. private _onKeyDown;
  41113. private _onVrDisplayPresentChange;
  41114. private _onVRDisplayChanged;
  41115. private _onVRRequestPresentStart;
  41116. private _onVRRequestPresentComplete;
  41117. /**
  41118. * Observable raised right before entering VR.
  41119. */
  41120. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41121. /**
  41122. * Observable raised when entering VR has completed.
  41123. */
  41124. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41125. /**
  41126. * Observable raised when exiting VR.
  41127. */
  41128. onExitingVRObservable: Observable<VRExperienceHelper>;
  41129. /**
  41130. * Observable raised when controller mesh is loaded.
  41131. */
  41132. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41133. /** Return this.onEnteringVRObservable
  41134. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41135. */
  41136. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41137. /** Return this.onExitingVRObservable
  41138. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41139. */
  41140. readonly onExitingVR: Observable<VRExperienceHelper>;
  41141. /** Return this.onControllerMeshLoadedObservable
  41142. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41143. */
  41144. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41145. private _rayLength;
  41146. private _useCustomVRButton;
  41147. private _teleportationRequested;
  41148. private _teleportActive;
  41149. private _floorMeshName;
  41150. private _floorMeshesCollection;
  41151. private _rotationAllowed;
  41152. private _teleportBackwardsVector;
  41153. private _teleportationTarget;
  41154. private _isDefaultTeleportationTarget;
  41155. private _postProcessMove;
  41156. private _teleportationFillColor;
  41157. private _teleportationBorderColor;
  41158. private _rotationAngle;
  41159. private _haloCenter;
  41160. private _cameraGazer;
  41161. private _padSensibilityUp;
  41162. private _padSensibilityDown;
  41163. private _leftController;
  41164. private _rightController;
  41165. /**
  41166. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41167. */
  41168. onNewMeshSelected: Observable<AbstractMesh>;
  41169. /**
  41170. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41171. */
  41172. onNewMeshPicked: Observable<PickingInfo>;
  41173. private _circleEase;
  41174. /**
  41175. * Observable raised before camera teleportation
  41176. */
  41177. onBeforeCameraTeleport: Observable<Vector3>;
  41178. /**
  41179. * Observable raised after camera teleportation
  41180. */
  41181. onAfterCameraTeleport: Observable<Vector3>;
  41182. /**
  41183. * Observable raised when current selected mesh gets unselected
  41184. */
  41185. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41186. private _raySelectionPredicate;
  41187. /**
  41188. * To be optionaly changed by user to define custom ray selection
  41189. */
  41190. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41191. /**
  41192. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41193. */
  41194. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41195. /**
  41196. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41197. */
  41198. teleportationEnabled: boolean;
  41199. private _defaultHeight;
  41200. private _teleportationInitialized;
  41201. private _interactionsEnabled;
  41202. private _interactionsRequested;
  41203. private _displayGaze;
  41204. private _displayLaserPointer;
  41205. /**
  41206. * The mesh used to display where the user is going to teleport.
  41207. */
  41208. /**
  41209. * Sets the mesh to be used to display where the user is going to teleport.
  41210. */
  41211. teleportationTarget: Mesh;
  41212. /**
  41213. * 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
  41214. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41215. * See http://doc.babylonjs.com/resources/baking_transformations
  41216. */
  41217. gazeTrackerMesh: Mesh;
  41218. /**
  41219. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41220. */
  41221. updateGazeTrackerScale: boolean;
  41222. /**
  41223. * If the gaze trackers color should be updated when selecting meshes
  41224. */
  41225. updateGazeTrackerColor: boolean;
  41226. /**
  41227. * The gaze tracking mesh corresponding to the left controller
  41228. */
  41229. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41230. /**
  41231. * The gaze tracking mesh corresponding to the right controller
  41232. */
  41233. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41234. /**
  41235. * If the ray of the gaze should be displayed.
  41236. */
  41237. /**
  41238. * Sets if the ray of the gaze should be displayed.
  41239. */
  41240. displayGaze: boolean;
  41241. /**
  41242. * If the ray of the LaserPointer should be displayed.
  41243. */
  41244. /**
  41245. * Sets if the ray of the LaserPointer should be displayed.
  41246. */
  41247. displayLaserPointer: boolean;
  41248. /**
  41249. * The deviceOrientationCamera used as the camera when not in VR.
  41250. */
  41251. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41252. /**
  41253. * Based on the current WebVR support, returns the current VR camera used.
  41254. */
  41255. readonly currentVRCamera: Nullable<Camera>;
  41256. /**
  41257. * The webVRCamera which is used when in VR.
  41258. */
  41259. readonly webVRCamera: WebVRFreeCamera;
  41260. /**
  41261. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41262. */
  41263. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41264. private readonly _teleportationRequestInitiated;
  41265. /**
  41266. * Defines wether or not Pointer lock should be requested when switching to
  41267. * full screen.
  41268. */
  41269. requestPointerLockOnFullScreen: boolean;
  41270. /**
  41271. * Instantiates a VRExperienceHelper.
  41272. * Helps to quickly add VR support to an existing scene.
  41273. * @param scene The scene the VRExperienceHelper belongs to.
  41274. * @param webVROptions Options to modify the vr experience helper's behavior.
  41275. */
  41276. constructor(scene: Scene,
  41277. /** Options to modify the vr experience helper's behavior. */
  41278. webVROptions?: VRExperienceHelperOptions);
  41279. private _onDefaultMeshLoaded;
  41280. private _onResize;
  41281. private _onFullscreenChange;
  41282. /**
  41283. * Gets a value indicating if we are currently in VR mode.
  41284. */
  41285. readonly isInVRMode: boolean;
  41286. private onVrDisplayPresentChange;
  41287. private onVRDisplayChanged;
  41288. private moveButtonToBottomRight;
  41289. private displayVRButton;
  41290. private updateButtonVisibility;
  41291. private _cachedAngularSensibility;
  41292. /**
  41293. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41294. * Otherwise, will use the fullscreen API.
  41295. */
  41296. enterVR(): void;
  41297. /**
  41298. * Attempt to exit VR, or fullscreen.
  41299. */
  41300. exitVR(): void;
  41301. /**
  41302. * The position of the vr experience helper.
  41303. */
  41304. /**
  41305. * Sets the position of the vr experience helper.
  41306. */
  41307. position: Vector3;
  41308. /**
  41309. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41310. */
  41311. enableInteractions(): void;
  41312. private readonly _noControllerIsActive;
  41313. private beforeRender;
  41314. private _isTeleportationFloor;
  41315. /**
  41316. * Adds a floor mesh to be used for teleportation.
  41317. * @param floorMesh the mesh to be used for teleportation.
  41318. */
  41319. addFloorMesh(floorMesh: Mesh): void;
  41320. /**
  41321. * Removes a floor mesh from being used for teleportation.
  41322. * @param floorMesh the mesh to be removed.
  41323. */
  41324. removeFloorMesh(floorMesh: Mesh): void;
  41325. /**
  41326. * Enables interactions and teleportation using the VR controllers and gaze.
  41327. * @param vrTeleportationOptions options to modify teleportation behavior.
  41328. */
  41329. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41330. private _onNewGamepadConnected;
  41331. private _tryEnableInteractionOnController;
  41332. private _onNewGamepadDisconnected;
  41333. private _enableInteractionOnController;
  41334. private _checkTeleportWithRay;
  41335. private _checkRotate;
  41336. private _checkTeleportBackwards;
  41337. private _enableTeleportationOnController;
  41338. private _createTeleportationCircles;
  41339. private _displayTeleportationTarget;
  41340. private _hideTeleportationTarget;
  41341. private _rotateCamera;
  41342. private _moveTeleportationSelectorTo;
  41343. private _workingVector;
  41344. private _workingQuaternion;
  41345. private _workingMatrix;
  41346. /**
  41347. * Teleports the users feet to the desired location
  41348. * @param location The location where the user's feet should be placed
  41349. */
  41350. teleportCamera(location: Vector3): void;
  41351. private _convertNormalToDirectionOfRay;
  41352. private _castRayAndSelectObject;
  41353. private _notifySelectedMeshUnselected;
  41354. /**
  41355. * Sets the color of the laser ray from the vr controllers.
  41356. * @param color new color for the ray.
  41357. */
  41358. changeLaserColor(color: Color3): void;
  41359. /**
  41360. * Sets the color of the ray from the vr headsets gaze.
  41361. * @param color new color for the ray.
  41362. */
  41363. changeGazeColor(color: Color3): void;
  41364. /**
  41365. * Exits VR and disposes of the vr experience helper
  41366. */
  41367. dispose(): void;
  41368. /**
  41369. * Gets the name of the VRExperienceHelper class
  41370. * @returns "VRExperienceHelper"
  41371. */
  41372. getClassName(): string;
  41373. }
  41374. }
  41375. declare module "babylonjs/Cameras/VR/index" {
  41376. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41377. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41378. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41379. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41380. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41381. export * from "babylonjs/Cameras/VR/webVRCamera";
  41382. }
  41383. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41384. import { Observable } from "babylonjs/Misc/observable";
  41385. import { Nullable } from "babylonjs/types";
  41386. import { IDisposable, Scene } from "babylonjs/scene";
  41387. import { Vector3 } from "babylonjs/Maths/math";
  41388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41389. import { Ray } from "babylonjs/Culling/ray";
  41390. /**
  41391. * Manages an XRSession
  41392. * @see https://doc.babylonjs.com/how_to/webxr
  41393. */
  41394. export class WebXRSessionManager implements IDisposable {
  41395. private scene;
  41396. /**
  41397. * Fires every time a new xrFrame arrives which can be used to update the camera
  41398. */
  41399. onXRFrameObservable: Observable<any>;
  41400. /**
  41401. * Fires when the xr session is ended either by the device or manually done
  41402. */
  41403. onXRSessionEnded: Observable<any>;
  41404. /** @hidden */
  41405. _xrSession: XRSession;
  41406. /** @hidden */
  41407. _frameOfReference: XRFrameOfReference;
  41408. /** @hidden */
  41409. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41410. /** @hidden */
  41411. _currentXRFrame: Nullable<XRFrame>;
  41412. private _xrNavigator;
  41413. private _xrDevice;
  41414. private _tmpMatrix;
  41415. /**
  41416. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41417. * @param scene The scene which the session should be created for
  41418. */
  41419. constructor(scene: Scene);
  41420. /**
  41421. * Initializes the manager
  41422. * After initialization enterXR can be called to start an XR session
  41423. * @returns Promise which resolves after it is initialized
  41424. */
  41425. initializeAsync(): Promise<void>;
  41426. /**
  41427. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41428. * @param sessionCreationOptions xr options to create the session with
  41429. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41430. * @returns Promise which resolves after it enters XR
  41431. */
  41432. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41433. /**
  41434. * Stops the xrSession and restores the renderloop
  41435. * @returns Promise which resolves after it exits XR
  41436. */
  41437. exitXRAsync(): Promise<void>;
  41438. /**
  41439. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41440. * @param ray ray to cast into the environment
  41441. * @returns Promise which resolves with a collision point in the environment if it exists
  41442. */
  41443. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41444. /**
  41445. * Checks if a session would be supported for the creation options specified
  41446. * @param options creation options to check if they are supported
  41447. * @returns true if supported
  41448. */
  41449. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41450. /**
  41451. * @hidden
  41452. * Converts the render layer of xrSession to a render target
  41453. * @param session session to create render target for
  41454. * @param scene scene the new render target should be created for
  41455. */
  41456. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41457. /**
  41458. * Disposes of the session manager
  41459. */
  41460. dispose(): void;
  41461. }
  41462. }
  41463. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41464. import { Scene } from "babylonjs/scene";
  41465. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41466. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41467. /**
  41468. * WebXR Camera which holds the views for the xrSession
  41469. * @see https://doc.babylonjs.com/how_to/webxr
  41470. */
  41471. export class WebXRCamera extends FreeCamera {
  41472. private static _TmpMatrix;
  41473. /**
  41474. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41475. * @param name the name of the camera
  41476. * @param scene the scene to add the camera to
  41477. */
  41478. constructor(name: string, scene: Scene);
  41479. private _updateNumberOfRigCameras;
  41480. /** @hidden */
  41481. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41482. /**
  41483. * Updates the cameras position from the current pose information of the XR session
  41484. * @param xrSessionManager the session containing pose information
  41485. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41486. */
  41487. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41488. }
  41489. }
  41490. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41491. import { Nullable } from "babylonjs/types";
  41492. import { Observable } from "babylonjs/Misc/observable";
  41493. import { IDisposable, Scene } from "babylonjs/scene";
  41494. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41496. import { Ray } from "babylonjs/Culling/ray";
  41497. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41498. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41499. /**
  41500. * States of the webXR experience
  41501. */
  41502. export enum WebXRState {
  41503. /**
  41504. * Transitioning to being in XR mode
  41505. */
  41506. ENTERING_XR = 0,
  41507. /**
  41508. * Transitioning to non XR mode
  41509. */
  41510. EXITING_XR = 1,
  41511. /**
  41512. * In XR mode and presenting
  41513. */
  41514. IN_XR = 2,
  41515. /**
  41516. * Not entered XR mode
  41517. */
  41518. NOT_IN_XR = 3
  41519. }
  41520. /**
  41521. * Helper class used to enable XR
  41522. * @see https://doc.babylonjs.com/how_to/webxr
  41523. */
  41524. export class WebXRExperienceHelper implements IDisposable {
  41525. private scene;
  41526. /**
  41527. * 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
  41528. */
  41529. container: AbstractMesh;
  41530. /**
  41531. * Camera used to render xr content
  41532. */
  41533. camera: WebXRCamera;
  41534. /**
  41535. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41536. */
  41537. state: WebXRState;
  41538. private _setState;
  41539. private static _TmpVector;
  41540. /**
  41541. * Fires when the state of the experience helper has changed
  41542. */
  41543. onStateChangedObservable: Observable<WebXRState>;
  41544. /** @hidden */
  41545. _sessionManager: WebXRSessionManager;
  41546. private _nonVRCamera;
  41547. private _originalSceneAutoClear;
  41548. private _supported;
  41549. /**
  41550. * Creates the experience helper
  41551. * @param scene the scene to attach the experience helper to
  41552. * @returns a promise for the experience helper
  41553. */
  41554. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41555. /**
  41556. * Creates a WebXRExperienceHelper
  41557. * @param scene The scene the helper should be created in
  41558. */
  41559. private constructor();
  41560. /**
  41561. * Exits XR mode and returns the scene to its original state
  41562. * @returns promise that resolves after xr mode has exited
  41563. */
  41564. exitXRAsync(): Promise<void>;
  41565. /**
  41566. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41567. * @param sessionCreationOptions options for the XR session
  41568. * @param frameOfReference frame of reference of the XR session
  41569. * @returns promise that resolves after xr mode has entered
  41570. */
  41571. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41572. /**
  41573. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41574. * @param ray ray to cast into the environment
  41575. * @returns Promise which resolves with a collision point in the environment if it exists
  41576. */
  41577. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41578. /**
  41579. * Updates the global position of the camera by moving the camera's container
  41580. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41581. * @param position The desired global position of the camera
  41582. */
  41583. setPositionOfCameraUsingContainer(position: Vector3): void;
  41584. /**
  41585. * Rotates the xr camera by rotating the camera's container around the camera's position
  41586. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41587. * @param rotation the desired quaternion rotation to apply to the camera
  41588. */
  41589. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41590. /**
  41591. * Checks if the creation options are supported by the xr session
  41592. * @param options creation options
  41593. * @returns true if supported
  41594. */
  41595. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41596. /**
  41597. * Disposes of the experience helper
  41598. */
  41599. dispose(): void;
  41600. }
  41601. }
  41602. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41603. import { Nullable } from "babylonjs/types";
  41604. import { Observable } from "babylonjs/Misc/observable";
  41605. import { IDisposable, Scene } from "babylonjs/scene";
  41606. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41607. /**
  41608. * Button which can be used to enter a different mode of XR
  41609. */
  41610. export class WebXREnterExitUIButton {
  41611. /** button element */
  41612. element: HTMLElement;
  41613. /** XR initialization options for the button */
  41614. initializationOptions: XRSessionCreationOptions;
  41615. /**
  41616. * Creates a WebXREnterExitUIButton
  41617. * @param element button element
  41618. * @param initializationOptions XR initialization options for the button
  41619. */
  41620. constructor(
  41621. /** button element */
  41622. element: HTMLElement,
  41623. /** XR initialization options for the button */
  41624. initializationOptions: XRSessionCreationOptions);
  41625. /**
  41626. * Overwritable function which can be used to update the button's visuals when the state changes
  41627. * @param activeButton the current active button in the UI
  41628. */
  41629. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41630. }
  41631. /**
  41632. * Options to create the webXR UI
  41633. */
  41634. export class WebXREnterExitUIOptions {
  41635. /**
  41636. * Context to enter xr with
  41637. */
  41638. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41639. /**
  41640. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41641. */
  41642. customButtons?: Array<WebXREnterExitUIButton>;
  41643. }
  41644. /**
  41645. * UI to allow the user to enter/exit XR mode
  41646. */
  41647. export class WebXREnterExitUI implements IDisposable {
  41648. private scene;
  41649. private _overlay;
  41650. private _buttons;
  41651. private _activeButton;
  41652. /**
  41653. * Fired every time the active button is changed.
  41654. *
  41655. * When xr is entered via a button that launches xr that button will be the callback parameter
  41656. *
  41657. * When exiting xr the callback parameter will be null)
  41658. */
  41659. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41660. /**
  41661. * Creates UI to allow the user to enter/exit XR mode
  41662. * @param scene the scene to add the ui to
  41663. * @param helper the xr experience helper to enter/exit xr with
  41664. * @param options options to configure the UI
  41665. * @returns the created ui
  41666. */
  41667. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41668. private constructor();
  41669. private _updateButtons;
  41670. /**
  41671. * Disposes of the object
  41672. */
  41673. dispose(): void;
  41674. }
  41675. }
  41676. declare module "babylonjs/Cameras/XR/webXRInput" {
  41677. import { IDisposable, Scene } from "babylonjs/scene";
  41678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41679. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41680. /**
  41681. * Represents an XR input
  41682. */
  41683. export class WebXRController {
  41684. /**
  41685. * 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
  41686. */
  41687. grip?: AbstractMesh;
  41688. /**
  41689. * Pointer which can be used to select objects or attach a visible laser to
  41690. */
  41691. pointer: AbstractMesh;
  41692. /**
  41693. * Creates the controller
  41694. * @see https://doc.babylonjs.com/how_to/webxr
  41695. * @param scene the scene which the controller should be associated to
  41696. */
  41697. constructor(scene: Scene);
  41698. /**
  41699. * Disposes of the object
  41700. */
  41701. dispose(): void;
  41702. }
  41703. /**
  41704. * XR input used to track XR inputs such as controllers/rays
  41705. */
  41706. export class WebXRInput implements IDisposable {
  41707. private helper;
  41708. /**
  41709. * XR controllers being tracked
  41710. */
  41711. controllers: Array<WebXRController>;
  41712. private _tmpMatrix;
  41713. private _frameObserver;
  41714. /**
  41715. * Initializes the WebXRInput
  41716. * @param helper experience helper which the input should be created for
  41717. */
  41718. constructor(helper: WebXRExperienceHelper);
  41719. /**
  41720. * Disposes of the object
  41721. */
  41722. dispose(): void;
  41723. }
  41724. }
  41725. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41726. import { Nullable } from "babylonjs/types";
  41727. import { IDisposable } from "babylonjs/scene";
  41728. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41729. /**
  41730. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41731. */
  41732. export class WebXRManagedOutputCanvas implements IDisposable {
  41733. private _canvas;
  41734. /**
  41735. * xrpresent context of the canvas which can be used to display/mirror xr content
  41736. */
  41737. canvasContext: Nullable<WebGLRenderingContext>;
  41738. /**
  41739. * Initializes the canvas to be added/removed upon entering/exiting xr
  41740. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41741. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41742. */
  41743. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41744. /**
  41745. * Disposes of the object
  41746. */
  41747. dispose(): void;
  41748. private _setManagedOutputCanvas;
  41749. private _addCanvas;
  41750. private _removeCanvas;
  41751. }
  41752. }
  41753. declare module "babylonjs/Cameras/XR/index" {
  41754. export * from "babylonjs/Cameras/XR/webXRCamera";
  41755. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41756. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41757. export * from "babylonjs/Cameras/XR/webXRInput";
  41758. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41759. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41760. }
  41761. declare module "babylonjs/Cameras/RigModes/index" {
  41762. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41763. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41764. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41765. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41766. }
  41767. declare module "babylonjs/Cameras/index" {
  41768. export * from "babylonjs/Cameras/Inputs/index";
  41769. export * from "babylonjs/Cameras/cameraInputsManager";
  41770. export * from "babylonjs/Cameras/camera";
  41771. export * from "babylonjs/Cameras/targetCamera";
  41772. export * from "babylonjs/Cameras/freeCamera";
  41773. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41774. export * from "babylonjs/Cameras/touchCamera";
  41775. export * from "babylonjs/Cameras/arcRotateCamera";
  41776. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41777. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41778. export * from "babylonjs/Cameras/flyCamera";
  41779. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41780. export * from "babylonjs/Cameras/followCamera";
  41781. export * from "babylonjs/Cameras/gamepadCamera";
  41782. export * from "babylonjs/Cameras/Stereoscopic/index";
  41783. export * from "babylonjs/Cameras/universalCamera";
  41784. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41785. export * from "babylonjs/Cameras/VR/index";
  41786. export * from "babylonjs/Cameras/XR/index";
  41787. export * from "babylonjs/Cameras/RigModes/index";
  41788. }
  41789. declare module "babylonjs/Collisions/index" {
  41790. export * from "babylonjs/Collisions/collider";
  41791. export * from "babylonjs/Collisions/collisionCoordinator";
  41792. export * from "babylonjs/Collisions/pickingInfo";
  41793. export * from "babylonjs/Collisions/intersectionInfo";
  41794. export * from "babylonjs/Collisions/meshCollisionData";
  41795. }
  41796. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41797. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41798. import { Vector3, Plane } from "babylonjs/Maths/math";
  41799. import { Ray } from "babylonjs/Culling/ray";
  41800. /**
  41801. * Contains an array of blocks representing the octree
  41802. */
  41803. export interface IOctreeContainer<T> {
  41804. /**
  41805. * Blocks within the octree
  41806. */
  41807. blocks: Array<OctreeBlock<T>>;
  41808. }
  41809. /**
  41810. * Class used to store a cell in an octree
  41811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41812. */
  41813. export class OctreeBlock<T> {
  41814. /**
  41815. * Gets the content of the current block
  41816. */
  41817. entries: T[];
  41818. /**
  41819. * Gets the list of block children
  41820. */
  41821. blocks: Array<OctreeBlock<T>>;
  41822. private _depth;
  41823. private _maxDepth;
  41824. private _capacity;
  41825. private _minPoint;
  41826. private _maxPoint;
  41827. private _boundingVectors;
  41828. private _creationFunc;
  41829. /**
  41830. * Creates a new block
  41831. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41832. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41833. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41834. * @param depth defines the current depth of this block in the octree
  41835. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41836. * @param creationFunc defines a callback to call when an element is added to the block
  41837. */
  41838. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41839. /**
  41840. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41841. */
  41842. readonly capacity: number;
  41843. /**
  41844. * Gets the minimum vector (in world space) of the block's bounding box
  41845. */
  41846. readonly minPoint: Vector3;
  41847. /**
  41848. * Gets the maximum vector (in world space) of the block's bounding box
  41849. */
  41850. readonly maxPoint: Vector3;
  41851. /**
  41852. * Add a new element to this block
  41853. * @param entry defines the element to add
  41854. */
  41855. addEntry(entry: T): void;
  41856. /**
  41857. * Remove an element from this block
  41858. * @param entry defines the element to remove
  41859. */
  41860. removeEntry(entry: T): void;
  41861. /**
  41862. * Add an array of elements to this block
  41863. * @param entries defines the array of elements to add
  41864. */
  41865. addEntries(entries: T[]): void;
  41866. /**
  41867. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41868. * @param frustumPlanes defines the frustum planes to test
  41869. * @param selection defines the array to store current content if selection is positive
  41870. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41871. */
  41872. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41873. /**
  41874. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41875. * @param sphereCenter defines the bounding sphere center
  41876. * @param sphereRadius defines the bounding sphere radius
  41877. * @param selection defines the array to store current content if selection is positive
  41878. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41879. */
  41880. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41881. /**
  41882. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41883. * @param ray defines the ray to test with
  41884. * @param selection defines the array to store current content if selection is positive
  41885. */
  41886. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41887. /**
  41888. * Subdivide the content into child blocks (this block will then be empty)
  41889. */
  41890. createInnerBlocks(): void;
  41891. /**
  41892. * @hidden
  41893. */
  41894. 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;
  41895. }
  41896. }
  41897. declare module "babylonjs/Culling/Octrees/octree" {
  41898. import { SmartArray } from "babylonjs/Misc/smartArray";
  41899. import { Vector3, Plane } from "babylonjs/Maths/math";
  41900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41902. import { Ray } from "babylonjs/Culling/ray";
  41903. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41904. /**
  41905. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41906. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41907. */
  41908. export class Octree<T> {
  41909. /** 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.) */
  41910. maxDepth: number;
  41911. /**
  41912. * Blocks within the octree containing objects
  41913. */
  41914. blocks: Array<OctreeBlock<T>>;
  41915. /**
  41916. * Content stored in the octree
  41917. */
  41918. dynamicContent: T[];
  41919. private _maxBlockCapacity;
  41920. private _selectionContent;
  41921. private _creationFunc;
  41922. /**
  41923. * Creates a octree
  41924. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41925. * @param creationFunc function to be used to instatiate the octree
  41926. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41927. * @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.)
  41928. */
  41929. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41930. /** 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.) */
  41931. maxDepth?: number);
  41932. /**
  41933. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41934. * @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);
  41935. * @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);
  41936. * @param entries meshes to be added to the octree blocks
  41937. */
  41938. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41939. /**
  41940. * Adds a mesh to the octree
  41941. * @param entry Mesh to add to the octree
  41942. */
  41943. addMesh(entry: T): void;
  41944. /**
  41945. * Remove an element from the octree
  41946. * @param entry defines the element to remove
  41947. */
  41948. removeMesh(entry: T): void;
  41949. /**
  41950. * Selects an array of meshes within the frustum
  41951. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41952. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41953. * @returns array of meshes within the frustum
  41954. */
  41955. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41956. /**
  41957. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41958. * @param sphereCenter defines the bounding sphere center
  41959. * @param sphereRadius defines the bounding sphere radius
  41960. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41961. * @returns an array of objects that intersect the sphere
  41962. */
  41963. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41964. /**
  41965. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41966. * @param ray defines the ray to test with
  41967. * @returns array of intersected objects
  41968. */
  41969. intersectsRay(ray: Ray): SmartArray<T>;
  41970. /**
  41971. * Adds a mesh into the octree block if it intersects the block
  41972. */
  41973. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41974. /**
  41975. * Adds a submesh into the octree block if it intersects the block
  41976. */
  41977. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41978. }
  41979. }
  41980. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41981. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41982. import { Scene } from "babylonjs/scene";
  41983. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41985. import { Ray } from "babylonjs/Culling/ray";
  41986. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41987. import { Collider } from "babylonjs/Collisions/collider";
  41988. module "babylonjs/scene" {
  41989. interface Scene {
  41990. /**
  41991. * @hidden
  41992. * Backing Filed
  41993. */
  41994. _selectionOctree: Octree<AbstractMesh>;
  41995. /**
  41996. * Gets the octree used to boost mesh selection (picking)
  41997. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41998. */
  41999. selectionOctree: Octree<AbstractMesh>;
  42000. /**
  42001. * Creates or updates the octree used to boost selection (picking)
  42002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42003. * @param maxCapacity defines the maximum capacity per leaf
  42004. * @param maxDepth defines the maximum depth of the octree
  42005. * @returns an octree of AbstractMesh
  42006. */
  42007. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42008. }
  42009. }
  42010. module "babylonjs/Meshes/abstractMesh" {
  42011. interface AbstractMesh {
  42012. /**
  42013. * @hidden
  42014. * Backing Field
  42015. */
  42016. _submeshesOctree: Octree<SubMesh>;
  42017. /**
  42018. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42019. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42020. * @param maxCapacity defines the maximum size of each block (64 by default)
  42021. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42022. * @returns the new octree
  42023. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42024. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42025. */
  42026. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42027. }
  42028. }
  42029. /**
  42030. * Defines the octree scene component responsible to manage any octrees
  42031. * in a given scene.
  42032. */
  42033. export class OctreeSceneComponent {
  42034. /**
  42035. * The component name help to identify the component in the list of scene components.
  42036. */
  42037. readonly name: string;
  42038. /**
  42039. * The scene the component belongs to.
  42040. */
  42041. scene: Scene;
  42042. /**
  42043. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42044. */
  42045. readonly checksIsEnabled: boolean;
  42046. /**
  42047. * Creates a new instance of the component for the given scene
  42048. * @param scene Defines the scene to register the component in
  42049. */
  42050. constructor(scene: Scene);
  42051. /**
  42052. * Registers the component in a given scene
  42053. */
  42054. register(): void;
  42055. /**
  42056. * Return the list of active meshes
  42057. * @returns the list of active meshes
  42058. */
  42059. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42060. /**
  42061. * Return the list of active sub meshes
  42062. * @param mesh The mesh to get the candidates sub meshes from
  42063. * @returns the list of active sub meshes
  42064. */
  42065. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42066. private _tempRay;
  42067. /**
  42068. * Return the list of sub meshes intersecting with a given local ray
  42069. * @param mesh defines the mesh to find the submesh for
  42070. * @param localRay defines the ray in local space
  42071. * @returns the list of intersecting sub meshes
  42072. */
  42073. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42074. /**
  42075. * Return the list of sub meshes colliding with a collider
  42076. * @param mesh defines the mesh to find the submesh for
  42077. * @param collider defines the collider to evaluate the collision against
  42078. * @returns the list of colliding sub meshes
  42079. */
  42080. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42081. /**
  42082. * Rebuilds the elements related to this component in case of
  42083. * context lost for instance.
  42084. */
  42085. rebuild(): void;
  42086. /**
  42087. * Disposes the component and the associated ressources.
  42088. */
  42089. dispose(): void;
  42090. }
  42091. }
  42092. declare module "babylonjs/Culling/Octrees/index" {
  42093. export * from "babylonjs/Culling/Octrees/octree";
  42094. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42095. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42096. }
  42097. declare module "babylonjs/Culling/index" {
  42098. export * from "babylonjs/Culling/boundingBox";
  42099. export * from "babylonjs/Culling/boundingInfo";
  42100. export * from "babylonjs/Culling/boundingSphere";
  42101. export * from "babylonjs/Culling/Octrees/index";
  42102. export * from "babylonjs/Culling/ray";
  42103. }
  42104. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42105. import { IDisposable, Scene } from "babylonjs/scene";
  42106. import { Nullable } from "babylonjs/types";
  42107. import { Observable } from "babylonjs/Misc/observable";
  42108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42109. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42110. /**
  42111. * Renders a layer on top of an existing scene
  42112. */
  42113. export class UtilityLayerRenderer implements IDisposable {
  42114. /** the original scene that will be rendered on top of */
  42115. originalScene: Scene;
  42116. private _pointerCaptures;
  42117. private _lastPointerEvents;
  42118. private static _DefaultUtilityLayer;
  42119. private static _DefaultKeepDepthUtilityLayer;
  42120. private _sharedGizmoLight;
  42121. /**
  42122. * @hidden
  42123. * Light which used by gizmos to get light shading
  42124. */
  42125. _getSharedGizmoLight(): HemisphericLight;
  42126. /**
  42127. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42128. */
  42129. pickUtilitySceneFirst: boolean;
  42130. /**
  42131. * 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)
  42132. */
  42133. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42134. /**
  42135. * 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)
  42136. */
  42137. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42138. /**
  42139. * The scene that is rendered on top of the original scene
  42140. */
  42141. utilityLayerScene: Scene;
  42142. /**
  42143. * If the utility layer should automatically be rendered on top of existing scene
  42144. */
  42145. shouldRender: boolean;
  42146. /**
  42147. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42148. */
  42149. onlyCheckPointerDownEvents: boolean;
  42150. /**
  42151. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42152. */
  42153. processAllEvents: boolean;
  42154. /**
  42155. * Observable raised when the pointer move from the utility layer scene to the main scene
  42156. */
  42157. onPointerOutObservable: Observable<number>;
  42158. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42159. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42160. private _afterRenderObserver;
  42161. private _sceneDisposeObserver;
  42162. private _originalPointerObserver;
  42163. /**
  42164. * Instantiates a UtilityLayerRenderer
  42165. * @param originalScene the original scene that will be rendered on top of
  42166. * @param handleEvents boolean indicating if the utility layer should handle events
  42167. */
  42168. constructor(
  42169. /** the original scene that will be rendered on top of */
  42170. originalScene: Scene, handleEvents?: boolean);
  42171. private _notifyObservers;
  42172. /**
  42173. * Renders the utility layers scene on top of the original scene
  42174. */
  42175. render(): void;
  42176. /**
  42177. * Disposes of the renderer
  42178. */
  42179. dispose(): void;
  42180. private _updateCamera;
  42181. }
  42182. }
  42183. declare module "babylonjs/Gizmos/gizmo" {
  42184. import { Nullable } from "babylonjs/types";
  42185. import { IDisposable } from "babylonjs/scene";
  42186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42187. import { Mesh } from "babylonjs/Meshes/mesh";
  42188. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42189. /**
  42190. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42191. */
  42192. export class Gizmo implements IDisposable {
  42193. /** The utility layer the gizmo will be added to */
  42194. gizmoLayer: UtilityLayerRenderer;
  42195. /**
  42196. * The root mesh of the gizmo
  42197. */
  42198. _rootMesh: Mesh;
  42199. private _attachedMesh;
  42200. /**
  42201. * Ratio for the scale of the gizmo (Default: 1)
  42202. */
  42203. scaleRatio: number;
  42204. /**
  42205. * If a custom mesh has been set (Default: false)
  42206. */
  42207. protected _customMeshSet: boolean;
  42208. /**
  42209. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42210. * * When set, interactions will be enabled
  42211. */
  42212. attachedMesh: Nullable<AbstractMesh>;
  42213. /**
  42214. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42215. * @param mesh The mesh to replace the default mesh of the gizmo
  42216. */
  42217. setCustomMesh(mesh: Mesh): void;
  42218. /**
  42219. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42220. */
  42221. updateGizmoRotationToMatchAttachedMesh: boolean;
  42222. /**
  42223. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42224. */
  42225. updateGizmoPositionToMatchAttachedMesh: boolean;
  42226. /**
  42227. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42228. */
  42229. protected _updateScale: boolean;
  42230. protected _interactionsEnabled: boolean;
  42231. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42232. private _beforeRenderObserver;
  42233. private _tempVector;
  42234. /**
  42235. * Creates a gizmo
  42236. * @param gizmoLayer The utility layer the gizmo will be added to
  42237. */
  42238. constructor(
  42239. /** The utility layer the gizmo will be added to */
  42240. gizmoLayer?: UtilityLayerRenderer);
  42241. /**
  42242. * Updates the gizmo to match the attached mesh's position/rotation
  42243. */
  42244. protected _update(): void;
  42245. /**
  42246. * Disposes of the gizmo
  42247. */
  42248. dispose(): void;
  42249. }
  42250. }
  42251. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42252. import { Observable } from "babylonjs/Misc/observable";
  42253. import { Nullable } from "babylonjs/types";
  42254. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42255. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42257. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42258. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42259. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42260. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42261. import { Scene } from "babylonjs/scene";
  42262. /**
  42263. * Single axis drag gizmo
  42264. */
  42265. export class AxisDragGizmo extends Gizmo {
  42266. /**
  42267. * Drag behavior responsible for the gizmos dragging interactions
  42268. */
  42269. dragBehavior: PointerDragBehavior;
  42270. private _pointerObserver;
  42271. /**
  42272. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42273. */
  42274. snapDistance: number;
  42275. /**
  42276. * Event that fires each time the gizmo snaps to a new location.
  42277. * * snapDistance is the the change in distance
  42278. */
  42279. onSnapObservable: Observable<{
  42280. snapDistance: number;
  42281. }>;
  42282. /** @hidden */
  42283. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42284. /** @hidden */
  42285. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42286. /**
  42287. * Creates an AxisDragGizmo
  42288. * @param gizmoLayer The utility layer the gizmo will be added to
  42289. * @param dragAxis The axis which the gizmo will be able to drag on
  42290. * @param color The color of the gizmo
  42291. */
  42292. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42293. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42294. /**
  42295. * Disposes of the gizmo
  42296. */
  42297. dispose(): void;
  42298. }
  42299. }
  42300. declare module "babylonjs/Debug/axesViewer" {
  42301. import { Vector3 } from "babylonjs/Maths/math";
  42302. import { Nullable } from "babylonjs/types";
  42303. import { Scene } from "babylonjs/scene";
  42304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42305. /**
  42306. * The Axes viewer will show 3 axes in a specific point in space
  42307. */
  42308. export class AxesViewer {
  42309. private _xAxis;
  42310. private _yAxis;
  42311. private _zAxis;
  42312. private _scaleLinesFactor;
  42313. private _instanced;
  42314. /**
  42315. * Gets the hosting scene
  42316. */
  42317. scene: Scene;
  42318. /**
  42319. * Gets or sets a number used to scale line length
  42320. */
  42321. scaleLines: number;
  42322. /** Gets the node hierarchy used to render x-axis */
  42323. readonly xAxis: TransformNode;
  42324. /** Gets the node hierarchy used to render y-axis */
  42325. readonly yAxis: TransformNode;
  42326. /** Gets the node hierarchy used to render z-axis */
  42327. readonly zAxis: TransformNode;
  42328. /**
  42329. * Creates a new AxesViewer
  42330. * @param scene defines the hosting scene
  42331. * @param scaleLines defines a number used to scale line length (1 by default)
  42332. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42333. * @param xAxis defines the node hierarchy used to render the x-axis
  42334. * @param yAxis defines the node hierarchy used to render the y-axis
  42335. * @param zAxis defines the node hierarchy used to render the z-axis
  42336. */
  42337. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42338. /**
  42339. * Force the viewer to update
  42340. * @param position defines the position of the viewer
  42341. * @param xaxis defines the x axis of the viewer
  42342. * @param yaxis defines the y axis of the viewer
  42343. * @param zaxis defines the z axis of the viewer
  42344. */
  42345. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42346. /**
  42347. * Creates an instance of this axes viewer.
  42348. * @returns a new axes viewer with instanced meshes
  42349. */
  42350. createInstance(): AxesViewer;
  42351. /** Releases resources */
  42352. dispose(): void;
  42353. private static _SetRenderingGroupId;
  42354. }
  42355. }
  42356. declare module "babylonjs/Debug/boneAxesViewer" {
  42357. import { Nullable } from "babylonjs/types";
  42358. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42359. import { Vector3 } from "babylonjs/Maths/math";
  42360. import { Mesh } from "babylonjs/Meshes/mesh";
  42361. import { Bone } from "babylonjs/Bones/bone";
  42362. import { Scene } from "babylonjs/scene";
  42363. /**
  42364. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42365. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42366. */
  42367. export class BoneAxesViewer extends AxesViewer {
  42368. /**
  42369. * Gets or sets the target mesh where to display the axes viewer
  42370. */
  42371. mesh: Nullable<Mesh>;
  42372. /**
  42373. * Gets or sets the target bone where to display the axes viewer
  42374. */
  42375. bone: Nullable<Bone>;
  42376. /** Gets current position */
  42377. pos: Vector3;
  42378. /** Gets direction of X axis */
  42379. xaxis: Vector3;
  42380. /** Gets direction of Y axis */
  42381. yaxis: Vector3;
  42382. /** Gets direction of Z axis */
  42383. zaxis: Vector3;
  42384. /**
  42385. * Creates a new BoneAxesViewer
  42386. * @param scene defines the hosting scene
  42387. * @param bone defines the target bone
  42388. * @param mesh defines the target mesh
  42389. * @param scaleLines defines a scaling factor for line length (1 by default)
  42390. */
  42391. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42392. /**
  42393. * Force the viewer to update
  42394. */
  42395. update(): void;
  42396. /** Releases resources */
  42397. dispose(): void;
  42398. }
  42399. }
  42400. declare module "babylonjs/Debug/debugLayer" {
  42401. import { Observable } from "babylonjs/Misc/observable";
  42402. import { Scene } from "babylonjs/scene";
  42403. /**
  42404. * Interface used to define scene explorer extensibility option
  42405. */
  42406. export interface IExplorerExtensibilityOption {
  42407. /**
  42408. * Define the option label
  42409. */
  42410. label: string;
  42411. /**
  42412. * Defines the action to execute on click
  42413. */
  42414. action: (entity: any) => void;
  42415. }
  42416. /**
  42417. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42418. */
  42419. export interface IExplorerExtensibilityGroup {
  42420. /**
  42421. * Defines a predicate to test if a given type mut be extended
  42422. */
  42423. predicate: (entity: any) => boolean;
  42424. /**
  42425. * Gets the list of options added to a type
  42426. */
  42427. entries: IExplorerExtensibilityOption[];
  42428. }
  42429. /**
  42430. * Interface used to define the options to use to create the Inspector
  42431. */
  42432. export interface IInspectorOptions {
  42433. /**
  42434. * Display in overlay mode (default: false)
  42435. */
  42436. overlay?: boolean;
  42437. /**
  42438. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42439. */
  42440. globalRoot?: HTMLElement;
  42441. /**
  42442. * Display the Scene explorer
  42443. */
  42444. showExplorer?: boolean;
  42445. /**
  42446. * Display the property inspector
  42447. */
  42448. showInspector?: boolean;
  42449. /**
  42450. * Display in embed mode (both panes on the right)
  42451. */
  42452. embedMode?: boolean;
  42453. /**
  42454. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42455. */
  42456. handleResize?: boolean;
  42457. /**
  42458. * Allow the panes to popup (default: true)
  42459. */
  42460. enablePopup?: boolean;
  42461. /**
  42462. * Allow the panes to be closed by users (default: true)
  42463. */
  42464. enableClose?: boolean;
  42465. /**
  42466. * Optional list of extensibility entries
  42467. */
  42468. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42469. /**
  42470. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42471. */
  42472. inspectorURL?: string;
  42473. }
  42474. module "babylonjs/scene" {
  42475. interface Scene {
  42476. /**
  42477. * @hidden
  42478. * Backing field
  42479. */
  42480. _debugLayer: DebugLayer;
  42481. /**
  42482. * Gets the debug layer (aka Inspector) associated with the scene
  42483. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42484. */
  42485. debugLayer: DebugLayer;
  42486. }
  42487. }
  42488. /**
  42489. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42490. * what is happening in your scene
  42491. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42492. */
  42493. export class DebugLayer {
  42494. /**
  42495. * Define the url to get the inspector script from.
  42496. * By default it uses the babylonjs CDN.
  42497. * @ignoreNaming
  42498. */
  42499. static InspectorURL: string;
  42500. private _scene;
  42501. private BJSINSPECTOR;
  42502. /**
  42503. * Observable triggered when a property is changed through the inspector.
  42504. */
  42505. onPropertyChangedObservable: Observable<{
  42506. object: any;
  42507. property: string;
  42508. value: any;
  42509. initialValue: any;
  42510. }>;
  42511. /**
  42512. * Instantiates a new debug layer.
  42513. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42514. * what is happening in your scene
  42515. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42516. * @param scene Defines the scene to inspect
  42517. */
  42518. constructor(scene: Scene);
  42519. /** Creates the inspector window. */
  42520. private _createInspector;
  42521. /**
  42522. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42523. * @param entity defines the entity to select
  42524. * @param lineContainerTitle defines the specific block to highlight
  42525. */
  42526. select(entity: any, lineContainerTitle?: string): void;
  42527. /** Get the inspector from bundle or global */
  42528. private _getGlobalInspector;
  42529. /**
  42530. * Get if the inspector is visible or not.
  42531. * @returns true if visible otherwise, false
  42532. */
  42533. isVisible(): boolean;
  42534. /**
  42535. * Hide the inspector and close its window.
  42536. */
  42537. hide(): void;
  42538. /**
  42539. * Launch the debugLayer.
  42540. * @param config Define the configuration of the inspector
  42541. * @return a promise fulfilled when the debug layer is visible
  42542. */
  42543. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42544. }
  42545. }
  42546. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42547. import { Nullable } from "babylonjs/types";
  42548. import { Scene } from "babylonjs/scene";
  42549. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42550. import { Mesh } from "babylonjs/Meshes/mesh";
  42551. /**
  42552. * Class containing static functions to help procedurally build meshes
  42553. */
  42554. export class BoxBuilder {
  42555. /**
  42556. * Creates a box mesh
  42557. * * The parameter `size` sets the size (float) of each box side (default 1)
  42558. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42559. * * 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)
  42560. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42564. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42565. * @param name defines the name of the mesh
  42566. * @param options defines the options used to create the mesh
  42567. * @param scene defines the hosting scene
  42568. * @returns the box mesh
  42569. */
  42570. static CreateBox(name: string, options: {
  42571. size?: number;
  42572. width?: number;
  42573. height?: number;
  42574. depth?: number;
  42575. faceUV?: Vector4[];
  42576. faceColors?: Color4[];
  42577. sideOrientation?: number;
  42578. frontUVs?: Vector4;
  42579. backUVs?: Vector4;
  42580. wrap?: boolean;
  42581. topBaseAt?: number;
  42582. bottomBaseAt?: number;
  42583. updatable?: boolean;
  42584. }, scene?: Nullable<Scene>): Mesh;
  42585. }
  42586. }
  42587. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42588. import { Vector4 } from "babylonjs/Maths/math";
  42589. import { Mesh } from "babylonjs/Meshes/mesh";
  42590. /**
  42591. * Class containing static functions to help procedurally build meshes
  42592. */
  42593. export class SphereBuilder {
  42594. /**
  42595. * Creates a sphere mesh
  42596. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42597. * * 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`)
  42598. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42599. * * 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
  42600. * * 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)
  42601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42604. * @param name defines the name of the mesh
  42605. * @param options defines the options used to create the mesh
  42606. * @param scene defines the hosting scene
  42607. * @returns the sphere mesh
  42608. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42609. */
  42610. static CreateSphere(name: string, options: {
  42611. segments?: number;
  42612. diameter?: number;
  42613. diameterX?: number;
  42614. diameterY?: number;
  42615. diameterZ?: number;
  42616. arc?: number;
  42617. slice?: number;
  42618. sideOrientation?: number;
  42619. frontUVs?: Vector4;
  42620. backUVs?: Vector4;
  42621. updatable?: boolean;
  42622. }, scene: any): Mesh;
  42623. }
  42624. }
  42625. declare module "babylonjs/Debug/physicsViewer" {
  42626. import { Nullable } from "babylonjs/types";
  42627. import { Scene } from "babylonjs/scene";
  42628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42629. import { Mesh } from "babylonjs/Meshes/mesh";
  42630. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42631. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42632. /**
  42633. * Used to show the physics impostor around the specific mesh
  42634. */
  42635. export class PhysicsViewer {
  42636. /** @hidden */
  42637. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42638. /** @hidden */
  42639. protected _meshes: Array<Nullable<AbstractMesh>>;
  42640. /** @hidden */
  42641. protected _scene: Nullable<Scene>;
  42642. /** @hidden */
  42643. protected _numMeshes: number;
  42644. /** @hidden */
  42645. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42646. private _renderFunction;
  42647. private _utilityLayer;
  42648. private _debugBoxMesh;
  42649. private _debugSphereMesh;
  42650. private _debugCylinderMesh;
  42651. private _debugMaterial;
  42652. private _debugMeshMeshes;
  42653. /**
  42654. * Creates a new PhysicsViewer
  42655. * @param scene defines the hosting scene
  42656. */
  42657. constructor(scene: Scene);
  42658. /** @hidden */
  42659. protected _updateDebugMeshes(): void;
  42660. /**
  42661. * Renders a specified physic impostor
  42662. * @param impostor defines the impostor to render
  42663. * @param targetMesh defines the mesh represented by the impostor
  42664. * @returns the new debug mesh used to render the impostor
  42665. */
  42666. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42667. /**
  42668. * Hides a specified physic impostor
  42669. * @param impostor defines the impostor to hide
  42670. */
  42671. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42672. private _getDebugMaterial;
  42673. private _getDebugBoxMesh;
  42674. private _getDebugSphereMesh;
  42675. private _getDebugCylinderMesh;
  42676. private _getDebugMeshMesh;
  42677. private _getDebugMesh;
  42678. /** Releases all resources */
  42679. dispose(): void;
  42680. }
  42681. }
  42682. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42683. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42684. import { Nullable } from "babylonjs/types";
  42685. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42686. import { Scene } from "babylonjs/scene";
  42687. /**
  42688. * Class containing static functions to help procedurally build meshes
  42689. */
  42690. export class LinesBuilder {
  42691. /**
  42692. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42693. * * 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
  42694. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42695. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42696. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42697. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42698. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42699. * * 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
  42700. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42703. * @param name defines the name of the new line system
  42704. * @param options defines the options used to create the line system
  42705. * @param scene defines the hosting scene
  42706. * @returns a new line system mesh
  42707. */
  42708. static CreateLineSystem(name: string, options: {
  42709. lines: Vector3[][];
  42710. updatable?: boolean;
  42711. instance?: Nullable<LinesMesh>;
  42712. colors?: Nullable<Color4[][]>;
  42713. useVertexAlpha?: boolean;
  42714. }, scene: Nullable<Scene>): LinesMesh;
  42715. /**
  42716. * Creates a line mesh
  42717. * 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
  42718. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42719. * * The parameter `points` is an array successive Vector3
  42720. * * 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
  42721. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42722. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42723. * * When updating an instance, remember that only point positions can change, not the number of points
  42724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42726. * @param name defines the name of the new line system
  42727. * @param options defines the options used to create the line system
  42728. * @param scene defines the hosting scene
  42729. * @returns a new line mesh
  42730. */
  42731. static CreateLines(name: string, options: {
  42732. points: Vector3[];
  42733. updatable?: boolean;
  42734. instance?: Nullable<LinesMesh>;
  42735. colors?: Color4[];
  42736. useVertexAlpha?: boolean;
  42737. }, scene?: Nullable<Scene>): LinesMesh;
  42738. /**
  42739. * Creates a dashed line mesh
  42740. * * 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
  42741. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42742. * * The parameter `points` is an array successive Vector3
  42743. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42744. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42745. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42746. * * 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
  42747. * * When updating an instance, remember that only point positions can change, not the number of points
  42748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42749. * @param name defines the name of the mesh
  42750. * @param options defines the options used to create the mesh
  42751. * @param scene defines the hosting scene
  42752. * @returns the dashed line mesh
  42753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42754. */
  42755. static CreateDashedLines(name: string, options: {
  42756. points: Vector3[];
  42757. dashSize?: number;
  42758. gapSize?: number;
  42759. dashNb?: number;
  42760. updatable?: boolean;
  42761. instance?: LinesMesh;
  42762. }, scene?: Nullable<Scene>): LinesMesh;
  42763. }
  42764. }
  42765. declare module "babylonjs/Debug/rayHelper" {
  42766. import { Nullable } from "babylonjs/types";
  42767. import { Ray } from "babylonjs/Culling/ray";
  42768. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42769. import { Scene } from "babylonjs/scene";
  42770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42771. import "babylonjs/Meshes/Builders/linesBuilder";
  42772. /**
  42773. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42774. * in order to better appreciate the issue one might have.
  42775. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42776. */
  42777. export class RayHelper {
  42778. /**
  42779. * Defines the ray we are currently tryin to visualize.
  42780. */
  42781. ray: Nullable<Ray>;
  42782. private _renderPoints;
  42783. private _renderLine;
  42784. private _renderFunction;
  42785. private _scene;
  42786. private _updateToMeshFunction;
  42787. private _attachedToMesh;
  42788. private _meshSpaceDirection;
  42789. private _meshSpaceOrigin;
  42790. /**
  42791. * Helper function to create a colored helper in a scene in one line.
  42792. * @param ray Defines the ray we are currently tryin to visualize
  42793. * @param scene Defines the scene the ray is used in
  42794. * @param color Defines the color we want to see the ray in
  42795. * @returns The newly created ray helper.
  42796. */
  42797. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42798. /**
  42799. * Instantiate a new ray helper.
  42800. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42801. * in order to better appreciate the issue one might have.
  42802. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42803. * @param ray Defines the ray we are currently tryin to visualize
  42804. */
  42805. constructor(ray: Ray);
  42806. /**
  42807. * Shows the ray we are willing to debug.
  42808. * @param scene Defines the scene the ray needs to be rendered in
  42809. * @param color Defines the color the ray needs to be rendered in
  42810. */
  42811. show(scene: Scene, color?: Color3): void;
  42812. /**
  42813. * Hides the ray we are debugging.
  42814. */
  42815. hide(): void;
  42816. private _render;
  42817. /**
  42818. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42819. * @param mesh Defines the mesh we want the helper attached to
  42820. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42821. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42822. * @param length Defines the length of the ray
  42823. */
  42824. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42825. /**
  42826. * Detach the ray helper from the mesh it has previously been attached to.
  42827. */
  42828. detachFromMesh(): void;
  42829. private _updateToMesh;
  42830. /**
  42831. * Dispose the helper and release its associated resources.
  42832. */
  42833. dispose(): void;
  42834. }
  42835. }
  42836. declare module "babylonjs/Debug/skeletonViewer" {
  42837. import { Color3 } from "babylonjs/Maths/math";
  42838. import { Scene } from "babylonjs/scene";
  42839. import { Nullable } from "babylonjs/types";
  42840. import { Skeleton } from "babylonjs/Bones/skeleton";
  42841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42842. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42843. /**
  42844. * Class used to render a debug view of a given skeleton
  42845. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42846. */
  42847. export class SkeletonViewer {
  42848. /** defines the skeleton to render */
  42849. skeleton: Skeleton;
  42850. /** defines the mesh attached to the skeleton */
  42851. mesh: AbstractMesh;
  42852. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42853. autoUpdateBonesMatrices: boolean;
  42854. /** defines the rendering group id to use with the viewer */
  42855. renderingGroupId: number;
  42856. /** Gets or sets the color used to render the skeleton */
  42857. color: Color3;
  42858. private _scene;
  42859. private _debugLines;
  42860. private _debugMesh;
  42861. private _isEnabled;
  42862. private _renderFunction;
  42863. private _utilityLayer;
  42864. /**
  42865. * Returns the mesh used to render the bones
  42866. */
  42867. readonly debugMesh: Nullable<LinesMesh>;
  42868. /**
  42869. * Creates a new SkeletonViewer
  42870. * @param skeleton defines the skeleton to render
  42871. * @param mesh defines the mesh attached to the skeleton
  42872. * @param scene defines the hosting scene
  42873. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42874. * @param renderingGroupId defines the rendering group id to use with the viewer
  42875. */
  42876. constructor(
  42877. /** defines the skeleton to render */
  42878. skeleton: Skeleton,
  42879. /** defines the mesh attached to the skeleton */
  42880. mesh: AbstractMesh, scene: Scene,
  42881. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42882. autoUpdateBonesMatrices?: boolean,
  42883. /** defines the rendering group id to use with the viewer */
  42884. renderingGroupId?: number);
  42885. /** Gets or sets a boolean indicating if the viewer is enabled */
  42886. isEnabled: boolean;
  42887. private _getBonePosition;
  42888. private _getLinesForBonesWithLength;
  42889. private _getLinesForBonesNoLength;
  42890. /** Update the viewer to sync with current skeleton state */
  42891. update(): void;
  42892. /** Release associated resources */
  42893. dispose(): void;
  42894. }
  42895. }
  42896. declare module "babylonjs/Debug/index" {
  42897. export * from "babylonjs/Debug/axesViewer";
  42898. export * from "babylonjs/Debug/boneAxesViewer";
  42899. export * from "babylonjs/Debug/debugLayer";
  42900. export * from "babylonjs/Debug/physicsViewer";
  42901. export * from "babylonjs/Debug/rayHelper";
  42902. export * from "babylonjs/Debug/skeletonViewer";
  42903. }
  42904. declare module "babylonjs/Engines/nullEngine" {
  42905. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42906. import { Scene } from "babylonjs/scene";
  42907. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42908. import { Engine } from "babylonjs/Engines/engine";
  42909. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42910. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42911. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42912. import { Effect } from "babylonjs/Materials/effect";
  42913. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42914. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42915. /**
  42916. * Options to create the null engine
  42917. */
  42918. export class NullEngineOptions {
  42919. /**
  42920. * Render width (Default: 512)
  42921. */
  42922. renderWidth: number;
  42923. /**
  42924. * Render height (Default: 256)
  42925. */
  42926. renderHeight: number;
  42927. /**
  42928. * Texture size (Default: 512)
  42929. */
  42930. textureSize: number;
  42931. /**
  42932. * If delta time between frames should be constant
  42933. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42934. */
  42935. deterministicLockstep: boolean;
  42936. /**
  42937. * Maximum about of steps between frames (Default: 4)
  42938. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42939. */
  42940. lockstepMaxSteps: number;
  42941. }
  42942. /**
  42943. * The null engine class provides support for headless version of babylon.js.
  42944. * This can be used in server side scenario or for testing purposes
  42945. */
  42946. export class NullEngine extends Engine {
  42947. private _options;
  42948. /**
  42949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42950. */
  42951. isDeterministicLockStep(): boolean;
  42952. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42953. getLockstepMaxSteps(): number;
  42954. /**
  42955. * Sets hardware scaling, used to save performance if needed
  42956. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42957. */
  42958. getHardwareScalingLevel(): number;
  42959. constructor(options?: NullEngineOptions);
  42960. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42961. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42962. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42963. getRenderWidth(useScreen?: boolean): number;
  42964. getRenderHeight(useScreen?: boolean): number;
  42965. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42966. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42967. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42968. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42969. bindSamplers(effect: Effect): void;
  42970. enableEffect(effect: Effect): void;
  42971. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42972. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42973. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42974. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42975. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42976. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42977. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42978. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42979. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42980. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42981. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42982. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42983. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42984. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42985. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42986. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42987. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42988. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42989. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42990. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42991. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42992. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42993. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42994. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42995. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42996. bindBuffers(vertexBuffers: {
  42997. [key: string]: VertexBuffer;
  42998. }, indexBuffer: DataBuffer, effect: Effect): void;
  42999. wipeCaches(bruteForce?: boolean): void;
  43000. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43001. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43002. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43003. /** @hidden */
  43004. _createTexture(): WebGLTexture;
  43005. /** @hidden */
  43006. _releaseTexture(texture: InternalTexture): void;
  43007. 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;
  43008. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43009. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43010. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43011. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43012. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43013. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43014. areAllEffectsReady(): boolean;
  43015. /**
  43016. * @hidden
  43017. * Get the current error code of the webGL context
  43018. * @returns the error code
  43019. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43020. */
  43021. getError(): number;
  43022. /** @hidden */
  43023. _getUnpackAlignement(): number;
  43024. /** @hidden */
  43025. _unpackFlipY(value: boolean): void;
  43026. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43027. /**
  43028. * Updates a dynamic vertex buffer.
  43029. * @param vertexBuffer the vertex buffer to update
  43030. * @param data the data used to update the vertex buffer
  43031. * @param byteOffset the byte offset of the data (optional)
  43032. * @param byteLength the byte length of the data (optional)
  43033. */
  43034. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43035. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43036. /** @hidden */
  43037. _bindTexture(channel: number, texture: InternalTexture): void;
  43038. /** @hidden */
  43039. _releaseBuffer(buffer: DataBuffer): boolean;
  43040. releaseEffects(): void;
  43041. displayLoadingUI(): void;
  43042. hideLoadingUI(): void;
  43043. /** @hidden */
  43044. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43045. /** @hidden */
  43046. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43047. /** @hidden */
  43048. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43049. /** @hidden */
  43050. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43051. }
  43052. }
  43053. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43054. import { Nullable, int } from "babylonjs/types";
  43055. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43056. /** @hidden */
  43057. export class _OcclusionDataStorage {
  43058. /** @hidden */
  43059. occlusionInternalRetryCounter: number;
  43060. /** @hidden */
  43061. isOcclusionQueryInProgress: boolean;
  43062. /** @hidden */
  43063. isOccluded: boolean;
  43064. /** @hidden */
  43065. occlusionRetryCount: number;
  43066. /** @hidden */
  43067. occlusionType: number;
  43068. /** @hidden */
  43069. occlusionQueryAlgorithmType: number;
  43070. }
  43071. module "babylonjs/Engines/engine" {
  43072. interface Engine {
  43073. /**
  43074. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43075. * @return the new query
  43076. */
  43077. createQuery(): WebGLQuery;
  43078. /**
  43079. * Delete and release a webGL query
  43080. * @param query defines the query to delete
  43081. * @return the current engine
  43082. */
  43083. deleteQuery(query: WebGLQuery): Engine;
  43084. /**
  43085. * Check if a given query has resolved and got its value
  43086. * @param query defines the query to check
  43087. * @returns true if the query got its value
  43088. */
  43089. isQueryResultAvailable(query: WebGLQuery): boolean;
  43090. /**
  43091. * Gets the value of a given query
  43092. * @param query defines the query to check
  43093. * @returns the value of the query
  43094. */
  43095. getQueryResult(query: WebGLQuery): number;
  43096. /**
  43097. * Initiates an occlusion query
  43098. * @param algorithmType defines the algorithm to use
  43099. * @param query defines the query to use
  43100. * @returns the current engine
  43101. * @see http://doc.babylonjs.com/features/occlusionquery
  43102. */
  43103. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43104. /**
  43105. * Ends an occlusion query
  43106. * @see http://doc.babylonjs.com/features/occlusionquery
  43107. * @param algorithmType defines the algorithm to use
  43108. * @returns the current engine
  43109. */
  43110. endOcclusionQuery(algorithmType: number): Engine;
  43111. /**
  43112. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43113. * Please note that only one query can be issued at a time
  43114. * @returns a time token used to track the time span
  43115. */
  43116. startTimeQuery(): Nullable<_TimeToken>;
  43117. /**
  43118. * Ends a time query
  43119. * @param token defines the token used to measure the time span
  43120. * @returns the time spent (in ns)
  43121. */
  43122. endTimeQuery(token: _TimeToken): int;
  43123. /** @hidden */
  43124. _currentNonTimestampToken: Nullable<_TimeToken>;
  43125. /** @hidden */
  43126. _createTimeQuery(): WebGLQuery;
  43127. /** @hidden */
  43128. _deleteTimeQuery(query: WebGLQuery): void;
  43129. /** @hidden */
  43130. _getGlAlgorithmType(algorithmType: number): number;
  43131. /** @hidden */
  43132. _getTimeQueryResult(query: WebGLQuery): any;
  43133. /** @hidden */
  43134. _getTimeQueryAvailability(query: WebGLQuery): any;
  43135. }
  43136. }
  43137. module "babylonjs/Meshes/abstractMesh" {
  43138. interface AbstractMesh {
  43139. /**
  43140. * Backing filed
  43141. * @hidden
  43142. */
  43143. __occlusionDataStorage: _OcclusionDataStorage;
  43144. /**
  43145. * Access property
  43146. * @hidden
  43147. */
  43148. _occlusionDataStorage: _OcclusionDataStorage;
  43149. /**
  43150. * 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.
  43151. * The default value is -1 which means don't break the query and wait till the result
  43152. * @see http://doc.babylonjs.com/features/occlusionquery
  43153. */
  43154. occlusionRetryCount: number;
  43155. /**
  43156. * 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:
  43157. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43158. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43159. * * 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.
  43160. * @see http://doc.babylonjs.com/features/occlusionquery
  43161. */
  43162. occlusionType: number;
  43163. /**
  43164. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43165. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43166. * * 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.
  43167. * @see http://doc.babylonjs.com/features/occlusionquery
  43168. */
  43169. occlusionQueryAlgorithmType: number;
  43170. /**
  43171. * 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
  43172. * @see http://doc.babylonjs.com/features/occlusionquery
  43173. */
  43174. isOccluded: boolean;
  43175. /**
  43176. * Flag to check the progress status of the query
  43177. * @see http://doc.babylonjs.com/features/occlusionquery
  43178. */
  43179. isOcclusionQueryInProgress: boolean;
  43180. }
  43181. }
  43182. }
  43183. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43184. import { Nullable } from "babylonjs/types";
  43185. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43186. /** @hidden */
  43187. export var _forceTransformFeedbackToBundle: boolean;
  43188. module "babylonjs/Engines/engine" {
  43189. interface Engine {
  43190. /**
  43191. * Creates a webGL transform feedback object
  43192. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43193. * @returns the webGL transform feedback object
  43194. */
  43195. createTransformFeedback(): WebGLTransformFeedback;
  43196. /**
  43197. * Delete a webGL transform feedback object
  43198. * @param value defines the webGL transform feedback object to delete
  43199. */
  43200. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43201. /**
  43202. * Bind a webGL transform feedback object to the webgl context
  43203. * @param value defines the webGL transform feedback object to bind
  43204. */
  43205. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43206. /**
  43207. * Begins a transform feedback operation
  43208. * @param usePoints defines if points or triangles must be used
  43209. */
  43210. beginTransformFeedback(usePoints: boolean): void;
  43211. /**
  43212. * Ends a transform feedback operation
  43213. */
  43214. endTransformFeedback(): void;
  43215. /**
  43216. * Specify the varyings to use with transform feedback
  43217. * @param program defines the associated webGL program
  43218. * @param value defines the list of strings representing the varying names
  43219. */
  43220. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43221. /**
  43222. * Bind a webGL buffer for a transform feedback operation
  43223. * @param value defines the webGL buffer to bind
  43224. */
  43225. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43226. }
  43227. }
  43228. }
  43229. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43230. import { Scene } from "babylonjs/scene";
  43231. import { Engine } from "babylonjs/Engines/engine";
  43232. import { Texture } from "babylonjs/Materials/Textures/texture";
  43233. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43234. import "babylonjs/Engines/Extensions/engine.multiRender";
  43235. /**
  43236. * Creation options of the multi render target texture.
  43237. */
  43238. export interface IMultiRenderTargetOptions {
  43239. /**
  43240. * Define if the texture needs to create mip maps after render.
  43241. */
  43242. generateMipMaps?: boolean;
  43243. /**
  43244. * Define the types of all the draw buffers we want to create
  43245. */
  43246. types?: number[];
  43247. /**
  43248. * Define the sampling modes of all the draw buffers we want to create
  43249. */
  43250. samplingModes?: number[];
  43251. /**
  43252. * Define if a depth buffer is required
  43253. */
  43254. generateDepthBuffer?: boolean;
  43255. /**
  43256. * Define if a stencil buffer is required
  43257. */
  43258. generateStencilBuffer?: boolean;
  43259. /**
  43260. * Define if a depth texture is required instead of a depth buffer
  43261. */
  43262. generateDepthTexture?: boolean;
  43263. /**
  43264. * Define the number of desired draw buffers
  43265. */
  43266. textureCount?: number;
  43267. /**
  43268. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43269. */
  43270. doNotChangeAspectRatio?: boolean;
  43271. /**
  43272. * Define the default type of the buffers we are creating
  43273. */
  43274. defaultType?: number;
  43275. }
  43276. /**
  43277. * A multi render target, like a render target provides the ability to render to a texture.
  43278. * Unlike the render target, it can render to several draw buffers in one draw.
  43279. * This is specially interesting in deferred rendering or for any effects requiring more than
  43280. * just one color from a single pass.
  43281. */
  43282. export class MultiRenderTarget extends RenderTargetTexture {
  43283. private _internalTextures;
  43284. private _textures;
  43285. private _multiRenderTargetOptions;
  43286. /**
  43287. * Get if draw buffers are currently supported by the used hardware and browser.
  43288. */
  43289. readonly isSupported: boolean;
  43290. /**
  43291. * Get the list of textures generated by the multi render target.
  43292. */
  43293. readonly textures: Texture[];
  43294. /**
  43295. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43296. */
  43297. readonly depthTexture: Texture;
  43298. /**
  43299. * Set the wrapping mode on U of all the textures we are rendering to.
  43300. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43301. */
  43302. wrapU: number;
  43303. /**
  43304. * Set the wrapping mode on V of all the textures we are rendering to.
  43305. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43306. */
  43307. wrapV: number;
  43308. /**
  43309. * Instantiate a new multi render target texture.
  43310. * A multi render target, like a render target provides the ability to render to a texture.
  43311. * Unlike the render target, it can render to several draw buffers in one draw.
  43312. * This is specially interesting in deferred rendering or for any effects requiring more than
  43313. * just one color from a single pass.
  43314. * @param name Define the name of the texture
  43315. * @param size Define the size of the buffers to render to
  43316. * @param count Define the number of target we are rendering into
  43317. * @param scene Define the scene the texture belongs to
  43318. * @param options Define the options used to create the multi render target
  43319. */
  43320. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43321. /** @hidden */
  43322. _rebuild(): void;
  43323. private _createInternalTextures;
  43324. private _createTextures;
  43325. /**
  43326. * Define the number of samples used if MSAA is enabled.
  43327. */
  43328. samples: number;
  43329. /**
  43330. * Resize all the textures in the multi render target.
  43331. * Be carrefull as it will recreate all the data in the new texture.
  43332. * @param size Define the new size
  43333. */
  43334. resize(size: any): void;
  43335. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43336. /**
  43337. * Dispose the render targets and their associated resources
  43338. */
  43339. dispose(): void;
  43340. /**
  43341. * Release all the underlying texture used as draw buffers.
  43342. */
  43343. releaseInternalTextures(): void;
  43344. }
  43345. }
  43346. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43347. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43348. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43349. import { Nullable } from "babylonjs/types";
  43350. module "babylonjs/Engines/engine" {
  43351. interface Engine {
  43352. /**
  43353. * Unbind a list of render target textures from the webGL context
  43354. * This is used only when drawBuffer extension or webGL2 are active
  43355. * @param textures defines the render target textures to unbind
  43356. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43357. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43358. */
  43359. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43360. /**
  43361. * Create a multi render target texture
  43362. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43363. * @param size defines the size of the texture
  43364. * @param options defines the creation options
  43365. * @returns the cube texture as an InternalTexture
  43366. */
  43367. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43368. /**
  43369. * Update the sample count for a given multiple render target texture
  43370. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43371. * @param textures defines the textures to update
  43372. * @param samples defines the sample count to set
  43373. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43374. */
  43375. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43376. }
  43377. }
  43378. }
  43379. declare module "babylonjs/Engines/Extensions/index" {
  43380. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43381. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43382. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43383. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43384. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43385. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43386. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43387. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43388. }
  43389. declare module "babylonjs/Engines/index" {
  43390. export * from "babylonjs/Engines/constants";
  43391. export * from "babylonjs/Engines/engine";
  43392. export * from "babylonjs/Engines/engineStore";
  43393. export * from "babylonjs/Engines/nullEngine";
  43394. export * from "babylonjs/Engines/Extensions/index";
  43395. export * from "babylonjs/Engines/IPipelineContext";
  43396. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43397. }
  43398. declare module "babylonjs/Events/clipboardEvents" {
  43399. /**
  43400. * Gather the list of clipboard event types as constants.
  43401. */
  43402. export class ClipboardEventTypes {
  43403. /**
  43404. * The clipboard event is fired when a copy command is active (pressed).
  43405. */
  43406. static readonly COPY: number;
  43407. /**
  43408. * The clipboard event is fired when a cut command is active (pressed).
  43409. */
  43410. static readonly CUT: number;
  43411. /**
  43412. * The clipboard event is fired when a paste command is active (pressed).
  43413. */
  43414. static readonly PASTE: number;
  43415. }
  43416. /**
  43417. * This class is used to store clipboard related info for the onClipboardObservable event.
  43418. */
  43419. export class ClipboardInfo {
  43420. /**
  43421. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43422. */
  43423. type: number;
  43424. /**
  43425. * Defines the related dom event
  43426. */
  43427. event: ClipboardEvent;
  43428. /**
  43429. *Creates an instance of ClipboardInfo.
  43430. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43431. * @param event Defines the related dom event
  43432. */
  43433. constructor(
  43434. /**
  43435. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43436. */
  43437. type: number,
  43438. /**
  43439. * Defines the related dom event
  43440. */
  43441. event: ClipboardEvent);
  43442. /**
  43443. * Get the clipboard event's type from the keycode.
  43444. * @param keyCode Defines the keyCode for the current keyboard event.
  43445. * @return {number}
  43446. */
  43447. static GetTypeFromCharacter(keyCode: number): number;
  43448. }
  43449. }
  43450. declare module "babylonjs/Events/index" {
  43451. export * from "babylonjs/Events/keyboardEvents";
  43452. export * from "babylonjs/Events/pointerEvents";
  43453. export * from "babylonjs/Events/clipboardEvents";
  43454. }
  43455. declare module "babylonjs/Loading/sceneLoader" {
  43456. import { Observable } from "babylonjs/Misc/observable";
  43457. import { Nullable } from "babylonjs/types";
  43458. import { Scene } from "babylonjs/scene";
  43459. import { Engine } from "babylonjs/Engines/engine";
  43460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43461. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43462. import { AssetContainer } from "babylonjs/assetContainer";
  43463. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43464. import { Skeleton } from "babylonjs/Bones/skeleton";
  43465. /**
  43466. * Class used to represent data loading progression
  43467. */
  43468. export class SceneLoaderProgressEvent {
  43469. /** defines if data length to load can be evaluated */
  43470. readonly lengthComputable: boolean;
  43471. /** defines the loaded data length */
  43472. readonly loaded: number;
  43473. /** defines the data length to load */
  43474. readonly total: number;
  43475. /**
  43476. * Create a new progress event
  43477. * @param lengthComputable defines if data length to load can be evaluated
  43478. * @param loaded defines the loaded data length
  43479. * @param total defines the data length to load
  43480. */
  43481. constructor(
  43482. /** defines if data length to load can be evaluated */
  43483. lengthComputable: boolean,
  43484. /** defines the loaded data length */
  43485. loaded: number,
  43486. /** defines the data length to load */
  43487. total: number);
  43488. /**
  43489. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43490. * @param event defines the source event
  43491. * @returns a new SceneLoaderProgressEvent
  43492. */
  43493. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43494. }
  43495. /**
  43496. * Interface used by SceneLoader plugins to define supported file extensions
  43497. */
  43498. export interface ISceneLoaderPluginExtensions {
  43499. /**
  43500. * Defines the list of supported extensions
  43501. */
  43502. [extension: string]: {
  43503. isBinary: boolean;
  43504. };
  43505. }
  43506. /**
  43507. * Interface used by SceneLoader plugin factory
  43508. */
  43509. export interface ISceneLoaderPluginFactory {
  43510. /**
  43511. * Defines the name of the factory
  43512. */
  43513. name: string;
  43514. /**
  43515. * Function called to create a new plugin
  43516. * @return the new plugin
  43517. */
  43518. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43519. /**
  43520. * Boolean indicating if the plugin can direct load specific data
  43521. */
  43522. canDirectLoad?: (data: string) => boolean;
  43523. }
  43524. /**
  43525. * Interface used to define a SceneLoader plugin
  43526. */
  43527. export interface ISceneLoaderPlugin {
  43528. /**
  43529. * The friendly name of this plugin.
  43530. */
  43531. name: string;
  43532. /**
  43533. * The file extensions supported by this plugin.
  43534. */
  43535. extensions: string | ISceneLoaderPluginExtensions;
  43536. /**
  43537. * Import meshes into a scene.
  43538. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43539. * @param scene The scene to import into
  43540. * @param data The data to import
  43541. * @param rootUrl The root url for scene and resources
  43542. * @param meshes The meshes array to import into
  43543. * @param particleSystems The particle systems array to import into
  43544. * @param skeletons The skeletons array to import into
  43545. * @param onError The callback when import fails
  43546. * @returns True if successful or false otherwise
  43547. */
  43548. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43549. /**
  43550. * Load into a scene.
  43551. * @param scene The scene to load into
  43552. * @param data The data to import
  43553. * @param rootUrl The root url for scene and resources
  43554. * @param onError The callback when import fails
  43555. * @returns true if successful or false otherwise
  43556. */
  43557. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43558. /**
  43559. * The callback that returns true if the data can be directly loaded.
  43560. */
  43561. canDirectLoad?: (data: string) => boolean;
  43562. /**
  43563. * The callback that allows custom handling of the root url based on the response url.
  43564. */
  43565. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43566. /**
  43567. * Load into an asset container.
  43568. * @param scene The scene to load into
  43569. * @param data The data to import
  43570. * @param rootUrl The root url for scene and resources
  43571. * @param onError The callback when import fails
  43572. * @returns The loaded asset container
  43573. */
  43574. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43575. }
  43576. /**
  43577. * Interface used to define an async SceneLoader plugin
  43578. */
  43579. export interface ISceneLoaderPluginAsync {
  43580. /**
  43581. * The friendly name of this plugin.
  43582. */
  43583. name: string;
  43584. /**
  43585. * The file extensions supported by this plugin.
  43586. */
  43587. extensions: string | ISceneLoaderPluginExtensions;
  43588. /**
  43589. * Import meshes into a scene.
  43590. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43591. * @param scene The scene to import into
  43592. * @param data The data to import
  43593. * @param rootUrl The root url for scene and resources
  43594. * @param onProgress The callback when the load progresses
  43595. * @param fileName Defines the name of the file to load
  43596. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43597. */
  43598. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43599. meshes: AbstractMesh[];
  43600. particleSystems: IParticleSystem[];
  43601. skeletons: Skeleton[];
  43602. animationGroups: AnimationGroup[];
  43603. }>;
  43604. /**
  43605. * Load into a scene.
  43606. * @param scene The scene to load into
  43607. * @param data The data to import
  43608. * @param rootUrl The root url for scene and resources
  43609. * @param onProgress The callback when the load progresses
  43610. * @param fileName Defines the name of the file to load
  43611. * @returns Nothing
  43612. */
  43613. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43614. /**
  43615. * The callback that returns true if the data can be directly loaded.
  43616. */
  43617. canDirectLoad?: (data: string) => boolean;
  43618. /**
  43619. * The callback that allows custom handling of the root url based on the response url.
  43620. */
  43621. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43622. /**
  43623. * Load into an asset container.
  43624. * @param scene The scene to load into
  43625. * @param data The data to import
  43626. * @param rootUrl The root url for scene and resources
  43627. * @param onProgress The callback when the load progresses
  43628. * @param fileName Defines the name of the file to load
  43629. * @returns The loaded asset container
  43630. */
  43631. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43632. }
  43633. /**
  43634. * Class used to load scene from various file formats using registered plugins
  43635. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43636. */
  43637. export class SceneLoader {
  43638. /**
  43639. * No logging while loading
  43640. */
  43641. static readonly NO_LOGGING: number;
  43642. /**
  43643. * Minimal logging while loading
  43644. */
  43645. static readonly MINIMAL_LOGGING: number;
  43646. /**
  43647. * Summary logging while loading
  43648. */
  43649. static readonly SUMMARY_LOGGING: number;
  43650. /**
  43651. * Detailled logging while loading
  43652. */
  43653. static readonly DETAILED_LOGGING: number;
  43654. /**
  43655. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43656. */
  43657. static ForceFullSceneLoadingForIncremental: boolean;
  43658. /**
  43659. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43660. */
  43661. static ShowLoadingScreen: boolean;
  43662. /**
  43663. * Defines the current logging level (while loading the scene)
  43664. * @ignorenaming
  43665. */
  43666. static loggingLevel: number;
  43667. /**
  43668. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43669. */
  43670. static CleanBoneMatrixWeights: boolean;
  43671. /**
  43672. * Event raised when a plugin is used to load a scene
  43673. */
  43674. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43675. private static _registeredPlugins;
  43676. private static _getDefaultPlugin;
  43677. private static _getPluginForExtension;
  43678. private static _getPluginForDirectLoad;
  43679. private static _getPluginForFilename;
  43680. private static _getDirectLoad;
  43681. private static _loadData;
  43682. private static _getFileInfo;
  43683. /**
  43684. * Gets a plugin that can load the given extension
  43685. * @param extension defines the extension to load
  43686. * @returns a plugin or null if none works
  43687. */
  43688. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43689. /**
  43690. * Gets a boolean indicating that the given extension can be loaded
  43691. * @param extension defines the extension to load
  43692. * @returns true if the extension is supported
  43693. */
  43694. static IsPluginForExtensionAvailable(extension: string): boolean;
  43695. /**
  43696. * Adds a new plugin to the list of registered plugins
  43697. * @param plugin defines the plugin to add
  43698. */
  43699. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43700. /**
  43701. * Import meshes into a scene
  43702. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43703. * @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)
  43704. * @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)
  43705. * @param scene the instance of BABYLON.Scene to append to
  43706. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43707. * @param onProgress a callback with a progress event for each file being loaded
  43708. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43709. * @param pluginExtension the extension used to determine the plugin
  43710. * @returns The loaded plugin
  43711. */
  43712. 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>;
  43713. /**
  43714. * Import meshes into a scene
  43715. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43716. * @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)
  43717. * @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)
  43718. * @param scene the instance of BABYLON.Scene to append to
  43719. * @param onProgress a callback with a progress event for each file being loaded
  43720. * @param pluginExtension the extension used to determine the plugin
  43721. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43722. */
  43723. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43724. meshes: AbstractMesh[];
  43725. particleSystems: IParticleSystem[];
  43726. skeletons: Skeleton[];
  43727. animationGroups: AnimationGroup[];
  43728. }>;
  43729. /**
  43730. * Load a scene
  43731. * @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)
  43732. * @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)
  43733. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43734. * @param onSuccess a callback with the scene when import succeeds
  43735. * @param onProgress a callback with a progress event for each file being loaded
  43736. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43737. * @param pluginExtension the extension used to determine the plugin
  43738. * @returns The loaded plugin
  43739. */
  43740. 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>;
  43741. /**
  43742. * Load a scene
  43743. * @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)
  43744. * @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)
  43745. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43746. * @param onProgress a callback with a progress event for each file being loaded
  43747. * @param pluginExtension the extension used to determine the plugin
  43748. * @returns The loaded scene
  43749. */
  43750. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43751. /**
  43752. * Append a scene
  43753. * @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)
  43754. * @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)
  43755. * @param scene is the instance of BABYLON.Scene to append to
  43756. * @param onSuccess a callback with the scene when import succeeds
  43757. * @param onProgress a callback with a progress event for each file being loaded
  43758. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43759. * @param pluginExtension the extension used to determine the plugin
  43760. * @returns The loaded plugin
  43761. */
  43762. 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>;
  43763. /**
  43764. * Append a scene
  43765. * @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)
  43766. * @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)
  43767. * @param scene is the instance of BABYLON.Scene to append to
  43768. * @param onProgress a callback with a progress event for each file being loaded
  43769. * @param pluginExtension the extension used to determine the plugin
  43770. * @returns The given scene
  43771. */
  43772. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43773. /**
  43774. * Load a scene into an asset container
  43775. * @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)
  43776. * @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)
  43777. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43778. * @param onSuccess a callback with the scene when import succeeds
  43779. * @param onProgress a callback with a progress event for each file being loaded
  43780. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43781. * @param pluginExtension the extension used to determine the plugin
  43782. * @returns The loaded plugin
  43783. */
  43784. 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>;
  43785. /**
  43786. * Load a scene into an asset container
  43787. * @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)
  43788. * @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)
  43789. * @param scene is the instance of Scene to append to
  43790. * @param onProgress a callback with a progress event for each file being loaded
  43791. * @param pluginExtension the extension used to determine the plugin
  43792. * @returns The loaded asset container
  43793. */
  43794. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43795. }
  43796. }
  43797. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43798. import { Scene } from "babylonjs/scene";
  43799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43800. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43801. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43802. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43803. /**
  43804. * Google Daydream controller
  43805. */
  43806. export class DaydreamController extends WebVRController {
  43807. /**
  43808. * Base Url for the controller model.
  43809. */
  43810. static MODEL_BASE_URL: string;
  43811. /**
  43812. * File name for the controller model.
  43813. */
  43814. static MODEL_FILENAME: string;
  43815. /**
  43816. * Gamepad Id prefix used to identify Daydream Controller.
  43817. */
  43818. static readonly GAMEPAD_ID_PREFIX: string;
  43819. /**
  43820. * Creates a new DaydreamController from a gamepad
  43821. * @param vrGamepad the gamepad that the controller should be created from
  43822. */
  43823. constructor(vrGamepad: any);
  43824. /**
  43825. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43826. * @param scene scene in which to add meshes
  43827. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43828. */
  43829. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43830. /**
  43831. * Called once for each button that changed state since the last frame
  43832. * @param buttonIdx Which button index changed
  43833. * @param state New state of the button
  43834. * @param changes Which properties on the state changed since last frame
  43835. */
  43836. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43837. }
  43838. }
  43839. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43840. import { Scene } from "babylonjs/scene";
  43841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43842. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43843. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43844. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43845. /**
  43846. * Gear VR Controller
  43847. */
  43848. export class GearVRController extends WebVRController {
  43849. /**
  43850. * Base Url for the controller model.
  43851. */
  43852. static MODEL_BASE_URL: string;
  43853. /**
  43854. * File name for the controller model.
  43855. */
  43856. static MODEL_FILENAME: string;
  43857. /**
  43858. * Gamepad Id prefix used to identify this controller.
  43859. */
  43860. static readonly GAMEPAD_ID_PREFIX: string;
  43861. private readonly _buttonIndexToObservableNameMap;
  43862. /**
  43863. * Creates a new GearVRController from a gamepad
  43864. * @param vrGamepad the gamepad that the controller should be created from
  43865. */
  43866. constructor(vrGamepad: any);
  43867. /**
  43868. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43869. * @param scene scene in which to add meshes
  43870. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43871. */
  43872. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43873. /**
  43874. * Called once for each button that changed state since the last frame
  43875. * @param buttonIdx Which button index changed
  43876. * @param state New state of the button
  43877. * @param changes Which properties on the state changed since last frame
  43878. */
  43879. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43880. }
  43881. }
  43882. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43883. import { Scene } from "babylonjs/scene";
  43884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43885. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43886. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43887. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43888. /**
  43889. * Generic Controller
  43890. */
  43891. export class GenericController extends WebVRController {
  43892. /**
  43893. * Base Url for the controller model.
  43894. */
  43895. static readonly MODEL_BASE_URL: string;
  43896. /**
  43897. * File name for the controller model.
  43898. */
  43899. static readonly MODEL_FILENAME: string;
  43900. /**
  43901. * Creates a new GenericController from a gamepad
  43902. * @param vrGamepad the gamepad that the controller should be created from
  43903. */
  43904. constructor(vrGamepad: any);
  43905. /**
  43906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43907. * @param scene scene in which to add meshes
  43908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43909. */
  43910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43911. /**
  43912. * Called once for each button that changed state since the last frame
  43913. * @param buttonIdx Which button index changed
  43914. * @param state New state of the button
  43915. * @param changes Which properties on the state changed since last frame
  43916. */
  43917. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43918. }
  43919. }
  43920. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43921. import { Observable } from "babylonjs/Misc/observable";
  43922. import { Scene } from "babylonjs/scene";
  43923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43924. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43925. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43926. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43927. /**
  43928. * Oculus Touch Controller
  43929. */
  43930. export class OculusTouchController extends WebVRController {
  43931. /**
  43932. * Base Url for the controller model.
  43933. */
  43934. static MODEL_BASE_URL: string;
  43935. /**
  43936. * File name for the left controller model.
  43937. */
  43938. static MODEL_LEFT_FILENAME: string;
  43939. /**
  43940. * File name for the right controller model.
  43941. */
  43942. static MODEL_RIGHT_FILENAME: string;
  43943. /**
  43944. * Fired when the secondary trigger on this controller is modified
  43945. */
  43946. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43947. /**
  43948. * Fired when the thumb rest on this controller is modified
  43949. */
  43950. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43951. /**
  43952. * Creates a new OculusTouchController from a gamepad
  43953. * @param vrGamepad the gamepad that the controller should be created from
  43954. */
  43955. constructor(vrGamepad: any);
  43956. /**
  43957. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43958. * @param scene scene in which to add meshes
  43959. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43960. */
  43961. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43962. /**
  43963. * Fired when the A button on this controller is modified
  43964. */
  43965. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43966. /**
  43967. * Fired when the B button on this controller is modified
  43968. */
  43969. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43970. /**
  43971. * Fired when the X button on this controller is modified
  43972. */
  43973. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43974. /**
  43975. * Fired when the Y button on this controller is modified
  43976. */
  43977. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43978. /**
  43979. * Called once for each button that changed state since the last frame
  43980. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43981. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43982. * 2) secondary trigger (same)
  43983. * 3) A (right) X (left), touch, pressed = value
  43984. * 4) B / Y
  43985. * 5) thumb rest
  43986. * @param buttonIdx Which button index changed
  43987. * @param state New state of the button
  43988. * @param changes Which properties on the state changed since last frame
  43989. */
  43990. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43991. }
  43992. }
  43993. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43994. import { Scene } from "babylonjs/scene";
  43995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43996. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43997. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43998. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43999. import { Observable } from "babylonjs/Misc/observable";
  44000. /**
  44001. * Vive Controller
  44002. */
  44003. export class ViveController extends WebVRController {
  44004. /**
  44005. * Base Url for the controller model.
  44006. */
  44007. static MODEL_BASE_URL: string;
  44008. /**
  44009. * File name for the controller model.
  44010. */
  44011. static MODEL_FILENAME: string;
  44012. /**
  44013. * Creates a new ViveController from a gamepad
  44014. * @param vrGamepad the gamepad that the controller should be created from
  44015. */
  44016. constructor(vrGamepad: any);
  44017. /**
  44018. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44019. * @param scene scene in which to add meshes
  44020. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44021. */
  44022. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44023. /**
  44024. * Fired when the left button on this controller is modified
  44025. */
  44026. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44027. /**
  44028. * Fired when the right button on this controller is modified
  44029. */
  44030. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44031. /**
  44032. * Fired when the menu button on this controller is modified
  44033. */
  44034. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44035. /**
  44036. * Called once for each button that changed state since the last frame
  44037. * Vive mapping:
  44038. * 0: touchpad
  44039. * 1: trigger
  44040. * 2: left AND right buttons
  44041. * 3: menu button
  44042. * @param buttonIdx Which button index changed
  44043. * @param state New state of the button
  44044. * @param changes Which properties on the state changed since last frame
  44045. */
  44046. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44047. }
  44048. }
  44049. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44050. import { Observable } from "babylonjs/Misc/observable";
  44051. import { Scene } from "babylonjs/scene";
  44052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44053. import { Ray } from "babylonjs/Culling/ray";
  44054. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44055. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44056. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44057. /**
  44058. * Defines the WindowsMotionController object that the state of the windows motion controller
  44059. */
  44060. export class WindowsMotionController extends WebVRController {
  44061. /**
  44062. * The base url used to load the left and right controller models
  44063. */
  44064. static MODEL_BASE_URL: string;
  44065. /**
  44066. * The name of the left controller model file
  44067. */
  44068. static MODEL_LEFT_FILENAME: string;
  44069. /**
  44070. * The name of the right controller model file
  44071. */
  44072. static MODEL_RIGHT_FILENAME: string;
  44073. /**
  44074. * The controller name prefix for this controller type
  44075. */
  44076. static readonly GAMEPAD_ID_PREFIX: string;
  44077. /**
  44078. * The controller id pattern for this controller type
  44079. */
  44080. private static readonly GAMEPAD_ID_PATTERN;
  44081. private _loadedMeshInfo;
  44082. private readonly _mapping;
  44083. /**
  44084. * Fired when the trackpad on this controller is clicked
  44085. */
  44086. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44087. /**
  44088. * Fired when the trackpad on this controller is modified
  44089. */
  44090. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44091. /**
  44092. * The current x and y values of this controller's trackpad
  44093. */
  44094. trackpad: StickValues;
  44095. /**
  44096. * Creates a new WindowsMotionController from a gamepad
  44097. * @param vrGamepad the gamepad that the controller should be created from
  44098. */
  44099. constructor(vrGamepad: any);
  44100. /**
  44101. * Fired when the trigger on this controller is modified
  44102. */
  44103. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44104. /**
  44105. * Fired when the menu button on this controller is modified
  44106. */
  44107. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44108. /**
  44109. * Fired when the grip button on this controller is modified
  44110. */
  44111. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44112. /**
  44113. * Fired when the thumbstick button on this controller is modified
  44114. */
  44115. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44116. /**
  44117. * Fired when the touchpad button on this controller is modified
  44118. */
  44119. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44120. /**
  44121. * Fired when the touchpad values on this controller are modified
  44122. */
  44123. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44124. private _updateTrackpad;
  44125. /**
  44126. * Called once per frame by the engine.
  44127. */
  44128. update(): void;
  44129. /**
  44130. * Called once for each button that changed state since the last frame
  44131. * @param buttonIdx Which button index changed
  44132. * @param state New state of the button
  44133. * @param changes Which properties on the state changed since last frame
  44134. */
  44135. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44136. /**
  44137. * Moves the buttons on the controller mesh based on their current state
  44138. * @param buttonName the name of the button to move
  44139. * @param buttonValue the value of the button which determines the buttons new position
  44140. */
  44141. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44142. /**
  44143. * Moves the axis on the controller mesh based on its current state
  44144. * @param axis the index of the axis
  44145. * @param axisValue the value of the axis which determines the meshes new position
  44146. * @hidden
  44147. */
  44148. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44149. /**
  44150. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44151. * @param scene scene in which to add meshes
  44152. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44153. */
  44154. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44155. /**
  44156. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44157. * can be transformed by button presses and axes values, based on this._mapping.
  44158. *
  44159. * @param scene scene in which the meshes exist
  44160. * @param meshes list of meshes that make up the controller model to process
  44161. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44162. */
  44163. private processModel;
  44164. private createMeshInfo;
  44165. /**
  44166. * Gets the ray of the controller in the direction the controller is pointing
  44167. * @param length the length the resulting ray should be
  44168. * @returns a ray in the direction the controller is pointing
  44169. */
  44170. getForwardRay(length?: number): Ray;
  44171. /**
  44172. * Disposes of the controller
  44173. */
  44174. dispose(): void;
  44175. }
  44176. }
  44177. declare module "babylonjs/Gamepads/Controllers/index" {
  44178. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44179. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44180. export * from "babylonjs/Gamepads/Controllers/genericController";
  44181. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44182. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44183. export * from "babylonjs/Gamepads/Controllers/viveController";
  44184. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44185. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44186. }
  44187. declare module "babylonjs/Gamepads/index" {
  44188. export * from "babylonjs/Gamepads/Controllers/index";
  44189. export * from "babylonjs/Gamepads/gamepad";
  44190. export * from "babylonjs/Gamepads/gamepadManager";
  44191. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44192. export * from "babylonjs/Gamepads/xboxGamepad";
  44193. }
  44194. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44195. import { Observable } from "babylonjs/Misc/observable";
  44196. import { Nullable } from "babylonjs/types";
  44197. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44199. import { Mesh } from "babylonjs/Meshes/mesh";
  44200. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44201. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44202. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44203. /**
  44204. * Single axis scale gizmo
  44205. */
  44206. export class AxisScaleGizmo extends Gizmo {
  44207. private _coloredMaterial;
  44208. /**
  44209. * Drag behavior responsible for the gizmos dragging interactions
  44210. */
  44211. dragBehavior: PointerDragBehavior;
  44212. private _pointerObserver;
  44213. /**
  44214. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44215. */
  44216. snapDistance: number;
  44217. /**
  44218. * Event that fires each time the gizmo snaps to a new location.
  44219. * * snapDistance is the the change in distance
  44220. */
  44221. onSnapObservable: Observable<{
  44222. snapDistance: number;
  44223. }>;
  44224. /**
  44225. * If the scaling operation should be done on all axis (default: false)
  44226. */
  44227. uniformScaling: boolean;
  44228. /**
  44229. * Creates an AxisScaleGizmo
  44230. * @param gizmoLayer The utility layer the gizmo will be added to
  44231. * @param dragAxis The axis which the gizmo will be able to scale on
  44232. * @param color The color of the gizmo
  44233. */
  44234. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44235. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44236. /**
  44237. * Disposes of the gizmo
  44238. */
  44239. dispose(): void;
  44240. /**
  44241. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44242. * @param mesh The mesh to replace the default mesh of the gizmo
  44243. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44244. */
  44245. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44246. }
  44247. }
  44248. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44249. import { Observable } from "babylonjs/Misc/observable";
  44250. import { Nullable } from "babylonjs/types";
  44251. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44253. import { Mesh } from "babylonjs/Meshes/mesh";
  44254. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44255. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44256. import "babylonjs/Meshes/Builders/boxBuilder";
  44257. /**
  44258. * Bounding box gizmo
  44259. */
  44260. export class BoundingBoxGizmo extends Gizmo {
  44261. private _lineBoundingBox;
  44262. private _rotateSpheresParent;
  44263. private _scaleBoxesParent;
  44264. private _boundingDimensions;
  44265. private _renderObserver;
  44266. private _pointerObserver;
  44267. private _scaleDragSpeed;
  44268. private _tmpQuaternion;
  44269. private _tmpVector;
  44270. private _tmpRotationMatrix;
  44271. /**
  44272. * 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)
  44273. */
  44274. ignoreChildren: boolean;
  44275. /**
  44276. * 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)
  44277. */
  44278. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44279. /**
  44280. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44281. */
  44282. rotationSphereSize: number;
  44283. /**
  44284. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44285. */
  44286. scaleBoxSize: number;
  44287. /**
  44288. * 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)
  44289. */
  44290. fixedDragMeshScreenSize: boolean;
  44291. /**
  44292. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44293. */
  44294. fixedDragMeshScreenSizeDistanceFactor: number;
  44295. /**
  44296. * Fired when a rotation sphere or scale box is dragged
  44297. */
  44298. onDragStartObservable: Observable<{}>;
  44299. /**
  44300. * Fired when a scale box is dragged
  44301. */
  44302. onScaleBoxDragObservable: Observable<{}>;
  44303. /**
  44304. * Fired when a scale box drag is ended
  44305. */
  44306. onScaleBoxDragEndObservable: Observable<{}>;
  44307. /**
  44308. * Fired when a rotation sphere is dragged
  44309. */
  44310. onRotationSphereDragObservable: Observable<{}>;
  44311. /**
  44312. * Fired when a rotation sphere drag is ended
  44313. */
  44314. onRotationSphereDragEndObservable: Observable<{}>;
  44315. /**
  44316. * 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)
  44317. */
  44318. scalePivot: Nullable<Vector3>;
  44319. /**
  44320. * Mesh used as a pivot to rotate the attached mesh
  44321. */
  44322. private _anchorMesh;
  44323. private _existingMeshScale;
  44324. private _dragMesh;
  44325. private pointerDragBehavior;
  44326. private coloredMaterial;
  44327. private hoverColoredMaterial;
  44328. /**
  44329. * Sets the color of the bounding box gizmo
  44330. * @param color the color to set
  44331. */
  44332. setColor(color: Color3): void;
  44333. /**
  44334. * Creates an BoundingBoxGizmo
  44335. * @param gizmoLayer The utility layer the gizmo will be added to
  44336. * @param color The color of the gizmo
  44337. */
  44338. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44339. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44340. private _selectNode;
  44341. /**
  44342. * Updates the bounding box information for the Gizmo
  44343. */
  44344. updateBoundingBox(): void;
  44345. private _updateRotationSpheres;
  44346. private _updateScaleBoxes;
  44347. /**
  44348. * Enables rotation on the specified axis and disables rotation on the others
  44349. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44350. */
  44351. setEnabledRotationAxis(axis: string): void;
  44352. /**
  44353. * Enables/disables scaling
  44354. * @param enable if scaling should be enabled
  44355. */
  44356. setEnabledScaling(enable: boolean): void;
  44357. private _updateDummy;
  44358. /**
  44359. * Enables a pointer drag behavior on the bounding box of the gizmo
  44360. */
  44361. enableDragBehavior(): void;
  44362. /**
  44363. * Disposes of the gizmo
  44364. */
  44365. dispose(): void;
  44366. /**
  44367. * 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)
  44368. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44369. * @returns the bounding box mesh with the passed in mesh as a child
  44370. */
  44371. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44372. /**
  44373. * CustomMeshes are not supported by this gizmo
  44374. * @param mesh The mesh to replace the default mesh of the gizmo
  44375. */
  44376. setCustomMesh(mesh: Mesh): void;
  44377. }
  44378. }
  44379. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44380. import { Observable } from "babylonjs/Misc/observable";
  44381. import { Nullable } from "babylonjs/types";
  44382. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44384. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44385. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44386. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44387. import "babylonjs/Meshes/Builders/linesBuilder";
  44388. /**
  44389. * Single plane rotation gizmo
  44390. */
  44391. export class PlaneRotationGizmo extends Gizmo {
  44392. /**
  44393. * Drag behavior responsible for the gizmos dragging interactions
  44394. */
  44395. dragBehavior: PointerDragBehavior;
  44396. private _pointerObserver;
  44397. /**
  44398. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44399. */
  44400. snapDistance: number;
  44401. /**
  44402. * Event that fires each time the gizmo snaps to a new location.
  44403. * * snapDistance is the the change in distance
  44404. */
  44405. onSnapObservable: Observable<{
  44406. snapDistance: number;
  44407. }>;
  44408. /**
  44409. * Creates a PlaneRotationGizmo
  44410. * @param gizmoLayer The utility layer the gizmo will be added to
  44411. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44412. * @param color The color of the gizmo
  44413. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44414. */
  44415. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44416. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44417. /**
  44418. * Disposes of the gizmo
  44419. */
  44420. dispose(): void;
  44421. }
  44422. }
  44423. declare module "babylonjs/Gizmos/rotationGizmo" {
  44424. import { Observable } from "babylonjs/Misc/observable";
  44425. import { Nullable } from "babylonjs/types";
  44426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44427. import { Mesh } from "babylonjs/Meshes/mesh";
  44428. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44429. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44430. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44431. /**
  44432. * Gizmo that enables rotating a mesh along 3 axis
  44433. */
  44434. export class RotationGizmo extends Gizmo {
  44435. /**
  44436. * Internal gizmo used for interactions on the x axis
  44437. */
  44438. xGizmo: PlaneRotationGizmo;
  44439. /**
  44440. * Internal gizmo used for interactions on the y axis
  44441. */
  44442. yGizmo: PlaneRotationGizmo;
  44443. /**
  44444. * Internal gizmo used for interactions on the z axis
  44445. */
  44446. zGizmo: PlaneRotationGizmo;
  44447. /** Fires an event when any of it's sub gizmos are dragged */
  44448. onDragStartObservable: Observable<{}>;
  44449. /** Fires an event when any of it's sub gizmos are released from dragging */
  44450. onDragEndObservable: Observable<{}>;
  44451. attachedMesh: Nullable<AbstractMesh>;
  44452. /**
  44453. * Creates a RotationGizmo
  44454. * @param gizmoLayer The utility layer the gizmo will be added to
  44455. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44456. */
  44457. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44458. updateGizmoRotationToMatchAttachedMesh: boolean;
  44459. /**
  44460. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44461. */
  44462. snapDistance: number;
  44463. /**
  44464. * Ratio for the scale of the gizmo (Default: 1)
  44465. */
  44466. scaleRatio: number;
  44467. /**
  44468. * Disposes of the gizmo
  44469. */
  44470. dispose(): void;
  44471. /**
  44472. * CustomMeshes are not supported by this gizmo
  44473. * @param mesh The mesh to replace the default mesh of the gizmo
  44474. */
  44475. setCustomMesh(mesh: Mesh): void;
  44476. }
  44477. }
  44478. declare module "babylonjs/Gizmos/positionGizmo" {
  44479. import { Observable } from "babylonjs/Misc/observable";
  44480. import { Nullable } from "babylonjs/types";
  44481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44482. import { Mesh } from "babylonjs/Meshes/mesh";
  44483. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44484. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44485. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44486. /**
  44487. * Gizmo that enables dragging a mesh along 3 axis
  44488. */
  44489. export class PositionGizmo extends Gizmo {
  44490. /**
  44491. * Internal gizmo used for interactions on the x axis
  44492. */
  44493. xGizmo: AxisDragGizmo;
  44494. /**
  44495. * Internal gizmo used for interactions on the y axis
  44496. */
  44497. yGizmo: AxisDragGizmo;
  44498. /**
  44499. * Internal gizmo used for interactions on the z axis
  44500. */
  44501. zGizmo: AxisDragGizmo;
  44502. /** Fires an event when any of it's sub gizmos are dragged */
  44503. onDragStartObservable: Observable<{}>;
  44504. /** Fires an event when any of it's sub gizmos are released from dragging */
  44505. onDragEndObservable: Observable<{}>;
  44506. attachedMesh: Nullable<AbstractMesh>;
  44507. /**
  44508. * Creates a PositionGizmo
  44509. * @param gizmoLayer The utility layer the gizmo will be added to
  44510. */
  44511. constructor(gizmoLayer?: UtilityLayerRenderer);
  44512. updateGizmoRotationToMatchAttachedMesh: boolean;
  44513. /**
  44514. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44515. */
  44516. snapDistance: number;
  44517. /**
  44518. * Ratio for the scale of the gizmo (Default: 1)
  44519. */
  44520. scaleRatio: number;
  44521. /**
  44522. * Disposes of the gizmo
  44523. */
  44524. dispose(): void;
  44525. /**
  44526. * CustomMeshes are not supported by this gizmo
  44527. * @param mesh The mesh to replace the default mesh of the gizmo
  44528. */
  44529. setCustomMesh(mesh: Mesh): void;
  44530. }
  44531. }
  44532. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44533. import { Scene } from "babylonjs/scene";
  44534. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44535. import { Mesh } from "babylonjs/Meshes/mesh";
  44536. import { Nullable } from "babylonjs/types";
  44537. /**
  44538. * Class containing static functions to help procedurally build meshes
  44539. */
  44540. export class PolyhedronBuilder {
  44541. /**
  44542. * Creates a polyhedron mesh
  44543. * * 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
  44544. * * The parameter `size` (positive float, default 1) sets the polygon size
  44545. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44546. * * 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`
  44547. * * 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
  44548. * * 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)`)
  44549. * * 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
  44550. * * 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
  44551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44554. * @param name defines the name of the mesh
  44555. * @param options defines the options used to create the mesh
  44556. * @param scene defines the hosting scene
  44557. * @returns the polyhedron mesh
  44558. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44559. */
  44560. static CreatePolyhedron(name: string, options: {
  44561. type?: number;
  44562. size?: number;
  44563. sizeX?: number;
  44564. sizeY?: number;
  44565. sizeZ?: number;
  44566. custom?: any;
  44567. faceUV?: Vector4[];
  44568. faceColors?: Color4[];
  44569. flat?: boolean;
  44570. updatable?: boolean;
  44571. sideOrientation?: number;
  44572. frontUVs?: Vector4;
  44573. backUVs?: Vector4;
  44574. }, scene?: Nullable<Scene>): Mesh;
  44575. }
  44576. }
  44577. declare module "babylonjs/Gizmos/scaleGizmo" {
  44578. import { Observable } from "babylonjs/Misc/observable";
  44579. import { Nullable } from "babylonjs/types";
  44580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44581. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44582. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44583. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44584. /**
  44585. * Gizmo that enables scaling a mesh along 3 axis
  44586. */
  44587. export class ScaleGizmo extends Gizmo {
  44588. /**
  44589. * Internal gizmo used for interactions on the x axis
  44590. */
  44591. xGizmo: AxisScaleGizmo;
  44592. /**
  44593. * Internal gizmo used for interactions on the y axis
  44594. */
  44595. yGizmo: AxisScaleGizmo;
  44596. /**
  44597. * Internal gizmo used for interactions on the z axis
  44598. */
  44599. zGizmo: AxisScaleGizmo;
  44600. /**
  44601. * Internal gizmo used to scale all axis equally
  44602. */
  44603. uniformScaleGizmo: AxisScaleGizmo;
  44604. /** Fires an event when any of it's sub gizmos are dragged */
  44605. onDragStartObservable: Observable<{}>;
  44606. /** Fires an event when any of it's sub gizmos are released from dragging */
  44607. onDragEndObservable: Observable<{}>;
  44608. attachedMesh: Nullable<AbstractMesh>;
  44609. /**
  44610. * Creates a ScaleGizmo
  44611. * @param gizmoLayer The utility layer the gizmo will be added to
  44612. */
  44613. constructor(gizmoLayer?: UtilityLayerRenderer);
  44614. updateGizmoRotationToMatchAttachedMesh: boolean;
  44615. /**
  44616. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44617. */
  44618. snapDistance: number;
  44619. /**
  44620. * Ratio for the scale of the gizmo (Default: 1)
  44621. */
  44622. scaleRatio: number;
  44623. /**
  44624. * Disposes of the gizmo
  44625. */
  44626. dispose(): void;
  44627. }
  44628. }
  44629. declare module "babylonjs/Gizmos/gizmoManager" {
  44630. import { Observable } from "babylonjs/Misc/observable";
  44631. import { Nullable } from "babylonjs/types";
  44632. import { Scene, IDisposable } from "babylonjs/scene";
  44633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44634. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44635. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44636. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44637. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44638. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44639. /**
  44640. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44641. */
  44642. export class GizmoManager implements IDisposable {
  44643. private scene;
  44644. /**
  44645. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44646. */
  44647. gizmos: {
  44648. positionGizmo: Nullable<PositionGizmo>;
  44649. rotationGizmo: Nullable<RotationGizmo>;
  44650. scaleGizmo: Nullable<ScaleGizmo>;
  44651. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44652. };
  44653. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44654. clearGizmoOnEmptyPointerEvent: boolean;
  44655. /** Fires an event when the manager is attached to a mesh */
  44656. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44657. private _gizmosEnabled;
  44658. private _pointerObserver;
  44659. private _attachedMesh;
  44660. private _boundingBoxColor;
  44661. private _defaultUtilityLayer;
  44662. private _defaultKeepDepthUtilityLayer;
  44663. /**
  44664. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44665. */
  44666. boundingBoxDragBehavior: SixDofDragBehavior;
  44667. /**
  44668. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44669. */
  44670. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44671. /**
  44672. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44673. */
  44674. usePointerToAttachGizmos: boolean;
  44675. /**
  44676. * Instatiates a gizmo manager
  44677. * @param scene the scene to overlay the gizmos on top of
  44678. */
  44679. constructor(scene: Scene);
  44680. /**
  44681. * Attaches a set of gizmos to the specified mesh
  44682. * @param mesh The mesh the gizmo's should be attached to
  44683. */
  44684. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44685. /**
  44686. * If the position gizmo is enabled
  44687. */
  44688. positionGizmoEnabled: boolean;
  44689. /**
  44690. * If the rotation gizmo is enabled
  44691. */
  44692. rotationGizmoEnabled: boolean;
  44693. /**
  44694. * If the scale gizmo is enabled
  44695. */
  44696. scaleGizmoEnabled: boolean;
  44697. /**
  44698. * If the boundingBox gizmo is enabled
  44699. */
  44700. boundingBoxGizmoEnabled: boolean;
  44701. /**
  44702. * Disposes of the gizmo manager
  44703. */
  44704. dispose(): void;
  44705. }
  44706. }
  44707. declare module "babylonjs/Lights/directionalLight" {
  44708. import { Camera } from "babylonjs/Cameras/camera";
  44709. import { Scene } from "babylonjs/scene";
  44710. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44712. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44713. import { Effect } from "babylonjs/Materials/effect";
  44714. /**
  44715. * A directional light is defined by a direction (what a surprise!).
  44716. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44717. * 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.
  44718. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44719. */
  44720. export class DirectionalLight extends ShadowLight {
  44721. private _shadowFrustumSize;
  44722. /**
  44723. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44724. */
  44725. /**
  44726. * Specifies a fix frustum size for the shadow generation.
  44727. */
  44728. shadowFrustumSize: number;
  44729. private _shadowOrthoScale;
  44730. /**
  44731. * Gets the shadow projection scale against the optimal computed one.
  44732. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44733. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44734. */
  44735. /**
  44736. * Sets the shadow projection scale against the optimal computed one.
  44737. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44738. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44739. */
  44740. shadowOrthoScale: number;
  44741. /**
  44742. * Automatically compute the projection matrix to best fit (including all the casters)
  44743. * on each frame.
  44744. */
  44745. autoUpdateExtends: boolean;
  44746. private _orthoLeft;
  44747. private _orthoRight;
  44748. private _orthoTop;
  44749. private _orthoBottom;
  44750. /**
  44751. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44752. * The directional light is emitted from everywhere in the given direction.
  44753. * It can cast shadows.
  44754. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44755. * @param name The friendly name of the light
  44756. * @param direction The direction of the light
  44757. * @param scene The scene the light belongs to
  44758. */
  44759. constructor(name: string, direction: Vector3, scene: Scene);
  44760. /**
  44761. * Returns the string "DirectionalLight".
  44762. * @return The class name
  44763. */
  44764. getClassName(): string;
  44765. /**
  44766. * Returns the integer 1.
  44767. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44768. */
  44769. getTypeID(): number;
  44770. /**
  44771. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44772. * Returns the DirectionalLight Shadow projection matrix.
  44773. */
  44774. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44775. /**
  44776. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44777. * Returns the DirectionalLight Shadow projection matrix.
  44778. */
  44779. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44780. /**
  44781. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44782. * Returns the DirectionalLight Shadow projection matrix.
  44783. */
  44784. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44785. protected _buildUniformLayout(): void;
  44786. /**
  44787. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44788. * @param effect The effect to update
  44789. * @param lightIndex The index of the light in the effect to update
  44790. * @returns The directional light
  44791. */
  44792. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44793. /**
  44794. * Gets the minZ used for shadow according to both the scene and the light.
  44795. *
  44796. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44797. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44798. * @param activeCamera The camera we are returning the min for
  44799. * @returns the depth min z
  44800. */
  44801. getDepthMinZ(activeCamera: Camera): number;
  44802. /**
  44803. * Gets the maxZ used for shadow according to both the scene and the light.
  44804. *
  44805. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44806. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44807. * @param activeCamera The camera we are returning the max for
  44808. * @returns the depth max z
  44809. */
  44810. getDepthMaxZ(activeCamera: Camera): number;
  44811. /**
  44812. * Prepares the list of defines specific to the light type.
  44813. * @param defines the list of defines
  44814. * @param lightIndex defines the index of the light for the effect
  44815. */
  44816. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44817. }
  44818. }
  44819. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44820. import { Mesh } from "babylonjs/Meshes/mesh";
  44821. /**
  44822. * Class containing static functions to help procedurally build meshes
  44823. */
  44824. export class HemisphereBuilder {
  44825. /**
  44826. * Creates a hemisphere mesh
  44827. * @param name defines the name of the mesh
  44828. * @param options defines the options used to create the mesh
  44829. * @param scene defines the hosting scene
  44830. * @returns the hemisphere mesh
  44831. */
  44832. static CreateHemisphere(name: string, options: {
  44833. segments?: number;
  44834. diameter?: number;
  44835. sideOrientation?: number;
  44836. }, scene: any): Mesh;
  44837. }
  44838. }
  44839. declare module "babylonjs/Lights/spotLight" {
  44840. import { Nullable } from "babylonjs/types";
  44841. import { Scene } from "babylonjs/scene";
  44842. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44844. import { Effect } from "babylonjs/Materials/effect";
  44845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44846. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44847. /**
  44848. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44849. * These values define a cone of light starting from the position, emitting toward the direction.
  44850. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44851. * and the exponent defines the speed of the decay of the light with distance (reach).
  44852. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44853. */
  44854. export class SpotLight extends ShadowLight {
  44855. private _angle;
  44856. private _innerAngle;
  44857. private _cosHalfAngle;
  44858. private _lightAngleScale;
  44859. private _lightAngleOffset;
  44860. /**
  44861. * Gets the cone angle of the spot light in Radians.
  44862. */
  44863. /**
  44864. * Sets the cone angle of the spot light in Radians.
  44865. */
  44866. angle: number;
  44867. /**
  44868. * Only used in gltf falloff mode, this defines the angle where
  44869. * the directional falloff will start before cutting at angle which could be seen
  44870. * as outer angle.
  44871. */
  44872. /**
  44873. * Only used in gltf falloff mode, this defines the angle where
  44874. * the directional falloff will start before cutting at angle which could be seen
  44875. * as outer angle.
  44876. */
  44877. innerAngle: number;
  44878. private _shadowAngleScale;
  44879. /**
  44880. * Allows scaling the angle of the light for shadow generation only.
  44881. */
  44882. /**
  44883. * Allows scaling the angle of the light for shadow generation only.
  44884. */
  44885. shadowAngleScale: number;
  44886. /**
  44887. * The light decay speed with the distance from the emission spot.
  44888. */
  44889. exponent: number;
  44890. private _projectionTextureMatrix;
  44891. /**
  44892. * Allows reading the projecton texture
  44893. */
  44894. readonly projectionTextureMatrix: Matrix;
  44895. protected _projectionTextureLightNear: number;
  44896. /**
  44897. * Gets the near clip of the Spotlight for texture projection.
  44898. */
  44899. /**
  44900. * Sets the near clip of the Spotlight for texture projection.
  44901. */
  44902. projectionTextureLightNear: number;
  44903. protected _projectionTextureLightFar: number;
  44904. /**
  44905. * Gets the far clip of the Spotlight for texture projection.
  44906. */
  44907. /**
  44908. * Sets the far clip of the Spotlight for texture projection.
  44909. */
  44910. projectionTextureLightFar: number;
  44911. protected _projectionTextureUpDirection: Vector3;
  44912. /**
  44913. * Gets the Up vector of the Spotlight for texture projection.
  44914. */
  44915. /**
  44916. * Sets the Up vector of the Spotlight for texture projection.
  44917. */
  44918. projectionTextureUpDirection: Vector3;
  44919. private _projectionTexture;
  44920. /**
  44921. * Gets the projection texture of the light.
  44922. */
  44923. /**
  44924. * Sets the projection texture of the light.
  44925. */
  44926. projectionTexture: Nullable<BaseTexture>;
  44927. private _projectionTextureViewLightDirty;
  44928. private _projectionTextureProjectionLightDirty;
  44929. private _projectionTextureDirty;
  44930. private _projectionTextureViewTargetVector;
  44931. private _projectionTextureViewLightMatrix;
  44932. private _projectionTextureProjectionLightMatrix;
  44933. private _projectionTextureScalingMatrix;
  44934. /**
  44935. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44936. * It can cast shadows.
  44937. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44938. * @param name The light friendly name
  44939. * @param position The position of the spot light in the scene
  44940. * @param direction The direction of the light in the scene
  44941. * @param angle The cone angle of the light in Radians
  44942. * @param exponent The light decay speed with the distance from the emission spot
  44943. * @param scene The scene the lights belongs to
  44944. */
  44945. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44946. /**
  44947. * Returns the string "SpotLight".
  44948. * @returns the class name
  44949. */
  44950. getClassName(): string;
  44951. /**
  44952. * Returns the integer 2.
  44953. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44954. */
  44955. getTypeID(): number;
  44956. /**
  44957. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44958. */
  44959. protected _setDirection(value: Vector3): void;
  44960. /**
  44961. * Overrides the position setter to recompute the projection texture view light Matrix.
  44962. */
  44963. protected _setPosition(value: Vector3): void;
  44964. /**
  44965. * 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.
  44966. * Returns the SpotLight.
  44967. */
  44968. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44969. protected _computeProjectionTextureViewLightMatrix(): void;
  44970. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44971. /**
  44972. * Main function for light texture projection matrix computing.
  44973. */
  44974. protected _computeProjectionTextureMatrix(): void;
  44975. protected _buildUniformLayout(): void;
  44976. private _computeAngleValues;
  44977. /**
  44978. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44979. * @param effect The effect to update
  44980. * @param lightIndex The index of the light in the effect to update
  44981. * @returns The spot light
  44982. */
  44983. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44984. /**
  44985. * Disposes the light and the associated resources.
  44986. */
  44987. dispose(): void;
  44988. /**
  44989. * Prepares the list of defines specific to the light type.
  44990. * @param defines the list of defines
  44991. * @param lightIndex defines the index of the light for the effect
  44992. */
  44993. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44994. }
  44995. }
  44996. declare module "babylonjs/Gizmos/lightGizmo" {
  44997. import { Nullable } from "babylonjs/types";
  44998. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44999. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45000. import { Light } from "babylonjs/Lights/light";
  45001. /**
  45002. * Gizmo that enables viewing a light
  45003. */
  45004. export class LightGizmo extends Gizmo {
  45005. private _lightMesh;
  45006. private _material;
  45007. private cachedPosition;
  45008. private cachedForward;
  45009. /**
  45010. * Creates a LightGizmo
  45011. * @param gizmoLayer The utility layer the gizmo will be added to
  45012. */
  45013. constructor(gizmoLayer?: UtilityLayerRenderer);
  45014. private _light;
  45015. /**
  45016. * The light that the gizmo is attached to
  45017. */
  45018. light: Nullable<Light>;
  45019. /**
  45020. * @hidden
  45021. * Updates the gizmo to match the attached mesh's position/rotation
  45022. */
  45023. protected _update(): void;
  45024. private static _Scale;
  45025. /**
  45026. * Creates the lines for a light mesh
  45027. */
  45028. private static _createLightLines;
  45029. /**
  45030. * Disposes of the light gizmo
  45031. */
  45032. dispose(): void;
  45033. private static _CreateHemisphericLightMesh;
  45034. private static _CreatePointLightMesh;
  45035. private static _CreateSpotLightMesh;
  45036. private static _CreateDirectionalLightMesh;
  45037. }
  45038. }
  45039. declare module "babylonjs/Gizmos/index" {
  45040. export * from "babylonjs/Gizmos/axisDragGizmo";
  45041. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45042. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45043. export * from "babylonjs/Gizmos/gizmo";
  45044. export * from "babylonjs/Gizmos/gizmoManager";
  45045. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45046. export * from "babylonjs/Gizmos/positionGizmo";
  45047. export * from "babylonjs/Gizmos/rotationGizmo";
  45048. export * from "babylonjs/Gizmos/scaleGizmo";
  45049. export * from "babylonjs/Gizmos/lightGizmo";
  45050. }
  45051. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45052. /** @hidden */
  45053. export var backgroundFragmentDeclaration: {
  45054. name: string;
  45055. shader: string;
  45056. };
  45057. }
  45058. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45059. /** @hidden */
  45060. export var backgroundUboDeclaration: {
  45061. name: string;
  45062. shader: string;
  45063. };
  45064. }
  45065. declare module "babylonjs/Shaders/background.fragment" {
  45066. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45067. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45068. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45069. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45070. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45071. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45072. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45073. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45074. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45075. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45076. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45077. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45078. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45079. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45080. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45081. /** @hidden */
  45082. export var backgroundPixelShader: {
  45083. name: string;
  45084. shader: string;
  45085. };
  45086. }
  45087. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45088. /** @hidden */
  45089. export var backgroundVertexDeclaration: {
  45090. name: string;
  45091. shader: string;
  45092. };
  45093. }
  45094. declare module "babylonjs/Shaders/background.vertex" {
  45095. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45096. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45097. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45098. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45099. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45100. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45101. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45102. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45103. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45104. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45105. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45106. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45107. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45108. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45109. /** @hidden */
  45110. export var backgroundVertexShader: {
  45111. name: string;
  45112. shader: string;
  45113. };
  45114. }
  45115. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45116. import { Nullable, int, float } from "babylonjs/types";
  45117. import { Scene } from "babylonjs/scene";
  45118. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45119. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45121. import { Mesh } from "babylonjs/Meshes/mesh";
  45122. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45123. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45124. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45126. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45127. import "babylonjs/Shaders/background.fragment";
  45128. import "babylonjs/Shaders/background.vertex";
  45129. /**
  45130. * Background material used to create an efficient environement around your scene.
  45131. */
  45132. export class BackgroundMaterial extends PushMaterial {
  45133. /**
  45134. * Standard reflectance value at parallel view angle.
  45135. */
  45136. static StandardReflectance0: number;
  45137. /**
  45138. * Standard reflectance value at grazing angle.
  45139. */
  45140. static StandardReflectance90: number;
  45141. protected _primaryColor: Color3;
  45142. /**
  45143. * Key light Color (multiply against the environement texture)
  45144. */
  45145. primaryColor: Color3;
  45146. protected __perceptualColor: Nullable<Color3>;
  45147. /**
  45148. * Experimental Internal Use Only.
  45149. *
  45150. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45151. * This acts as a helper to set the primary color to a more "human friendly" value.
  45152. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45153. * output color as close as possible from the chosen value.
  45154. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45155. * part of lighting setup.)
  45156. */
  45157. _perceptualColor: Nullable<Color3>;
  45158. protected _primaryColorShadowLevel: float;
  45159. /**
  45160. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45161. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45162. */
  45163. primaryColorShadowLevel: float;
  45164. protected _primaryColorHighlightLevel: float;
  45165. /**
  45166. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45167. * The primary color is used at the level chosen to define what the white area would look.
  45168. */
  45169. primaryColorHighlightLevel: float;
  45170. protected _reflectionTexture: Nullable<BaseTexture>;
  45171. /**
  45172. * Reflection Texture used in the material.
  45173. * Should be author in a specific way for the best result (refer to the documentation).
  45174. */
  45175. reflectionTexture: Nullable<BaseTexture>;
  45176. protected _reflectionBlur: float;
  45177. /**
  45178. * Reflection Texture level of blur.
  45179. *
  45180. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45181. * texture twice.
  45182. */
  45183. reflectionBlur: float;
  45184. protected _diffuseTexture: Nullable<BaseTexture>;
  45185. /**
  45186. * Diffuse Texture used in the material.
  45187. * Should be author in a specific way for the best result (refer to the documentation).
  45188. */
  45189. diffuseTexture: Nullable<BaseTexture>;
  45190. protected _shadowLights: Nullable<IShadowLight[]>;
  45191. /**
  45192. * Specify the list of lights casting shadow on the material.
  45193. * All scene shadow lights will be included if null.
  45194. */
  45195. shadowLights: Nullable<IShadowLight[]>;
  45196. protected _shadowLevel: float;
  45197. /**
  45198. * Helps adjusting the shadow to a softer level if required.
  45199. * 0 means black shadows and 1 means no shadows.
  45200. */
  45201. shadowLevel: float;
  45202. protected _sceneCenter: Vector3;
  45203. /**
  45204. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45205. * It is usually zero but might be interesting to modify according to your setup.
  45206. */
  45207. sceneCenter: Vector3;
  45208. protected _opacityFresnel: boolean;
  45209. /**
  45210. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45211. * This helps ensuring a nice transition when the camera goes under the ground.
  45212. */
  45213. opacityFresnel: boolean;
  45214. protected _reflectionFresnel: boolean;
  45215. /**
  45216. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45217. * This helps adding a mirror texture on the ground.
  45218. */
  45219. reflectionFresnel: boolean;
  45220. protected _reflectionFalloffDistance: number;
  45221. /**
  45222. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45223. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45224. */
  45225. reflectionFalloffDistance: number;
  45226. protected _reflectionAmount: number;
  45227. /**
  45228. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45229. */
  45230. reflectionAmount: number;
  45231. protected _reflectionReflectance0: number;
  45232. /**
  45233. * This specifies the weight of the reflection at grazing angle.
  45234. */
  45235. reflectionReflectance0: number;
  45236. protected _reflectionReflectance90: number;
  45237. /**
  45238. * This specifies the weight of the reflection at a perpendicular point of view.
  45239. */
  45240. reflectionReflectance90: number;
  45241. /**
  45242. * Sets the reflection reflectance fresnel values according to the default standard
  45243. * empirically know to work well :-)
  45244. */
  45245. reflectionStandardFresnelWeight: number;
  45246. protected _useRGBColor: boolean;
  45247. /**
  45248. * Helps to directly use the maps channels instead of their level.
  45249. */
  45250. useRGBColor: boolean;
  45251. protected _enableNoise: boolean;
  45252. /**
  45253. * This helps reducing the banding effect that could occur on the background.
  45254. */
  45255. enableNoise: boolean;
  45256. /**
  45257. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45258. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45259. * Recommended to be keep at 1.0 except for special cases.
  45260. */
  45261. fovMultiplier: number;
  45262. private _fovMultiplier;
  45263. /**
  45264. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45265. */
  45266. useEquirectangularFOV: boolean;
  45267. private _maxSimultaneousLights;
  45268. /**
  45269. * Number of Simultaneous lights allowed on the material.
  45270. */
  45271. maxSimultaneousLights: int;
  45272. /**
  45273. * Default configuration related to image processing available in the Background Material.
  45274. */
  45275. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45276. /**
  45277. * Keep track of the image processing observer to allow dispose and replace.
  45278. */
  45279. private _imageProcessingObserver;
  45280. /**
  45281. * Attaches a new image processing configuration to the PBR Material.
  45282. * @param configuration (if null the scene configuration will be use)
  45283. */
  45284. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45285. /**
  45286. * Gets the image processing configuration used either in this material.
  45287. */
  45288. /**
  45289. * Sets the Default image processing configuration used either in the this material.
  45290. *
  45291. * If sets to null, the scene one is in use.
  45292. */
  45293. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45294. /**
  45295. * Gets wether the color curves effect is enabled.
  45296. */
  45297. /**
  45298. * Sets wether the color curves effect is enabled.
  45299. */
  45300. cameraColorCurvesEnabled: boolean;
  45301. /**
  45302. * Gets wether the color grading effect is enabled.
  45303. */
  45304. /**
  45305. * Gets wether the color grading effect is enabled.
  45306. */
  45307. cameraColorGradingEnabled: boolean;
  45308. /**
  45309. * Gets wether tonemapping is enabled or not.
  45310. */
  45311. /**
  45312. * Sets wether tonemapping is enabled or not
  45313. */
  45314. cameraToneMappingEnabled: boolean;
  45315. /**
  45316. * The camera exposure used on this material.
  45317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45318. * This corresponds to a photographic exposure.
  45319. */
  45320. /**
  45321. * The camera exposure used on this material.
  45322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45323. * This corresponds to a photographic exposure.
  45324. */
  45325. cameraExposure: float;
  45326. /**
  45327. * Gets The camera contrast used on this material.
  45328. */
  45329. /**
  45330. * Sets The camera contrast used on this material.
  45331. */
  45332. cameraContrast: float;
  45333. /**
  45334. * Gets the Color Grading 2D Lookup Texture.
  45335. */
  45336. /**
  45337. * Sets the Color Grading 2D Lookup Texture.
  45338. */
  45339. cameraColorGradingTexture: Nullable<BaseTexture>;
  45340. /**
  45341. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45342. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45343. * 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;
  45344. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45345. */
  45346. /**
  45347. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45348. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45349. * 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;
  45350. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45351. */
  45352. cameraColorCurves: Nullable<ColorCurves>;
  45353. /**
  45354. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45355. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45356. */
  45357. switchToBGR: boolean;
  45358. private _renderTargets;
  45359. private _reflectionControls;
  45360. private _white;
  45361. private _primaryShadowColor;
  45362. private _primaryHighlightColor;
  45363. /**
  45364. * Instantiates a Background Material in the given scene
  45365. * @param name The friendly name of the material
  45366. * @param scene The scene to add the material to
  45367. */
  45368. constructor(name: string, scene: Scene);
  45369. /**
  45370. * Gets a boolean indicating that current material needs to register RTT
  45371. */
  45372. readonly hasRenderTargetTextures: boolean;
  45373. /**
  45374. * The entire material has been created in order to prevent overdraw.
  45375. * @returns false
  45376. */
  45377. needAlphaTesting(): boolean;
  45378. /**
  45379. * The entire material has been created in order to prevent overdraw.
  45380. * @returns true if blending is enable
  45381. */
  45382. needAlphaBlending(): boolean;
  45383. /**
  45384. * Checks wether the material is ready to be rendered for a given mesh.
  45385. * @param mesh The mesh to render
  45386. * @param subMesh The submesh to check against
  45387. * @param useInstances Specify wether or not the material is used with instances
  45388. * @returns true if all the dependencies are ready (Textures, Effects...)
  45389. */
  45390. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45391. /**
  45392. * Compute the primary color according to the chosen perceptual color.
  45393. */
  45394. private _computePrimaryColorFromPerceptualColor;
  45395. /**
  45396. * Compute the highlights and shadow colors according to their chosen levels.
  45397. */
  45398. private _computePrimaryColors;
  45399. /**
  45400. * Build the uniform buffer used in the material.
  45401. */
  45402. buildUniformLayout(): void;
  45403. /**
  45404. * Unbind the material.
  45405. */
  45406. unbind(): void;
  45407. /**
  45408. * Bind only the world matrix to the material.
  45409. * @param world The world matrix to bind.
  45410. */
  45411. bindOnlyWorldMatrix(world: Matrix): void;
  45412. /**
  45413. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45414. * @param world The world matrix to bind.
  45415. * @param subMesh The submesh to bind for.
  45416. */
  45417. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45418. /**
  45419. * Dispose the material.
  45420. * @param forceDisposeEffect Force disposal of the associated effect.
  45421. * @param forceDisposeTextures Force disposal of the associated textures.
  45422. */
  45423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45424. /**
  45425. * Clones the material.
  45426. * @param name The cloned name.
  45427. * @returns The cloned material.
  45428. */
  45429. clone(name: string): BackgroundMaterial;
  45430. /**
  45431. * Serializes the current material to its JSON representation.
  45432. * @returns The JSON representation.
  45433. */
  45434. serialize(): any;
  45435. /**
  45436. * Gets the class name of the material
  45437. * @returns "BackgroundMaterial"
  45438. */
  45439. getClassName(): string;
  45440. /**
  45441. * Parse a JSON input to create back a background material.
  45442. * @param source The JSON data to parse
  45443. * @param scene The scene to create the parsed material in
  45444. * @param rootUrl The root url of the assets the material depends upon
  45445. * @returns the instantiated BackgroundMaterial.
  45446. */
  45447. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45448. }
  45449. }
  45450. declare module "babylonjs/Helpers/environmentHelper" {
  45451. import { Observable } from "babylonjs/Misc/observable";
  45452. import { Nullable } from "babylonjs/types";
  45453. import { Scene } from "babylonjs/scene";
  45454. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45456. import { Mesh } from "babylonjs/Meshes/mesh";
  45457. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45458. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45459. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45460. import "babylonjs/Meshes/Builders/planeBuilder";
  45461. import "babylonjs/Meshes/Builders/boxBuilder";
  45462. /**
  45463. * Represents the different options available during the creation of
  45464. * a Environment helper.
  45465. *
  45466. * This can control the default ground, skybox and image processing setup of your scene.
  45467. */
  45468. export interface IEnvironmentHelperOptions {
  45469. /**
  45470. * Specifies wether or not to create a ground.
  45471. * True by default.
  45472. */
  45473. createGround: boolean;
  45474. /**
  45475. * Specifies the ground size.
  45476. * 15 by default.
  45477. */
  45478. groundSize: number;
  45479. /**
  45480. * The texture used on the ground for the main color.
  45481. * Comes from the BabylonJS CDN by default.
  45482. *
  45483. * Remarks: Can be either a texture or a url.
  45484. */
  45485. groundTexture: string | BaseTexture;
  45486. /**
  45487. * The color mixed in the ground texture by default.
  45488. * BabylonJS clearColor by default.
  45489. */
  45490. groundColor: Color3;
  45491. /**
  45492. * Specifies the ground opacity.
  45493. * 1 by default.
  45494. */
  45495. groundOpacity: number;
  45496. /**
  45497. * Enables the ground to receive shadows.
  45498. * True by default.
  45499. */
  45500. enableGroundShadow: boolean;
  45501. /**
  45502. * Helps preventing the shadow to be fully black on the ground.
  45503. * 0.5 by default.
  45504. */
  45505. groundShadowLevel: number;
  45506. /**
  45507. * Creates a mirror texture attach to the ground.
  45508. * false by default.
  45509. */
  45510. enableGroundMirror: boolean;
  45511. /**
  45512. * Specifies the ground mirror size ratio.
  45513. * 0.3 by default as the default kernel is 64.
  45514. */
  45515. groundMirrorSizeRatio: number;
  45516. /**
  45517. * Specifies the ground mirror blur kernel size.
  45518. * 64 by default.
  45519. */
  45520. groundMirrorBlurKernel: number;
  45521. /**
  45522. * Specifies the ground mirror visibility amount.
  45523. * 1 by default
  45524. */
  45525. groundMirrorAmount: number;
  45526. /**
  45527. * Specifies the ground mirror reflectance weight.
  45528. * This uses the standard weight of the background material to setup the fresnel effect
  45529. * of the mirror.
  45530. * 1 by default.
  45531. */
  45532. groundMirrorFresnelWeight: number;
  45533. /**
  45534. * Specifies the ground mirror Falloff distance.
  45535. * This can helps reducing the size of the reflection.
  45536. * 0 by Default.
  45537. */
  45538. groundMirrorFallOffDistance: number;
  45539. /**
  45540. * Specifies the ground mirror texture type.
  45541. * Unsigned Int by Default.
  45542. */
  45543. groundMirrorTextureType: number;
  45544. /**
  45545. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45546. * the shown objects.
  45547. */
  45548. groundYBias: number;
  45549. /**
  45550. * Specifies wether or not to create a skybox.
  45551. * True by default.
  45552. */
  45553. createSkybox: boolean;
  45554. /**
  45555. * Specifies the skybox size.
  45556. * 20 by default.
  45557. */
  45558. skyboxSize: number;
  45559. /**
  45560. * The texture used on the skybox for the main color.
  45561. * Comes from the BabylonJS CDN by default.
  45562. *
  45563. * Remarks: Can be either a texture or a url.
  45564. */
  45565. skyboxTexture: string | BaseTexture;
  45566. /**
  45567. * The color mixed in the skybox texture by default.
  45568. * BabylonJS clearColor by default.
  45569. */
  45570. skyboxColor: Color3;
  45571. /**
  45572. * The background rotation around the Y axis of the scene.
  45573. * This helps aligning the key lights of your scene with the background.
  45574. * 0 by default.
  45575. */
  45576. backgroundYRotation: number;
  45577. /**
  45578. * Compute automatically the size of the elements to best fit with the scene.
  45579. */
  45580. sizeAuto: boolean;
  45581. /**
  45582. * Default position of the rootMesh if autoSize is not true.
  45583. */
  45584. rootPosition: Vector3;
  45585. /**
  45586. * Sets up the image processing in the scene.
  45587. * true by default.
  45588. */
  45589. setupImageProcessing: boolean;
  45590. /**
  45591. * The texture used as your environment texture in the scene.
  45592. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45593. *
  45594. * Remarks: Can be either a texture or a url.
  45595. */
  45596. environmentTexture: string | BaseTexture;
  45597. /**
  45598. * The value of the exposure to apply to the scene.
  45599. * 0.6 by default if setupImageProcessing is true.
  45600. */
  45601. cameraExposure: number;
  45602. /**
  45603. * The value of the contrast to apply to the scene.
  45604. * 1.6 by default if setupImageProcessing is true.
  45605. */
  45606. cameraContrast: number;
  45607. /**
  45608. * Specifies wether or not tonemapping should be enabled in the scene.
  45609. * true by default if setupImageProcessing is true.
  45610. */
  45611. toneMappingEnabled: boolean;
  45612. }
  45613. /**
  45614. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45615. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45616. * It also helps with the default setup of your imageProcessing configuration.
  45617. */
  45618. export class EnvironmentHelper {
  45619. /**
  45620. * Default ground texture URL.
  45621. */
  45622. private static _groundTextureCDNUrl;
  45623. /**
  45624. * Default skybox texture URL.
  45625. */
  45626. private static _skyboxTextureCDNUrl;
  45627. /**
  45628. * Default environment texture URL.
  45629. */
  45630. private static _environmentTextureCDNUrl;
  45631. /**
  45632. * Creates the default options for the helper.
  45633. */
  45634. private static _getDefaultOptions;
  45635. private _rootMesh;
  45636. /**
  45637. * Gets the root mesh created by the helper.
  45638. */
  45639. readonly rootMesh: Mesh;
  45640. private _skybox;
  45641. /**
  45642. * Gets the skybox created by the helper.
  45643. */
  45644. readonly skybox: Nullable<Mesh>;
  45645. private _skyboxTexture;
  45646. /**
  45647. * Gets the skybox texture created by the helper.
  45648. */
  45649. readonly skyboxTexture: Nullable<BaseTexture>;
  45650. private _skyboxMaterial;
  45651. /**
  45652. * Gets the skybox material created by the helper.
  45653. */
  45654. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45655. private _ground;
  45656. /**
  45657. * Gets the ground mesh created by the helper.
  45658. */
  45659. readonly ground: Nullable<Mesh>;
  45660. private _groundTexture;
  45661. /**
  45662. * Gets the ground texture created by the helper.
  45663. */
  45664. readonly groundTexture: Nullable<BaseTexture>;
  45665. private _groundMirror;
  45666. /**
  45667. * Gets the ground mirror created by the helper.
  45668. */
  45669. readonly groundMirror: Nullable<MirrorTexture>;
  45670. /**
  45671. * Gets the ground mirror render list to helps pushing the meshes
  45672. * you wish in the ground reflection.
  45673. */
  45674. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45675. private _groundMaterial;
  45676. /**
  45677. * Gets the ground material created by the helper.
  45678. */
  45679. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45680. /**
  45681. * Stores the creation options.
  45682. */
  45683. private readonly _scene;
  45684. private _options;
  45685. /**
  45686. * This observable will be notified with any error during the creation of the environment,
  45687. * mainly texture creation errors.
  45688. */
  45689. onErrorObservable: Observable<{
  45690. message?: string;
  45691. exception?: any;
  45692. }>;
  45693. /**
  45694. * constructor
  45695. * @param options Defines the options we want to customize the helper
  45696. * @param scene The scene to add the material to
  45697. */
  45698. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45699. /**
  45700. * Updates the background according to the new options
  45701. * @param options
  45702. */
  45703. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45704. /**
  45705. * Sets the primary color of all the available elements.
  45706. * @param color the main color to affect to the ground and the background
  45707. */
  45708. setMainColor(color: Color3): void;
  45709. /**
  45710. * Setup the image processing according to the specified options.
  45711. */
  45712. private _setupImageProcessing;
  45713. /**
  45714. * Setup the environment texture according to the specified options.
  45715. */
  45716. private _setupEnvironmentTexture;
  45717. /**
  45718. * Setup the background according to the specified options.
  45719. */
  45720. private _setupBackground;
  45721. /**
  45722. * Get the scene sizes according to the setup.
  45723. */
  45724. private _getSceneSize;
  45725. /**
  45726. * Setup the ground according to the specified options.
  45727. */
  45728. private _setupGround;
  45729. /**
  45730. * Setup the ground material according to the specified options.
  45731. */
  45732. private _setupGroundMaterial;
  45733. /**
  45734. * Setup the ground diffuse texture according to the specified options.
  45735. */
  45736. private _setupGroundDiffuseTexture;
  45737. /**
  45738. * Setup the ground mirror texture according to the specified options.
  45739. */
  45740. private _setupGroundMirrorTexture;
  45741. /**
  45742. * Setup the ground to receive the mirror texture.
  45743. */
  45744. private _setupMirrorInGroundMaterial;
  45745. /**
  45746. * Setup the skybox according to the specified options.
  45747. */
  45748. private _setupSkybox;
  45749. /**
  45750. * Setup the skybox material according to the specified options.
  45751. */
  45752. private _setupSkyboxMaterial;
  45753. /**
  45754. * Setup the skybox reflection texture according to the specified options.
  45755. */
  45756. private _setupSkyboxReflectionTexture;
  45757. private _errorHandler;
  45758. /**
  45759. * Dispose all the elements created by the Helper.
  45760. */
  45761. dispose(): void;
  45762. }
  45763. }
  45764. declare module "babylonjs/Helpers/photoDome" {
  45765. import { Observable } from "babylonjs/Misc/observable";
  45766. import { Nullable } from "babylonjs/types";
  45767. import { Scene } from "babylonjs/scene";
  45768. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45769. import { Mesh } from "babylonjs/Meshes/mesh";
  45770. import { Texture } from "babylonjs/Materials/Textures/texture";
  45771. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45772. import "babylonjs/Meshes/Builders/sphereBuilder";
  45773. /**
  45774. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45775. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45776. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45777. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45778. */
  45779. export class PhotoDome extends TransformNode {
  45780. private _useDirectMapping;
  45781. /**
  45782. * The texture being displayed on the sphere
  45783. */
  45784. protected _photoTexture: Texture;
  45785. /**
  45786. * Gets or sets the texture being displayed on the sphere
  45787. */
  45788. photoTexture: Texture;
  45789. /**
  45790. * Observable raised when an error occured while loading the 360 image
  45791. */
  45792. onLoadErrorObservable: Observable<string>;
  45793. /**
  45794. * The skybox material
  45795. */
  45796. protected _material: BackgroundMaterial;
  45797. /**
  45798. * The surface used for the skybox
  45799. */
  45800. protected _mesh: Mesh;
  45801. /**
  45802. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45803. * Also see the options.resolution property.
  45804. */
  45805. fovMultiplier: number;
  45806. /**
  45807. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45808. * @param name Element's name, child elements will append suffixes for their own names.
  45809. * @param urlsOfPhoto defines the url of the photo to display
  45810. * @param options defines an object containing optional or exposed sub element properties
  45811. * @param onError defines a callback called when an error occured while loading the texture
  45812. */
  45813. constructor(name: string, urlOfPhoto: string, options: {
  45814. resolution?: number;
  45815. size?: number;
  45816. useDirectMapping?: boolean;
  45817. faceForward?: boolean;
  45818. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45819. /**
  45820. * Releases resources associated with this node.
  45821. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45822. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45823. */
  45824. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45825. }
  45826. }
  45827. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45828. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45829. /** @hidden */
  45830. export var rgbdDecodePixelShader: {
  45831. name: string;
  45832. shader: string;
  45833. };
  45834. }
  45835. declare module "babylonjs/Misc/brdfTextureTools" {
  45836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45837. import { Scene } from "babylonjs/scene";
  45838. import "babylonjs/Shaders/rgbdDecode.fragment";
  45839. /**
  45840. * Class used to host texture specific utilities
  45841. */
  45842. export class BRDFTextureTools {
  45843. /**
  45844. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45845. * @param texture the texture to expand.
  45846. */
  45847. private static _ExpandDefaultBRDFTexture;
  45848. /**
  45849. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45850. * @param scene defines the hosting scene
  45851. * @returns the environment BRDF texture
  45852. */
  45853. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45854. private static _environmentBRDFBase64Texture;
  45855. }
  45856. }
  45857. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45858. import { Nullable } from "babylonjs/types";
  45859. import { IAnimatable } from "babylonjs/Misc/tools";
  45860. import { Color3 } from "babylonjs/Maths/math";
  45861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45862. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45864. import { Engine } from "babylonjs/Engines/engine";
  45865. import { Scene } from "babylonjs/scene";
  45866. /**
  45867. * @hidden
  45868. */
  45869. export interface IMaterialClearCoatDefines {
  45870. CLEARCOAT: boolean;
  45871. CLEARCOAT_DEFAULTIOR: boolean;
  45872. CLEARCOAT_TEXTURE: boolean;
  45873. CLEARCOAT_TEXTUREDIRECTUV: number;
  45874. CLEARCOAT_BUMP: boolean;
  45875. CLEARCOAT_BUMPDIRECTUV: number;
  45876. CLEARCOAT_TINT: boolean;
  45877. CLEARCOAT_TINT_TEXTURE: boolean;
  45878. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45879. /** @hidden */
  45880. _areTexturesDirty: boolean;
  45881. }
  45882. /**
  45883. * Define the code related to the clear coat parameters of the pbr material.
  45884. */
  45885. export class PBRClearCoatConfiguration {
  45886. /**
  45887. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45888. * The default fits with a polyurethane material.
  45889. */
  45890. private static readonly _DefaultIndiceOfRefraction;
  45891. private _isEnabled;
  45892. /**
  45893. * Defines if the clear coat is enabled in the material.
  45894. */
  45895. isEnabled: boolean;
  45896. /**
  45897. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45898. */
  45899. intensity: number;
  45900. /**
  45901. * Defines the clear coat layer roughness.
  45902. */
  45903. roughness: number;
  45904. private _indiceOfRefraction;
  45905. /**
  45906. * Defines the indice of refraction of the clear coat.
  45907. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45908. * The default fits with a polyurethane material.
  45909. * Changing the default value is more performance intensive.
  45910. */
  45911. indiceOfRefraction: number;
  45912. private _texture;
  45913. /**
  45914. * Stores the clear coat values in a texture.
  45915. */
  45916. texture: Nullable<BaseTexture>;
  45917. private _bumpTexture;
  45918. /**
  45919. * Define the clear coat specific bump texture.
  45920. */
  45921. bumpTexture: Nullable<BaseTexture>;
  45922. private _isTintEnabled;
  45923. /**
  45924. * Defines if the clear coat tint is enabled in the material.
  45925. */
  45926. isTintEnabled: boolean;
  45927. /**
  45928. * Defines the clear coat tint of the material.
  45929. * This is only use if tint is enabled
  45930. */
  45931. tintColor: Color3;
  45932. /**
  45933. * Defines the distance at which the tint color should be found in the
  45934. * clear coat media.
  45935. * This is only use if tint is enabled
  45936. */
  45937. tintColorAtDistance: number;
  45938. /**
  45939. * Defines the clear coat layer thickness.
  45940. * This is only use if tint is enabled
  45941. */
  45942. tintThickness: number;
  45943. private _tintTexture;
  45944. /**
  45945. * Stores the clear tint values in a texture.
  45946. * rgb is tint
  45947. * a is a thickness factor
  45948. */
  45949. tintTexture: Nullable<BaseTexture>;
  45950. /** @hidden */
  45951. private _internalMarkAllSubMeshesAsTexturesDirty;
  45952. /** @hidden */
  45953. _markAllSubMeshesAsTexturesDirty(): void;
  45954. /**
  45955. * Instantiate a new istance of clear coat configuration.
  45956. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45957. */
  45958. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45959. /**
  45960. * Gets wehter the submesh is ready to be used or not.
  45961. * @param defines the list of "defines" to update.
  45962. * @param scene defines the scene the material belongs to.
  45963. * @param engine defines the engine the material belongs to.
  45964. * @param disableBumpMap defines wether the material disables bump or not.
  45965. * @returns - boolean indicating that the submesh is ready or not.
  45966. */
  45967. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45968. /**
  45969. * Checks to see if a texture is used in the material.
  45970. * @param defines the list of "defines" to update.
  45971. * @param scene defines the scene to the material belongs to.
  45972. */
  45973. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45974. /**
  45975. * Binds the material data.
  45976. * @param uniformBuffer defines the Uniform buffer to fill in.
  45977. * @param scene defines the scene the material belongs to.
  45978. * @param engine defines the engine the material belongs to.
  45979. * @param disableBumpMap defines wether the material disables bump or not.
  45980. * @param isFrozen defines wether the material is frozen or not.
  45981. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45982. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45983. */
  45984. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45985. /**
  45986. * Checks to see if a texture is used in the material.
  45987. * @param texture - Base texture to use.
  45988. * @returns - Boolean specifying if a texture is used in the material.
  45989. */
  45990. hasTexture(texture: BaseTexture): boolean;
  45991. /**
  45992. * Returns an array of the actively used textures.
  45993. * @param activeTextures Array of BaseTextures
  45994. */
  45995. getActiveTextures(activeTextures: BaseTexture[]): void;
  45996. /**
  45997. * Returns the animatable textures.
  45998. * @param animatables Array of animatable textures.
  45999. */
  46000. getAnimatables(animatables: IAnimatable[]): void;
  46001. /**
  46002. * Disposes the resources of the material.
  46003. * @param forceDisposeTextures - Forces the disposal of all textures.
  46004. */
  46005. dispose(forceDisposeTextures?: boolean): void;
  46006. /**
  46007. * Get the current class name of the texture useful for serialization or dynamic coding.
  46008. * @returns "PBRClearCoatConfiguration"
  46009. */
  46010. getClassName(): string;
  46011. /**
  46012. * Add fallbacks to the effect fallbacks list.
  46013. * @param defines defines the Base texture to use.
  46014. * @param fallbacks defines the current fallback list.
  46015. * @param currentRank defines the current fallback rank.
  46016. * @returns the new fallback rank.
  46017. */
  46018. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46019. /**
  46020. * Add the required uniforms to the current list.
  46021. * @param uniforms defines the current uniform list.
  46022. */
  46023. static AddUniforms(uniforms: string[]): void;
  46024. /**
  46025. * Add the required samplers to the current list.
  46026. * @param samplers defines the current sampler list.
  46027. */
  46028. static AddSamplers(samplers: string[]): void;
  46029. /**
  46030. * Add the required uniforms to the current buffer.
  46031. * @param uniformBuffer defines the current uniform buffer.
  46032. */
  46033. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46034. /**
  46035. * Makes a duplicate of the current configuration into another one.
  46036. * @param clearCoatConfiguration define the config where to copy the info
  46037. */
  46038. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46039. /**
  46040. * Serializes this clear coat configuration.
  46041. * @returns - An object with the serialized config.
  46042. */
  46043. serialize(): any;
  46044. /**
  46045. * Parses a Clear Coat Configuration from a serialized object.
  46046. * @param source - Serialized object.
  46047. */
  46048. parse(source: any): void;
  46049. }
  46050. }
  46051. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46052. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46053. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46055. import { Vector2 } from "babylonjs/Maths/math";
  46056. import { Scene } from "babylonjs/scene";
  46057. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46058. import { IAnimatable } from "babylonjs/Misc/tools";
  46059. import { Nullable } from "babylonjs/types";
  46060. /**
  46061. * @hidden
  46062. */
  46063. export interface IMaterialAnisotropicDefines {
  46064. ANISOTROPIC: boolean;
  46065. ANISOTROPIC_TEXTURE: boolean;
  46066. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46067. MAINUV1: boolean;
  46068. _areTexturesDirty: boolean;
  46069. _needUVs: boolean;
  46070. }
  46071. /**
  46072. * Define the code related to the anisotropic parameters of the pbr material.
  46073. */
  46074. export class PBRAnisotropicConfiguration {
  46075. private _isEnabled;
  46076. /**
  46077. * Defines if the anisotropy is enabled in the material.
  46078. */
  46079. isEnabled: boolean;
  46080. /**
  46081. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46082. */
  46083. intensity: number;
  46084. /**
  46085. * Defines if the effect is along the tangents, bitangents or in between.
  46086. * By default, the effect is "strectching" the highlights along the tangents.
  46087. */
  46088. direction: Vector2;
  46089. private _texture;
  46090. /**
  46091. * Stores the anisotropy values in a texture.
  46092. * rg is direction (like normal from -1 to 1)
  46093. * b is a intensity
  46094. */
  46095. texture: Nullable<BaseTexture>;
  46096. /** @hidden */
  46097. private _internalMarkAllSubMeshesAsTexturesDirty;
  46098. /** @hidden */
  46099. _markAllSubMeshesAsTexturesDirty(): void;
  46100. /**
  46101. * Instantiate a new istance of anisotropy configuration.
  46102. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46103. */
  46104. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46105. /**
  46106. * Specifies that the submesh is ready to be used.
  46107. * @param defines the list of "defines" to update.
  46108. * @param scene defines the scene the material belongs to.
  46109. * @returns - boolean indicating that the submesh is ready or not.
  46110. */
  46111. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46112. /**
  46113. * Checks to see if a texture is used in the material.
  46114. * @param defines the list of "defines" to update.
  46115. * @param mesh the mesh we are preparing the defines for.
  46116. * @param scene defines the scene the material belongs to.
  46117. */
  46118. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46119. /**
  46120. * Binds the material data.
  46121. * @param uniformBuffer defines the Uniform buffer to fill in.
  46122. * @param scene defines the scene the material belongs to.
  46123. * @param isFrozen defines wether the material is frozen or not.
  46124. */
  46125. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46126. /**
  46127. * Checks to see if a texture is used in the material.
  46128. * @param texture - Base texture to use.
  46129. * @returns - Boolean specifying if a texture is used in the material.
  46130. */
  46131. hasTexture(texture: BaseTexture): boolean;
  46132. /**
  46133. * Returns an array of the actively used textures.
  46134. * @param activeTextures Array of BaseTextures
  46135. */
  46136. getActiveTextures(activeTextures: BaseTexture[]): void;
  46137. /**
  46138. * Returns the animatable textures.
  46139. * @param animatables Array of animatable textures.
  46140. */
  46141. getAnimatables(animatables: IAnimatable[]): void;
  46142. /**
  46143. * Disposes the resources of the material.
  46144. * @param forceDisposeTextures - Forces the disposal of all textures.
  46145. */
  46146. dispose(forceDisposeTextures?: boolean): void;
  46147. /**
  46148. * Get the current class name of the texture useful for serialization or dynamic coding.
  46149. * @returns "PBRAnisotropicConfiguration"
  46150. */
  46151. getClassName(): string;
  46152. /**
  46153. * Add fallbacks to the effect fallbacks list.
  46154. * @param defines defines the Base texture to use.
  46155. * @param fallbacks defines the current fallback list.
  46156. * @param currentRank defines the current fallback rank.
  46157. * @returns the new fallback rank.
  46158. */
  46159. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46160. /**
  46161. * Add the required uniforms to the current list.
  46162. * @param uniforms defines the current uniform list.
  46163. */
  46164. static AddUniforms(uniforms: string[]): void;
  46165. /**
  46166. * Add the required uniforms to the current buffer.
  46167. * @param uniformBuffer defines the current uniform buffer.
  46168. */
  46169. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46170. /**
  46171. * Add the required samplers to the current list.
  46172. * @param samplers defines the current sampler list.
  46173. */
  46174. static AddSamplers(samplers: string[]): void;
  46175. /**
  46176. * Makes a duplicate of the current configuration into another one.
  46177. * @param anisotropicConfiguration define the config where to copy the info
  46178. */
  46179. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46180. /**
  46181. * Serializes this anisotropy configuration.
  46182. * @returns - An object with the serialized config.
  46183. */
  46184. serialize(): any;
  46185. /**
  46186. * Parses a anisotropy Configuration from a serialized object.
  46187. * @param source - Serialized object.
  46188. */
  46189. parse(source: any): void;
  46190. }
  46191. }
  46192. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46193. /**
  46194. * @hidden
  46195. */
  46196. export interface IMaterialBRDFDefines {
  46197. BRDF_V_HEIGHT_CORRELATED: boolean;
  46198. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46199. SPHERICAL_HARMONICS: boolean;
  46200. /** @hidden */
  46201. _areMiscDirty: boolean;
  46202. }
  46203. /**
  46204. * Define the code related to the BRDF parameters of the pbr material.
  46205. */
  46206. export class PBRBRDFConfiguration {
  46207. /**
  46208. * Default value used for the energy conservation.
  46209. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46210. */
  46211. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46212. /**
  46213. * Default value used for the Smith Visibility Height Correlated mode.
  46214. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46215. */
  46216. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46217. /**
  46218. * Default value used for the IBL diffuse part.
  46219. * This can help switching back to the polynomials mode globally which is a tiny bit
  46220. * less GPU intensive at the drawback of a lower quality.
  46221. */
  46222. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46223. private _useEnergyConservation;
  46224. /**
  46225. * Defines if the material uses energy conservation.
  46226. */
  46227. useEnergyConservation: boolean;
  46228. private _useSmithVisibilityHeightCorrelated;
  46229. /**
  46230. * LEGACY Mode set to false
  46231. * Defines if the material uses height smith correlated visibility term.
  46232. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46233. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46234. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46235. * Not relying on height correlated will also disable energy conservation.
  46236. */
  46237. useSmithVisibilityHeightCorrelated: boolean;
  46238. private _useSphericalHarmonics;
  46239. /**
  46240. * LEGACY Mode set to false
  46241. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46242. * diffuse part of the IBL.
  46243. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46244. * to the ground truth.
  46245. */
  46246. useSphericalHarmonics: boolean;
  46247. /** @hidden */
  46248. private _internalMarkAllSubMeshesAsMiscDirty;
  46249. /** @hidden */
  46250. _markAllSubMeshesAsMiscDirty(): void;
  46251. /**
  46252. * Instantiate a new istance of clear coat configuration.
  46253. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46254. */
  46255. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46256. /**
  46257. * Checks to see if a texture is used in the material.
  46258. * @param defines the list of "defines" to update.
  46259. */
  46260. prepareDefines(defines: IMaterialBRDFDefines): void;
  46261. /**
  46262. * Get the current class name of the texture useful for serialization or dynamic coding.
  46263. * @returns "PBRClearCoatConfiguration"
  46264. */
  46265. getClassName(): string;
  46266. /**
  46267. * Makes a duplicate of the current configuration into another one.
  46268. * @param brdfConfiguration define the config where to copy the info
  46269. */
  46270. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46271. /**
  46272. * Serializes this BRDF configuration.
  46273. * @returns - An object with the serialized config.
  46274. */
  46275. serialize(): any;
  46276. /**
  46277. * Parses a BRDF Configuration from a serialized object.
  46278. * @param source - Serialized object.
  46279. */
  46280. parse(source: any): void;
  46281. }
  46282. }
  46283. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46284. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46285. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46286. import { Color3 } from "babylonjs/Maths/math";
  46287. import { Scene } from "babylonjs/scene";
  46288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46289. import { IAnimatable } from "babylonjs/Misc/tools";
  46290. import { Nullable } from "babylonjs/types";
  46291. /**
  46292. * @hidden
  46293. */
  46294. export interface IMaterialSheenDefines {
  46295. SHEEN: boolean;
  46296. SHEEN_TEXTURE: boolean;
  46297. SHEEN_TEXTUREDIRECTUV: number;
  46298. SHEEN_LINKWITHALBEDO: boolean;
  46299. /** @hidden */
  46300. _areTexturesDirty: boolean;
  46301. }
  46302. /**
  46303. * Define the code related to the Sheen parameters of the pbr material.
  46304. */
  46305. export class PBRSheenConfiguration {
  46306. private _isEnabled;
  46307. /**
  46308. * Defines if the material uses sheen.
  46309. */
  46310. isEnabled: boolean;
  46311. private _linkSheenWithAlbedo;
  46312. /**
  46313. * Defines if the sheen is linked to the sheen color.
  46314. */
  46315. linkSheenWithAlbedo: boolean;
  46316. /**
  46317. * Defines the sheen intensity.
  46318. */
  46319. intensity: number;
  46320. /**
  46321. * Defines the sheen color.
  46322. */
  46323. color: Color3;
  46324. private _texture;
  46325. /**
  46326. * Stores the sheen tint values in a texture.
  46327. * rgb is tint
  46328. * a is a intensity
  46329. */
  46330. texture: Nullable<BaseTexture>;
  46331. /** @hidden */
  46332. private _internalMarkAllSubMeshesAsTexturesDirty;
  46333. /** @hidden */
  46334. _markAllSubMeshesAsTexturesDirty(): void;
  46335. /**
  46336. * Instantiate a new istance of clear coat configuration.
  46337. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46338. */
  46339. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46340. /**
  46341. * Specifies that the submesh is ready to be used.
  46342. * @param defines the list of "defines" to update.
  46343. * @param scene defines the scene the material belongs to.
  46344. * @returns - boolean indicating that the submesh is ready or not.
  46345. */
  46346. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46347. /**
  46348. * Checks to see if a texture is used in the material.
  46349. * @param defines the list of "defines" to update.
  46350. * @param scene defines the scene the material belongs to.
  46351. */
  46352. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46353. /**
  46354. * Binds the material data.
  46355. * @param uniformBuffer defines the Uniform buffer to fill in.
  46356. * @param scene defines the scene the material belongs to.
  46357. * @param isFrozen defines wether the material is frozen or not.
  46358. */
  46359. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46360. /**
  46361. * Checks to see if a texture is used in the material.
  46362. * @param texture - Base texture to use.
  46363. * @returns - Boolean specifying if a texture is used in the material.
  46364. */
  46365. hasTexture(texture: BaseTexture): boolean;
  46366. /**
  46367. * Returns an array of the actively used textures.
  46368. * @param activeTextures Array of BaseTextures
  46369. */
  46370. getActiveTextures(activeTextures: BaseTexture[]): void;
  46371. /**
  46372. * Returns the animatable textures.
  46373. * @param animatables Array of animatable textures.
  46374. */
  46375. getAnimatables(animatables: IAnimatable[]): void;
  46376. /**
  46377. * Disposes the resources of the material.
  46378. * @param forceDisposeTextures - Forces the disposal of all textures.
  46379. */
  46380. dispose(forceDisposeTextures?: boolean): void;
  46381. /**
  46382. * Get the current class name of the texture useful for serialization or dynamic coding.
  46383. * @returns "PBRSheenConfiguration"
  46384. */
  46385. getClassName(): string;
  46386. /**
  46387. * Add fallbacks to the effect fallbacks list.
  46388. * @param defines defines the Base texture to use.
  46389. * @param fallbacks defines the current fallback list.
  46390. * @param currentRank defines the current fallback rank.
  46391. * @returns the new fallback rank.
  46392. */
  46393. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46394. /**
  46395. * Add the required uniforms to the current list.
  46396. * @param uniforms defines the current uniform list.
  46397. */
  46398. static AddUniforms(uniforms: string[]): void;
  46399. /**
  46400. * Add the required uniforms to the current buffer.
  46401. * @param uniformBuffer defines the current uniform buffer.
  46402. */
  46403. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46404. /**
  46405. * Add the required samplers to the current list.
  46406. * @param samplers defines the current sampler list.
  46407. */
  46408. static AddSamplers(samplers: string[]): void;
  46409. /**
  46410. * Makes a duplicate of the current configuration into another one.
  46411. * @param sheenConfiguration define the config where to copy the info
  46412. */
  46413. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46414. /**
  46415. * Serializes this BRDF configuration.
  46416. * @returns - An object with the serialized config.
  46417. */
  46418. serialize(): any;
  46419. /**
  46420. * Parses a Sheen Configuration from a serialized object.
  46421. * @param source - Serialized object.
  46422. */
  46423. parse(source: any): void;
  46424. }
  46425. }
  46426. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46427. import { Nullable } from "babylonjs/types";
  46428. import { IAnimatable } from "babylonjs/Misc/tools";
  46429. import { Color3 } from "babylonjs/Maths/math";
  46430. import { SmartArray } from "babylonjs/Misc/smartArray";
  46431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46432. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46433. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46434. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46435. import { Engine } from "babylonjs/Engines/engine";
  46436. import { Scene } from "babylonjs/scene";
  46437. /**
  46438. * @hidden
  46439. */
  46440. export interface IMaterialSubSurfaceDefines {
  46441. SUBSURFACE: boolean;
  46442. SS_REFRACTION: boolean;
  46443. SS_TRANSLUCENCY: boolean;
  46444. SS_SCATERRING: boolean;
  46445. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46446. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46447. SS_REFRACTIONMAP_3D: boolean;
  46448. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46449. SS_LODINREFRACTIONALPHA: boolean;
  46450. SS_GAMMAREFRACTION: boolean;
  46451. SS_RGBDREFRACTION: boolean;
  46452. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46453. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46454. /** @hidden */
  46455. _areTexturesDirty: boolean;
  46456. }
  46457. /**
  46458. * Define the code related to the sub surface parameters of the pbr material.
  46459. */
  46460. export class PBRSubSurfaceConfiguration {
  46461. private _isRefractionEnabled;
  46462. /**
  46463. * Defines if the refraction is enabled in the material.
  46464. */
  46465. isRefractionEnabled: boolean;
  46466. private _isTranslucencyEnabled;
  46467. /**
  46468. * Defines if the translucency is enabled in the material.
  46469. */
  46470. isTranslucencyEnabled: boolean;
  46471. private _isScatteringEnabled;
  46472. /**
  46473. * Defines the refraction intensity of the material.
  46474. * The refraction when enabled replaces the Diffuse part of the material.
  46475. * The intensity helps transitionning between diffuse and refraction.
  46476. */
  46477. refractionIntensity: number;
  46478. /**
  46479. * Defines the translucency intensity of the material.
  46480. * When translucency has been enabled, this defines how much of the "translucency"
  46481. * is addded to the diffuse part of the material.
  46482. */
  46483. translucencyIntensity: number;
  46484. /**
  46485. * Defines the scattering intensity of the material.
  46486. * When scattering has been enabled, this defines how much of the "scattered light"
  46487. * is addded to the diffuse part of the material.
  46488. */
  46489. scatteringIntensity: number;
  46490. private _thicknessTexture;
  46491. /**
  46492. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46493. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46494. * 0 would mean minimumThickness
  46495. * 1 would mean maximumThickness
  46496. * The other channels might be use as a mask to vary the different effects intensity.
  46497. */
  46498. thicknessTexture: Nullable<BaseTexture>;
  46499. private _refractionTexture;
  46500. /**
  46501. * Defines the texture to use for refraction.
  46502. */
  46503. refractionTexture: Nullable<BaseTexture>;
  46504. private _indexOfRefraction;
  46505. /**
  46506. * Defines the indice of refraction used in the material.
  46507. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46508. */
  46509. indexOfRefraction: number;
  46510. private _invertRefractionY;
  46511. /**
  46512. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46513. */
  46514. invertRefractionY: boolean;
  46515. private _linkRefractionWithTransparency;
  46516. /**
  46517. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46518. * Materials half opaque for instance using refraction could benefit from this control.
  46519. */
  46520. linkRefractionWithTransparency: boolean;
  46521. /**
  46522. * Defines the minimum thickness stored in the thickness map.
  46523. * If no thickness map is defined, this value will be used to simulate thickness.
  46524. */
  46525. minimumThickness: number;
  46526. /**
  46527. * Defines the maximum thickness stored in the thickness map.
  46528. */
  46529. maximumThickness: number;
  46530. /**
  46531. * Defines the volume tint of the material.
  46532. * This is used for both translucency and scattering.
  46533. */
  46534. tintColor: Color3;
  46535. /**
  46536. * Defines the distance at which the tint color should be found in the media.
  46537. * This is used for refraction only.
  46538. */
  46539. tintColorAtDistance: number;
  46540. /**
  46541. * Defines how far each channel transmit through the media.
  46542. * It is defined as a color to simplify it selection.
  46543. */
  46544. diffusionDistance: Color3;
  46545. private _useMaskFromThicknessTexture;
  46546. /**
  46547. * Stores the intensity of the different subsurface effects in the thickness texture.
  46548. * * the green channel is the translucency intensity.
  46549. * * the blue channel is the scattering intensity.
  46550. * * the alpha channel is the refraction intensity.
  46551. */
  46552. useMaskFromThicknessTexture: boolean;
  46553. /** @hidden */
  46554. private _internalMarkAllSubMeshesAsTexturesDirty;
  46555. /** @hidden */
  46556. _markAllSubMeshesAsTexturesDirty(): void;
  46557. /**
  46558. * Instantiate a new istance of sub surface configuration.
  46559. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46560. */
  46561. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46562. /**
  46563. * Gets wehter the submesh is ready to be used or not.
  46564. * @param defines the list of "defines" to update.
  46565. * @param scene defines the scene the material belongs to.
  46566. * @returns - boolean indicating that the submesh is ready or not.
  46567. */
  46568. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46569. /**
  46570. * Checks to see if a texture is used in the material.
  46571. * @param defines the list of "defines" to update.
  46572. * @param scene defines the scene to the material belongs to.
  46573. */
  46574. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46575. /**
  46576. * Binds the material data.
  46577. * @param uniformBuffer defines the Uniform buffer to fill in.
  46578. * @param scene defines the scene the material belongs to.
  46579. * @param engine defines the engine the material belongs to.
  46580. * @param isFrozen defines wether the material is frozen or not.
  46581. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46582. */
  46583. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46584. /**
  46585. * Unbinds the material from the mesh.
  46586. * @param activeEffect defines the effect that should be unbound from.
  46587. * @returns true if unbound, otherwise false
  46588. */
  46589. unbind(activeEffect: Effect): boolean;
  46590. /**
  46591. * Returns the texture used for refraction or null if none is used.
  46592. * @param scene defines the scene the material belongs to.
  46593. * @returns - Refraction texture if present. If no refraction texture and refraction
  46594. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46595. */
  46596. private _getRefractionTexture;
  46597. /**
  46598. * Returns true if alpha blending should be disabled.
  46599. */
  46600. readonly disableAlphaBlending: boolean;
  46601. /**
  46602. * Fills the list of render target textures.
  46603. * @param renderTargets the list of render targets to update
  46604. */
  46605. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46606. /**
  46607. * Checks to see if a texture is used in the material.
  46608. * @param texture - Base texture to use.
  46609. * @returns - Boolean specifying if a texture is used in the material.
  46610. */
  46611. hasTexture(texture: BaseTexture): boolean;
  46612. /**
  46613. * Gets a boolean indicating that current material needs to register RTT
  46614. * @returns true if this uses a render target otherwise false.
  46615. */
  46616. hasRenderTargetTextures(): boolean;
  46617. /**
  46618. * Returns an array of the actively used textures.
  46619. * @param activeTextures Array of BaseTextures
  46620. */
  46621. getActiveTextures(activeTextures: BaseTexture[]): void;
  46622. /**
  46623. * Returns the animatable textures.
  46624. * @param animatables Array of animatable textures.
  46625. */
  46626. getAnimatables(animatables: IAnimatable[]): void;
  46627. /**
  46628. * Disposes the resources of the material.
  46629. * @param forceDisposeTextures - Forces the disposal of all textures.
  46630. */
  46631. dispose(forceDisposeTextures?: boolean): void;
  46632. /**
  46633. * Get the current class name of the texture useful for serialization or dynamic coding.
  46634. * @returns "PBRSubSurfaceConfiguration"
  46635. */
  46636. getClassName(): string;
  46637. /**
  46638. * Add fallbacks to the effect fallbacks list.
  46639. * @param defines defines the Base texture to use.
  46640. * @param fallbacks defines the current fallback list.
  46641. * @param currentRank defines the current fallback rank.
  46642. * @returns the new fallback rank.
  46643. */
  46644. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46645. /**
  46646. * Add the required uniforms to the current list.
  46647. * @param uniforms defines the current uniform list.
  46648. */
  46649. static AddUniforms(uniforms: string[]): void;
  46650. /**
  46651. * Add the required samplers to the current list.
  46652. * @param samplers defines the current sampler list.
  46653. */
  46654. static AddSamplers(samplers: string[]): void;
  46655. /**
  46656. * Add the required uniforms to the current buffer.
  46657. * @param uniformBuffer defines the current uniform buffer.
  46658. */
  46659. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46660. /**
  46661. * Makes a duplicate of the current configuration into another one.
  46662. * @param configuration define the config where to copy the info
  46663. */
  46664. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46665. /**
  46666. * Serializes this Sub Surface configuration.
  46667. * @returns - An object with the serialized config.
  46668. */
  46669. serialize(): any;
  46670. /**
  46671. * Parses a Sub Surface Configuration from a serialized object.
  46672. * @param source - Serialized object.
  46673. */
  46674. parse(source: any): void;
  46675. }
  46676. }
  46677. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46678. /** @hidden */
  46679. export var pbrFragmentDeclaration: {
  46680. name: string;
  46681. shader: string;
  46682. };
  46683. }
  46684. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46685. /** @hidden */
  46686. export var pbrUboDeclaration: {
  46687. name: string;
  46688. shader: string;
  46689. };
  46690. }
  46691. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46692. /** @hidden */
  46693. export var pbrFragmentExtraDeclaration: {
  46694. name: string;
  46695. shader: string;
  46696. };
  46697. }
  46698. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46699. /** @hidden */
  46700. export var pbrFragmentSamplersDeclaration: {
  46701. name: string;
  46702. shader: string;
  46703. };
  46704. }
  46705. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46706. /** @hidden */
  46707. export var pbrHelperFunctions: {
  46708. name: string;
  46709. shader: string;
  46710. };
  46711. }
  46712. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46713. /** @hidden */
  46714. export var harmonicsFunctions: {
  46715. name: string;
  46716. shader: string;
  46717. };
  46718. }
  46719. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46720. /** @hidden */
  46721. export var pbrDirectLightingSetupFunctions: {
  46722. name: string;
  46723. shader: string;
  46724. };
  46725. }
  46726. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46727. /** @hidden */
  46728. export var pbrDirectLightingFalloffFunctions: {
  46729. name: string;
  46730. shader: string;
  46731. };
  46732. }
  46733. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46734. /** @hidden */
  46735. export var pbrBRDFFunctions: {
  46736. name: string;
  46737. shader: string;
  46738. };
  46739. }
  46740. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46741. /** @hidden */
  46742. export var pbrDirectLightingFunctions: {
  46743. name: string;
  46744. shader: string;
  46745. };
  46746. }
  46747. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46748. /** @hidden */
  46749. export var pbrIBLFunctions: {
  46750. name: string;
  46751. shader: string;
  46752. };
  46753. }
  46754. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46755. /** @hidden */
  46756. export var pbrDebug: {
  46757. name: string;
  46758. shader: string;
  46759. };
  46760. }
  46761. declare module "babylonjs/Shaders/pbr.fragment" {
  46762. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46763. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46764. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46765. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46766. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46767. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46768. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46769. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46770. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46771. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46772. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46773. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46774. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46775. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46776. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46777. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46778. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46779. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46780. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46781. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46782. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46783. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46784. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46785. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46786. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46787. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46788. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46789. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46790. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46791. /** @hidden */
  46792. export var pbrPixelShader: {
  46793. name: string;
  46794. shader: string;
  46795. };
  46796. }
  46797. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46798. /** @hidden */
  46799. export var pbrVertexDeclaration: {
  46800. name: string;
  46801. shader: string;
  46802. };
  46803. }
  46804. declare module "babylonjs/Shaders/pbr.vertex" {
  46805. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46806. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46807. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46808. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46809. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46810. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46811. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46812. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46813. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46814. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46815. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46818. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46819. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46820. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46821. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46822. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46823. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46824. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46825. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46826. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46827. /** @hidden */
  46828. export var pbrVertexShader: {
  46829. name: string;
  46830. shader: string;
  46831. };
  46832. }
  46833. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46834. import { IAnimatable } from "babylonjs/Misc/tools";
  46835. import { Nullable } from "babylonjs/types";
  46836. import { Scene } from "babylonjs/scene";
  46837. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46838. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46840. import { Mesh } from "babylonjs/Meshes/mesh";
  46841. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46842. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46843. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46844. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46845. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46846. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46847. import { Material } from "babylonjs/Materials/material";
  46848. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46849. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46851. import "babylonjs/Shaders/pbr.fragment";
  46852. import "babylonjs/Shaders/pbr.vertex";
  46853. /**
  46854. * Manages the defines for the PBR Material.
  46855. * @hidden
  46856. */
  46857. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46858. PBR: boolean;
  46859. MAINUV1: boolean;
  46860. MAINUV2: boolean;
  46861. UV1: boolean;
  46862. UV2: boolean;
  46863. ALBEDO: boolean;
  46864. ALBEDODIRECTUV: number;
  46865. VERTEXCOLOR: boolean;
  46866. AMBIENT: boolean;
  46867. AMBIENTDIRECTUV: number;
  46868. AMBIENTINGRAYSCALE: boolean;
  46869. OPACITY: boolean;
  46870. VERTEXALPHA: boolean;
  46871. OPACITYDIRECTUV: number;
  46872. OPACITYRGB: boolean;
  46873. ALPHATEST: boolean;
  46874. DEPTHPREPASS: boolean;
  46875. ALPHABLEND: boolean;
  46876. ALPHAFROMALBEDO: boolean;
  46877. ALPHATESTVALUE: string;
  46878. SPECULAROVERALPHA: boolean;
  46879. RADIANCEOVERALPHA: boolean;
  46880. ALPHAFRESNEL: boolean;
  46881. LINEARALPHAFRESNEL: boolean;
  46882. PREMULTIPLYALPHA: boolean;
  46883. EMISSIVE: boolean;
  46884. EMISSIVEDIRECTUV: number;
  46885. REFLECTIVITY: boolean;
  46886. REFLECTIVITYDIRECTUV: number;
  46887. SPECULARTERM: boolean;
  46888. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46889. MICROSURFACEAUTOMATIC: boolean;
  46890. LODBASEDMICROSFURACE: boolean;
  46891. MICROSURFACEMAP: boolean;
  46892. MICROSURFACEMAPDIRECTUV: number;
  46893. METALLICWORKFLOW: boolean;
  46894. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46895. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46896. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46897. AOSTOREINMETALMAPRED: boolean;
  46898. ENVIRONMENTBRDF: boolean;
  46899. ENVIRONMENTBRDF_RGBD: boolean;
  46900. NORMAL: boolean;
  46901. TANGENT: boolean;
  46902. BUMP: boolean;
  46903. BUMPDIRECTUV: number;
  46904. OBJECTSPACE_NORMALMAP: boolean;
  46905. PARALLAX: boolean;
  46906. PARALLAXOCCLUSION: boolean;
  46907. NORMALXYSCALE: boolean;
  46908. LIGHTMAP: boolean;
  46909. LIGHTMAPDIRECTUV: number;
  46910. USELIGHTMAPASSHADOWMAP: boolean;
  46911. GAMMALIGHTMAP: boolean;
  46912. REFLECTION: boolean;
  46913. REFLECTIONMAP_3D: boolean;
  46914. REFLECTIONMAP_SPHERICAL: boolean;
  46915. REFLECTIONMAP_PLANAR: boolean;
  46916. REFLECTIONMAP_CUBIC: boolean;
  46917. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46918. REFLECTIONMAP_PROJECTION: boolean;
  46919. REFLECTIONMAP_SKYBOX: boolean;
  46920. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46921. REFLECTIONMAP_EXPLICIT: boolean;
  46922. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46923. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46924. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46925. INVERTCUBICMAP: boolean;
  46926. USESPHERICALFROMREFLECTIONMAP: boolean;
  46927. SPHERICAL_HARMONICS: boolean;
  46928. USESPHERICALINVERTEX: boolean;
  46929. REFLECTIONMAP_OPPOSITEZ: boolean;
  46930. LODINREFLECTIONALPHA: boolean;
  46931. GAMMAREFLECTION: boolean;
  46932. RGBDREFLECTION: boolean;
  46933. RADIANCEOCCLUSION: boolean;
  46934. HORIZONOCCLUSION: boolean;
  46935. INSTANCES: boolean;
  46936. NUM_BONE_INFLUENCERS: number;
  46937. BonesPerMesh: number;
  46938. BONETEXTURE: boolean;
  46939. NONUNIFORMSCALING: boolean;
  46940. MORPHTARGETS: boolean;
  46941. MORPHTARGETS_NORMAL: boolean;
  46942. MORPHTARGETS_TANGENT: boolean;
  46943. NUM_MORPH_INFLUENCERS: number;
  46944. IMAGEPROCESSING: boolean;
  46945. VIGNETTE: boolean;
  46946. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46947. VIGNETTEBLENDMODEOPAQUE: boolean;
  46948. TONEMAPPING: boolean;
  46949. TONEMAPPING_ACES: boolean;
  46950. CONTRAST: boolean;
  46951. COLORCURVES: boolean;
  46952. COLORGRADING: boolean;
  46953. COLORGRADING3D: boolean;
  46954. SAMPLER3DGREENDEPTH: boolean;
  46955. SAMPLER3DBGRMAP: boolean;
  46956. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46957. EXPOSURE: boolean;
  46958. MULTIVIEW: boolean;
  46959. USEPHYSICALLIGHTFALLOFF: boolean;
  46960. USEGLTFLIGHTFALLOFF: boolean;
  46961. TWOSIDEDLIGHTING: boolean;
  46962. SHADOWFLOAT: boolean;
  46963. CLIPPLANE: boolean;
  46964. CLIPPLANE2: boolean;
  46965. CLIPPLANE3: boolean;
  46966. CLIPPLANE4: boolean;
  46967. POINTSIZE: boolean;
  46968. FOG: boolean;
  46969. LOGARITHMICDEPTH: boolean;
  46970. FORCENORMALFORWARD: boolean;
  46971. SPECULARAA: boolean;
  46972. CLEARCOAT: boolean;
  46973. CLEARCOAT_DEFAULTIOR: boolean;
  46974. CLEARCOAT_TEXTURE: boolean;
  46975. CLEARCOAT_TEXTUREDIRECTUV: number;
  46976. CLEARCOAT_BUMP: boolean;
  46977. CLEARCOAT_BUMPDIRECTUV: number;
  46978. CLEARCOAT_TINT: boolean;
  46979. CLEARCOAT_TINT_TEXTURE: boolean;
  46980. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46981. ANISOTROPIC: boolean;
  46982. ANISOTROPIC_TEXTURE: boolean;
  46983. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46984. BRDF_V_HEIGHT_CORRELATED: boolean;
  46985. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46986. SHEEN: boolean;
  46987. SHEEN_TEXTURE: boolean;
  46988. SHEEN_TEXTUREDIRECTUV: number;
  46989. SHEEN_LINKWITHALBEDO: boolean;
  46990. SUBSURFACE: boolean;
  46991. SS_REFRACTION: boolean;
  46992. SS_TRANSLUCENCY: boolean;
  46993. SS_SCATERRING: boolean;
  46994. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46995. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46996. SS_REFRACTIONMAP_3D: boolean;
  46997. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46998. SS_LODINREFRACTIONALPHA: boolean;
  46999. SS_GAMMAREFRACTION: boolean;
  47000. SS_RGBDREFRACTION: boolean;
  47001. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47002. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47003. UNLIT: boolean;
  47004. DEBUGMODE: number;
  47005. /**
  47006. * Initializes the PBR Material defines.
  47007. */
  47008. constructor();
  47009. /**
  47010. * Resets the PBR Material defines.
  47011. */
  47012. reset(): void;
  47013. }
  47014. /**
  47015. * The Physically based material base class of BJS.
  47016. *
  47017. * This offers the main features of a standard PBR material.
  47018. * For more information, please refer to the documentation :
  47019. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47020. */
  47021. export abstract class PBRBaseMaterial extends PushMaterial {
  47022. /**
  47023. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47024. */
  47025. static readonly PBRMATERIAL_OPAQUE: number;
  47026. /**
  47027. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47028. */
  47029. static readonly PBRMATERIAL_ALPHATEST: number;
  47030. /**
  47031. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47032. */
  47033. static readonly PBRMATERIAL_ALPHABLEND: number;
  47034. /**
  47035. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47036. * They are also discarded below the alpha cutoff threshold to improve performances.
  47037. */
  47038. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47039. /**
  47040. * Defines the default value of how much AO map is occluding the analytical lights
  47041. * (point spot...).
  47042. */
  47043. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47044. /**
  47045. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47046. */
  47047. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47048. /**
  47049. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47050. * to enhance interoperability with other engines.
  47051. */
  47052. static readonly LIGHTFALLOFF_GLTF: number;
  47053. /**
  47054. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47055. * to enhance interoperability with other materials.
  47056. */
  47057. static readonly LIGHTFALLOFF_STANDARD: number;
  47058. /**
  47059. * Intensity of the direct lights e.g. the four lights available in your scene.
  47060. * This impacts both the direct diffuse and specular highlights.
  47061. */
  47062. protected _directIntensity: number;
  47063. /**
  47064. * Intensity of the emissive part of the material.
  47065. * This helps controlling the emissive effect without modifying the emissive color.
  47066. */
  47067. protected _emissiveIntensity: number;
  47068. /**
  47069. * Intensity of the environment e.g. how much the environment will light the object
  47070. * either through harmonics for rough material or through the refelction for shiny ones.
  47071. */
  47072. protected _environmentIntensity: number;
  47073. /**
  47074. * This is a special control allowing the reduction of the specular highlights coming from the
  47075. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47076. */
  47077. protected _specularIntensity: number;
  47078. /**
  47079. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47080. */
  47081. private _lightingInfos;
  47082. /**
  47083. * Debug Control allowing disabling the bump map on this material.
  47084. */
  47085. protected _disableBumpMap: boolean;
  47086. /**
  47087. * AKA Diffuse Texture in standard nomenclature.
  47088. */
  47089. protected _albedoTexture: Nullable<BaseTexture>;
  47090. /**
  47091. * AKA Occlusion Texture in other nomenclature.
  47092. */
  47093. protected _ambientTexture: Nullable<BaseTexture>;
  47094. /**
  47095. * AKA Occlusion Texture Intensity in other nomenclature.
  47096. */
  47097. protected _ambientTextureStrength: number;
  47098. /**
  47099. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47100. * 1 means it completely occludes it
  47101. * 0 mean it has no impact
  47102. */
  47103. protected _ambientTextureImpactOnAnalyticalLights: number;
  47104. /**
  47105. * Stores the alpha values in a texture.
  47106. */
  47107. protected _opacityTexture: Nullable<BaseTexture>;
  47108. /**
  47109. * Stores the reflection values in a texture.
  47110. */
  47111. protected _reflectionTexture: Nullable<BaseTexture>;
  47112. /**
  47113. * Stores the emissive values in a texture.
  47114. */
  47115. protected _emissiveTexture: Nullable<BaseTexture>;
  47116. /**
  47117. * AKA Specular texture in other nomenclature.
  47118. */
  47119. protected _reflectivityTexture: Nullable<BaseTexture>;
  47120. /**
  47121. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47122. */
  47123. protected _metallicTexture: Nullable<BaseTexture>;
  47124. /**
  47125. * Specifies the metallic scalar of the metallic/roughness workflow.
  47126. * Can also be used to scale the metalness values of the metallic texture.
  47127. */
  47128. protected _metallic: Nullable<number>;
  47129. /**
  47130. * Specifies the roughness scalar of the metallic/roughness workflow.
  47131. * Can also be used to scale the roughness values of the metallic texture.
  47132. */
  47133. protected _roughness: Nullable<number>;
  47134. /**
  47135. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47136. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47137. */
  47138. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47139. /**
  47140. * Stores surface normal data used to displace a mesh in a texture.
  47141. */
  47142. protected _bumpTexture: Nullable<BaseTexture>;
  47143. /**
  47144. * Stores the pre-calculated light information of a mesh in a texture.
  47145. */
  47146. protected _lightmapTexture: Nullable<BaseTexture>;
  47147. /**
  47148. * The color of a material in ambient lighting.
  47149. */
  47150. protected _ambientColor: Color3;
  47151. /**
  47152. * AKA Diffuse Color in other nomenclature.
  47153. */
  47154. protected _albedoColor: Color3;
  47155. /**
  47156. * AKA Specular Color in other nomenclature.
  47157. */
  47158. protected _reflectivityColor: Color3;
  47159. /**
  47160. * The color applied when light is reflected from a material.
  47161. */
  47162. protected _reflectionColor: Color3;
  47163. /**
  47164. * The color applied when light is emitted from a material.
  47165. */
  47166. protected _emissiveColor: Color3;
  47167. /**
  47168. * AKA Glossiness in other nomenclature.
  47169. */
  47170. protected _microSurface: number;
  47171. /**
  47172. * Specifies that the material will use the light map as a show map.
  47173. */
  47174. protected _useLightmapAsShadowmap: boolean;
  47175. /**
  47176. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47177. * makes the reflect vector face the model (under horizon).
  47178. */
  47179. protected _useHorizonOcclusion: boolean;
  47180. /**
  47181. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47182. * too much the area relying on ambient texture to define their ambient occlusion.
  47183. */
  47184. protected _useRadianceOcclusion: boolean;
  47185. /**
  47186. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47187. */
  47188. protected _useAlphaFromAlbedoTexture: boolean;
  47189. /**
  47190. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47191. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47192. */
  47193. protected _useSpecularOverAlpha: boolean;
  47194. /**
  47195. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47196. */
  47197. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47198. /**
  47199. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47200. */
  47201. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47202. /**
  47203. * Specifies if the metallic texture contains the roughness information in its green channel.
  47204. */
  47205. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47206. /**
  47207. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47208. */
  47209. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47210. /**
  47211. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47212. */
  47213. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47214. /**
  47215. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47216. */
  47217. protected _useAmbientInGrayScale: boolean;
  47218. /**
  47219. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47220. * The material will try to infer what glossiness each pixel should be.
  47221. */
  47222. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47223. /**
  47224. * Defines the falloff type used in this material.
  47225. * It by default is Physical.
  47226. */
  47227. protected _lightFalloff: number;
  47228. /**
  47229. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47230. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47231. */
  47232. protected _useRadianceOverAlpha: boolean;
  47233. /**
  47234. * Allows using an object space normal map (instead of tangent space).
  47235. */
  47236. protected _useObjectSpaceNormalMap: boolean;
  47237. /**
  47238. * Allows using the bump map in parallax mode.
  47239. */
  47240. protected _useParallax: boolean;
  47241. /**
  47242. * Allows using the bump map in parallax occlusion mode.
  47243. */
  47244. protected _useParallaxOcclusion: boolean;
  47245. /**
  47246. * Controls the scale bias of the parallax mode.
  47247. */
  47248. protected _parallaxScaleBias: number;
  47249. /**
  47250. * If sets to true, disables all the lights affecting the material.
  47251. */
  47252. protected _disableLighting: boolean;
  47253. /**
  47254. * Number of Simultaneous lights allowed on the material.
  47255. */
  47256. protected _maxSimultaneousLights: number;
  47257. /**
  47258. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47259. */
  47260. protected _invertNormalMapX: boolean;
  47261. /**
  47262. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47263. */
  47264. protected _invertNormalMapY: boolean;
  47265. /**
  47266. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47267. */
  47268. protected _twoSidedLighting: boolean;
  47269. /**
  47270. * Defines the alpha limits in alpha test mode.
  47271. */
  47272. protected _alphaCutOff: number;
  47273. /**
  47274. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47275. */
  47276. protected _forceAlphaTest: boolean;
  47277. /**
  47278. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47279. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47280. */
  47281. protected _useAlphaFresnel: boolean;
  47282. /**
  47283. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47284. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47285. */
  47286. protected _useLinearAlphaFresnel: boolean;
  47287. /**
  47288. * The transparency mode of the material.
  47289. */
  47290. protected _transparencyMode: Nullable<number>;
  47291. /**
  47292. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47293. * from cos thetav and roughness:
  47294. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47295. */
  47296. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47297. /**
  47298. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47299. */
  47300. protected _forceIrradianceInFragment: boolean;
  47301. /**
  47302. * Force normal to face away from face.
  47303. */
  47304. protected _forceNormalForward: boolean;
  47305. /**
  47306. * Enables specular anti aliasing in the PBR shader.
  47307. * It will both interacts on the Geometry for analytical and IBL lighting.
  47308. * It also prefilter the roughness map based on the bump values.
  47309. */
  47310. protected _enableSpecularAntiAliasing: boolean;
  47311. /**
  47312. * Default configuration related to image processing available in the PBR Material.
  47313. */
  47314. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47315. /**
  47316. * Keep track of the image processing observer to allow dispose and replace.
  47317. */
  47318. private _imageProcessingObserver;
  47319. /**
  47320. * Attaches a new image processing configuration to the PBR Material.
  47321. * @param configuration
  47322. */
  47323. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47324. /**
  47325. * Stores the available render targets.
  47326. */
  47327. private _renderTargets;
  47328. /**
  47329. * Sets the global ambient color for the material used in lighting calculations.
  47330. */
  47331. private _globalAmbientColor;
  47332. /**
  47333. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47334. */
  47335. private _useLogarithmicDepth;
  47336. /**
  47337. * If set to true, no lighting calculations will be applied.
  47338. */
  47339. private _unlit;
  47340. private _debugMode;
  47341. /**
  47342. * @hidden
  47343. * This is reserved for the inspector.
  47344. * Defines the material debug mode.
  47345. * It helps seeing only some components of the material while troubleshooting.
  47346. */
  47347. debugMode: number;
  47348. /**
  47349. * @hidden
  47350. * This is reserved for the inspector.
  47351. * Specify from where on screen the debug mode should start.
  47352. * The value goes from -1 (full screen) to 1 (not visible)
  47353. * It helps with side by side comparison against the final render
  47354. * This defaults to -1
  47355. */
  47356. private debugLimit;
  47357. /**
  47358. * @hidden
  47359. * This is reserved for the inspector.
  47360. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47361. * You can use the factor to better multiply the final value.
  47362. */
  47363. private debugFactor;
  47364. /**
  47365. * Defines the clear coat layer parameters for the material.
  47366. */
  47367. readonly clearCoat: PBRClearCoatConfiguration;
  47368. /**
  47369. * Defines the anisotropic parameters for the material.
  47370. */
  47371. readonly anisotropy: PBRAnisotropicConfiguration;
  47372. /**
  47373. * Defines the BRDF parameters for the material.
  47374. */
  47375. readonly brdf: PBRBRDFConfiguration;
  47376. /**
  47377. * Defines the Sheen parameters for the material.
  47378. */
  47379. readonly sheen: PBRSheenConfiguration;
  47380. /**
  47381. * Defines the SubSurface parameters for the material.
  47382. */
  47383. readonly subSurface: PBRSubSurfaceConfiguration;
  47384. /**
  47385. * Custom callback helping to override the default shader used in the material.
  47386. */
  47387. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47388. /**
  47389. * Instantiates a new PBRMaterial instance.
  47390. *
  47391. * @param name The material name
  47392. * @param scene The scene the material will be use in.
  47393. */
  47394. constructor(name: string, scene: Scene);
  47395. /**
  47396. * Gets a boolean indicating that current material needs to register RTT
  47397. */
  47398. readonly hasRenderTargetTextures: boolean;
  47399. /**
  47400. * Gets the name of the material class.
  47401. */
  47402. getClassName(): string;
  47403. /**
  47404. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47405. */
  47406. /**
  47407. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47408. */
  47409. useLogarithmicDepth: boolean;
  47410. /**
  47411. * Gets the current transparency mode.
  47412. */
  47413. /**
  47414. * Sets the transparency mode of the material.
  47415. *
  47416. * | Value | Type | Description |
  47417. * | ----- | ----------------------------------- | ----------- |
  47418. * | 0 | OPAQUE | |
  47419. * | 1 | ALPHATEST | |
  47420. * | 2 | ALPHABLEND | |
  47421. * | 3 | ALPHATESTANDBLEND | |
  47422. *
  47423. */
  47424. transparencyMode: Nullable<number>;
  47425. /**
  47426. * Returns true if alpha blending should be disabled.
  47427. */
  47428. private readonly _disableAlphaBlending;
  47429. /**
  47430. * Specifies whether or not this material should be rendered in alpha blend mode.
  47431. */
  47432. needAlphaBlending(): boolean;
  47433. /**
  47434. * Specifies if the mesh will require alpha blending.
  47435. * @param mesh - BJS mesh.
  47436. */
  47437. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47438. /**
  47439. * Specifies whether or not this material should be rendered in alpha test mode.
  47440. */
  47441. needAlphaTesting(): boolean;
  47442. /**
  47443. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47444. */
  47445. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47446. /**
  47447. * Gets the texture used for the alpha test.
  47448. */
  47449. getAlphaTestTexture(): Nullable<BaseTexture>;
  47450. /**
  47451. * Specifies that the submesh is ready to be used.
  47452. * @param mesh - BJS mesh.
  47453. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47454. * @param useInstances - Specifies that instances should be used.
  47455. * @returns - boolean indicating that the submesh is ready or not.
  47456. */
  47457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47458. /**
  47459. * Specifies if the material uses metallic roughness workflow.
  47460. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47461. */
  47462. isMetallicWorkflow(): boolean;
  47463. private _prepareEffect;
  47464. private _prepareDefines;
  47465. /**
  47466. * Force shader compilation
  47467. */
  47468. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47469. clipPlane: boolean;
  47470. }>): void;
  47471. /**
  47472. * Initializes the uniform buffer layout for the shader.
  47473. */
  47474. buildUniformLayout(): void;
  47475. /**
  47476. * Unbinds the material from the mesh
  47477. */
  47478. unbind(): void;
  47479. /**
  47480. * Binds the submesh data.
  47481. * @param world - The world matrix.
  47482. * @param mesh - The BJS mesh.
  47483. * @param subMesh - A submesh of the BJS mesh.
  47484. */
  47485. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47486. /**
  47487. * Returns the animatable textures.
  47488. * @returns - Array of animatable textures.
  47489. */
  47490. getAnimatables(): IAnimatable[];
  47491. /**
  47492. * Returns the texture used for reflections.
  47493. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47494. */
  47495. private _getReflectionTexture;
  47496. /**
  47497. * Returns an array of the actively used textures.
  47498. * @returns - Array of BaseTextures
  47499. */
  47500. getActiveTextures(): BaseTexture[];
  47501. /**
  47502. * Checks to see if a texture is used in the material.
  47503. * @param texture - Base texture to use.
  47504. * @returns - Boolean specifying if a texture is used in the material.
  47505. */
  47506. hasTexture(texture: BaseTexture): boolean;
  47507. /**
  47508. * Disposes the resources of the material.
  47509. * @param forceDisposeEffect - Forces the disposal of effects.
  47510. * @param forceDisposeTextures - Forces the disposal of all textures.
  47511. */
  47512. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47513. }
  47514. }
  47515. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47516. import { Nullable } from "babylonjs/types";
  47517. import { Scene } from "babylonjs/scene";
  47518. import { Color3 } from "babylonjs/Maths/math";
  47519. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47520. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47522. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47523. /**
  47524. * The Physically based material of BJS.
  47525. *
  47526. * This offers the main features of a standard PBR material.
  47527. * For more information, please refer to the documentation :
  47528. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47529. */
  47530. export class PBRMaterial extends PBRBaseMaterial {
  47531. /**
  47532. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47533. */
  47534. static readonly PBRMATERIAL_OPAQUE: number;
  47535. /**
  47536. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47537. */
  47538. static readonly PBRMATERIAL_ALPHATEST: number;
  47539. /**
  47540. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47541. */
  47542. static readonly PBRMATERIAL_ALPHABLEND: number;
  47543. /**
  47544. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47545. * They are also discarded below the alpha cutoff threshold to improve performances.
  47546. */
  47547. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47548. /**
  47549. * Defines the default value of how much AO map is occluding the analytical lights
  47550. * (point spot...).
  47551. */
  47552. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47553. /**
  47554. * Intensity of the direct lights e.g. the four lights available in your scene.
  47555. * This impacts both the direct diffuse and specular highlights.
  47556. */
  47557. directIntensity: number;
  47558. /**
  47559. * Intensity of the emissive part of the material.
  47560. * This helps controlling the emissive effect without modifying the emissive color.
  47561. */
  47562. emissiveIntensity: number;
  47563. /**
  47564. * Intensity of the environment e.g. how much the environment will light the object
  47565. * either through harmonics for rough material or through the refelction for shiny ones.
  47566. */
  47567. environmentIntensity: number;
  47568. /**
  47569. * This is a special control allowing the reduction of the specular highlights coming from the
  47570. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47571. */
  47572. specularIntensity: number;
  47573. /**
  47574. * Debug Control allowing disabling the bump map on this material.
  47575. */
  47576. disableBumpMap: boolean;
  47577. /**
  47578. * AKA Diffuse Texture in standard nomenclature.
  47579. */
  47580. albedoTexture: BaseTexture;
  47581. /**
  47582. * AKA Occlusion Texture in other nomenclature.
  47583. */
  47584. ambientTexture: BaseTexture;
  47585. /**
  47586. * AKA Occlusion Texture Intensity in other nomenclature.
  47587. */
  47588. ambientTextureStrength: number;
  47589. /**
  47590. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47591. * 1 means it completely occludes it
  47592. * 0 mean it has no impact
  47593. */
  47594. ambientTextureImpactOnAnalyticalLights: number;
  47595. /**
  47596. * Stores the alpha values in a texture.
  47597. */
  47598. opacityTexture: BaseTexture;
  47599. /**
  47600. * Stores the reflection values in a texture.
  47601. */
  47602. reflectionTexture: Nullable<BaseTexture>;
  47603. /**
  47604. * Stores the emissive values in a texture.
  47605. */
  47606. emissiveTexture: BaseTexture;
  47607. /**
  47608. * AKA Specular texture in other nomenclature.
  47609. */
  47610. reflectivityTexture: BaseTexture;
  47611. /**
  47612. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47613. */
  47614. metallicTexture: BaseTexture;
  47615. /**
  47616. * Specifies the metallic scalar of the metallic/roughness workflow.
  47617. * Can also be used to scale the metalness values of the metallic texture.
  47618. */
  47619. metallic: Nullable<number>;
  47620. /**
  47621. * Specifies the roughness scalar of the metallic/roughness workflow.
  47622. * Can also be used to scale the roughness values of the metallic texture.
  47623. */
  47624. roughness: Nullable<number>;
  47625. /**
  47626. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47627. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47628. */
  47629. microSurfaceTexture: BaseTexture;
  47630. /**
  47631. * Stores surface normal data used to displace a mesh in a texture.
  47632. */
  47633. bumpTexture: BaseTexture;
  47634. /**
  47635. * Stores the pre-calculated light information of a mesh in a texture.
  47636. */
  47637. lightmapTexture: BaseTexture;
  47638. /**
  47639. * Stores the refracted light information in a texture.
  47640. */
  47641. refractionTexture: Nullable<BaseTexture>;
  47642. /**
  47643. * The color of a material in ambient lighting.
  47644. */
  47645. ambientColor: Color3;
  47646. /**
  47647. * AKA Diffuse Color in other nomenclature.
  47648. */
  47649. albedoColor: Color3;
  47650. /**
  47651. * AKA Specular Color in other nomenclature.
  47652. */
  47653. reflectivityColor: Color3;
  47654. /**
  47655. * The color reflected from the material.
  47656. */
  47657. reflectionColor: Color3;
  47658. /**
  47659. * The color emitted from the material.
  47660. */
  47661. emissiveColor: Color3;
  47662. /**
  47663. * AKA Glossiness in other nomenclature.
  47664. */
  47665. microSurface: number;
  47666. /**
  47667. * source material index of refraction (IOR)' / 'destination material IOR.
  47668. */
  47669. indexOfRefraction: number;
  47670. /**
  47671. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47672. */
  47673. invertRefractionY: boolean;
  47674. /**
  47675. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47676. * Materials half opaque for instance using refraction could benefit from this control.
  47677. */
  47678. linkRefractionWithTransparency: boolean;
  47679. /**
  47680. * If true, the light map contains occlusion information instead of lighting info.
  47681. */
  47682. useLightmapAsShadowmap: boolean;
  47683. /**
  47684. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47685. */
  47686. useAlphaFromAlbedoTexture: boolean;
  47687. /**
  47688. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47689. */
  47690. forceAlphaTest: boolean;
  47691. /**
  47692. * Defines the alpha limits in alpha test mode.
  47693. */
  47694. alphaCutOff: number;
  47695. /**
  47696. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47697. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47698. */
  47699. useSpecularOverAlpha: boolean;
  47700. /**
  47701. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47702. */
  47703. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47704. /**
  47705. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47706. */
  47707. useRoughnessFromMetallicTextureAlpha: boolean;
  47708. /**
  47709. * Specifies if the metallic texture contains the roughness information in its green channel.
  47710. */
  47711. useRoughnessFromMetallicTextureGreen: boolean;
  47712. /**
  47713. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47714. */
  47715. useMetallnessFromMetallicTextureBlue: boolean;
  47716. /**
  47717. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47718. */
  47719. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47720. /**
  47721. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47722. */
  47723. useAmbientInGrayScale: boolean;
  47724. /**
  47725. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47726. * The material will try to infer what glossiness each pixel should be.
  47727. */
  47728. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47729. /**
  47730. * BJS is using an harcoded light falloff based on a manually sets up range.
  47731. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47732. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47733. */
  47734. /**
  47735. * BJS is using an harcoded light falloff based on a manually sets up range.
  47736. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47737. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47738. */
  47739. usePhysicalLightFalloff: boolean;
  47740. /**
  47741. * In order to support the falloff compatibility with gltf, a special mode has been added
  47742. * to reproduce the gltf light falloff.
  47743. */
  47744. /**
  47745. * In order to support the falloff compatibility with gltf, a special mode has been added
  47746. * to reproduce the gltf light falloff.
  47747. */
  47748. useGLTFLightFalloff: boolean;
  47749. /**
  47750. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47751. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47752. */
  47753. useRadianceOverAlpha: boolean;
  47754. /**
  47755. * Allows using an object space normal map (instead of tangent space).
  47756. */
  47757. useObjectSpaceNormalMap: boolean;
  47758. /**
  47759. * Allows using the bump map in parallax mode.
  47760. */
  47761. useParallax: boolean;
  47762. /**
  47763. * Allows using the bump map in parallax occlusion mode.
  47764. */
  47765. useParallaxOcclusion: boolean;
  47766. /**
  47767. * Controls the scale bias of the parallax mode.
  47768. */
  47769. parallaxScaleBias: number;
  47770. /**
  47771. * If sets to true, disables all the lights affecting the material.
  47772. */
  47773. disableLighting: boolean;
  47774. /**
  47775. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47776. */
  47777. forceIrradianceInFragment: boolean;
  47778. /**
  47779. * Number of Simultaneous lights allowed on the material.
  47780. */
  47781. maxSimultaneousLights: number;
  47782. /**
  47783. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47784. */
  47785. invertNormalMapX: boolean;
  47786. /**
  47787. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47788. */
  47789. invertNormalMapY: boolean;
  47790. /**
  47791. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47792. */
  47793. twoSidedLighting: boolean;
  47794. /**
  47795. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47796. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47797. */
  47798. useAlphaFresnel: boolean;
  47799. /**
  47800. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47801. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47802. */
  47803. useLinearAlphaFresnel: boolean;
  47804. /**
  47805. * Let user defines the brdf lookup texture used for IBL.
  47806. * A default 8bit version is embedded but you could point at :
  47807. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47808. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47809. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47810. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47811. */
  47812. environmentBRDFTexture: Nullable<BaseTexture>;
  47813. /**
  47814. * Force normal to face away from face.
  47815. */
  47816. forceNormalForward: boolean;
  47817. /**
  47818. * Enables specular anti aliasing in the PBR shader.
  47819. * It will both interacts on the Geometry for analytical and IBL lighting.
  47820. * It also prefilter the roughness map based on the bump values.
  47821. */
  47822. enableSpecularAntiAliasing: boolean;
  47823. /**
  47824. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47825. * makes the reflect vector face the model (under horizon).
  47826. */
  47827. useHorizonOcclusion: boolean;
  47828. /**
  47829. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47830. * too much the area relying on ambient texture to define their ambient occlusion.
  47831. */
  47832. useRadianceOcclusion: boolean;
  47833. /**
  47834. * If set to true, no lighting calculations will be applied.
  47835. */
  47836. unlit: boolean;
  47837. /**
  47838. * Gets the image processing configuration used either in this material.
  47839. */
  47840. /**
  47841. * Sets the Default image processing configuration used either in the this material.
  47842. *
  47843. * If sets to null, the scene one is in use.
  47844. */
  47845. imageProcessingConfiguration: ImageProcessingConfiguration;
  47846. /**
  47847. * Gets wether the color curves effect is enabled.
  47848. */
  47849. /**
  47850. * Sets wether the color curves effect is enabled.
  47851. */
  47852. cameraColorCurvesEnabled: boolean;
  47853. /**
  47854. * Gets wether the color grading effect is enabled.
  47855. */
  47856. /**
  47857. * Gets wether the color grading effect is enabled.
  47858. */
  47859. cameraColorGradingEnabled: boolean;
  47860. /**
  47861. * Gets wether tonemapping is enabled or not.
  47862. */
  47863. /**
  47864. * Sets wether tonemapping is enabled or not
  47865. */
  47866. cameraToneMappingEnabled: boolean;
  47867. /**
  47868. * The camera exposure used on this material.
  47869. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47870. * This corresponds to a photographic exposure.
  47871. */
  47872. /**
  47873. * The camera exposure used on this material.
  47874. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47875. * This corresponds to a photographic exposure.
  47876. */
  47877. cameraExposure: number;
  47878. /**
  47879. * Gets The camera contrast used on this material.
  47880. */
  47881. /**
  47882. * Sets The camera contrast used on this material.
  47883. */
  47884. cameraContrast: number;
  47885. /**
  47886. * Gets the Color Grading 2D Lookup Texture.
  47887. */
  47888. /**
  47889. * Sets the Color Grading 2D Lookup Texture.
  47890. */
  47891. cameraColorGradingTexture: Nullable<BaseTexture>;
  47892. /**
  47893. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47894. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47895. * 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;
  47896. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47897. */
  47898. /**
  47899. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47900. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47901. * 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;
  47902. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47903. */
  47904. cameraColorCurves: Nullable<ColorCurves>;
  47905. /**
  47906. * Instantiates a new PBRMaterial instance.
  47907. *
  47908. * @param name The material name
  47909. * @param scene The scene the material will be use in.
  47910. */
  47911. constructor(name: string, scene: Scene);
  47912. /**
  47913. * Returns the name of this material class.
  47914. */
  47915. getClassName(): string;
  47916. /**
  47917. * Makes a duplicate of the current material.
  47918. * @param name - name to use for the new material.
  47919. */
  47920. clone(name: string): PBRMaterial;
  47921. /**
  47922. * Serializes this PBR Material.
  47923. * @returns - An object with the serialized material.
  47924. */
  47925. serialize(): any;
  47926. /**
  47927. * Parses a PBR Material from a serialized object.
  47928. * @param source - Serialized object.
  47929. * @param scene - BJS scene instance.
  47930. * @param rootUrl - url for the scene object
  47931. * @returns - PBRMaterial
  47932. */
  47933. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47934. }
  47935. }
  47936. declare module "babylonjs/Misc/dds" {
  47937. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47938. import { Engine } from "babylonjs/Engines/engine";
  47939. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47940. import { Nullable } from "babylonjs/types";
  47941. import { Scene } from "babylonjs/scene";
  47942. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47943. /**
  47944. * Direct draw surface info
  47945. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47946. */
  47947. export interface DDSInfo {
  47948. /**
  47949. * Width of the texture
  47950. */
  47951. width: number;
  47952. /**
  47953. * Width of the texture
  47954. */
  47955. height: number;
  47956. /**
  47957. * Number of Mipmaps for the texture
  47958. * @see https://en.wikipedia.org/wiki/Mipmap
  47959. */
  47960. mipmapCount: number;
  47961. /**
  47962. * If the textures format is a known fourCC format
  47963. * @see https://www.fourcc.org/
  47964. */
  47965. isFourCC: boolean;
  47966. /**
  47967. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47968. */
  47969. isRGB: boolean;
  47970. /**
  47971. * If the texture is a lumincance format
  47972. */
  47973. isLuminance: boolean;
  47974. /**
  47975. * If this is a cube texture
  47976. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47977. */
  47978. isCube: boolean;
  47979. /**
  47980. * If the texture is a compressed format eg. FOURCC_DXT1
  47981. */
  47982. isCompressed: boolean;
  47983. /**
  47984. * The dxgiFormat of the texture
  47985. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47986. */
  47987. dxgiFormat: number;
  47988. /**
  47989. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47990. */
  47991. textureType: number;
  47992. /**
  47993. * Sphericle polynomial created for the dds texture
  47994. */
  47995. sphericalPolynomial?: SphericalPolynomial;
  47996. }
  47997. /**
  47998. * Class used to provide DDS decompression tools
  47999. */
  48000. export class DDSTools {
  48001. /**
  48002. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48003. */
  48004. static StoreLODInAlphaChannel: boolean;
  48005. /**
  48006. * Gets DDS information from an array buffer
  48007. * @param arrayBuffer defines the array buffer to read data from
  48008. * @returns the DDS information
  48009. */
  48010. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48011. private static _FloatView;
  48012. private static _Int32View;
  48013. private static _ToHalfFloat;
  48014. private static _FromHalfFloat;
  48015. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48016. private static _GetHalfFloatRGBAArrayBuffer;
  48017. private static _GetFloatRGBAArrayBuffer;
  48018. private static _GetFloatAsUIntRGBAArrayBuffer;
  48019. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48020. private static _GetRGBAArrayBuffer;
  48021. private static _ExtractLongWordOrder;
  48022. private static _GetRGBArrayBuffer;
  48023. private static _GetLuminanceArrayBuffer;
  48024. /**
  48025. * Uploads DDS Levels to a Babylon Texture
  48026. * @hidden
  48027. */
  48028. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48029. }
  48030. module "babylonjs/Engines/engine" {
  48031. interface Engine {
  48032. /**
  48033. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48034. * @param rootUrl defines the url where the file to load is located
  48035. * @param scene defines the current scene
  48036. * @param lodScale defines scale to apply to the mip map selection
  48037. * @param lodOffset defines offset to apply to the mip map selection
  48038. * @param onLoad defines an optional callback raised when the texture is loaded
  48039. * @param onError defines an optional callback raised if there is an issue to load the texture
  48040. * @param format defines the format of the data
  48041. * @param forcedExtension defines the extension to use to pick the right loader
  48042. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48043. * @returns the cube texture as an InternalTexture
  48044. */
  48045. 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;
  48046. }
  48047. }
  48048. }
  48049. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48050. import { Nullable } from "babylonjs/types";
  48051. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48052. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48053. /**
  48054. * Implementation of the DDS Texture Loader.
  48055. * @hidden
  48056. */
  48057. export class _DDSTextureLoader implements IInternalTextureLoader {
  48058. /**
  48059. * Defines wether the loader supports cascade loading the different faces.
  48060. */
  48061. readonly supportCascades: boolean;
  48062. /**
  48063. * This returns if the loader support the current file information.
  48064. * @param extension defines the file extension of the file being loaded
  48065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48066. * @param fallback defines the fallback internal texture if any
  48067. * @param isBase64 defines whether the texture is encoded as a base64
  48068. * @param isBuffer defines whether the texture data are stored as a buffer
  48069. * @returns true if the loader can load the specified file
  48070. */
  48071. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48072. /**
  48073. * Transform the url before loading if required.
  48074. * @param rootUrl the url of the texture
  48075. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48076. * @returns the transformed texture
  48077. */
  48078. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48079. /**
  48080. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48081. * @param rootUrl the url of the texture
  48082. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48083. * @returns the fallback texture
  48084. */
  48085. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48086. /**
  48087. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48088. * @param data contains the texture data
  48089. * @param texture defines the BabylonJS internal texture
  48090. * @param createPolynomials will be true if polynomials have been requested
  48091. * @param onLoad defines the callback to trigger once the texture is ready
  48092. * @param onError defines the callback to trigger in case of error
  48093. */
  48094. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48095. /**
  48096. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48097. * @param data contains the texture data
  48098. * @param texture defines the BabylonJS internal texture
  48099. * @param callback defines the method to call once ready to upload
  48100. */
  48101. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48102. }
  48103. }
  48104. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48105. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48106. /** @hidden */
  48107. export var rgbdEncodePixelShader: {
  48108. name: string;
  48109. shader: string;
  48110. };
  48111. }
  48112. declare module "babylonjs/Misc/environmentTextureTools" {
  48113. import { Nullable } from "babylonjs/types";
  48114. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48115. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48116. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48117. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48118. import "babylonjs/Shaders/rgbdEncode.fragment";
  48119. import "babylonjs/Shaders/rgbdDecode.fragment";
  48120. /**
  48121. * Raw texture data and descriptor sufficient for WebGL texture upload
  48122. */
  48123. export interface EnvironmentTextureInfo {
  48124. /**
  48125. * Version of the environment map
  48126. */
  48127. version: number;
  48128. /**
  48129. * Width of image
  48130. */
  48131. width: number;
  48132. /**
  48133. * Irradiance information stored in the file.
  48134. */
  48135. irradiance: any;
  48136. /**
  48137. * Specular information stored in the file.
  48138. */
  48139. specular: any;
  48140. }
  48141. /**
  48142. * Sets of helpers addressing the serialization and deserialization of environment texture
  48143. * stored in a BabylonJS env file.
  48144. * Those files are usually stored as .env files.
  48145. */
  48146. export class EnvironmentTextureTools {
  48147. /**
  48148. * Magic number identifying the env file.
  48149. */
  48150. private static _MagicBytes;
  48151. /**
  48152. * Gets the environment info from an env file.
  48153. * @param data The array buffer containing the .env bytes.
  48154. * @returns the environment file info (the json header) if successfully parsed.
  48155. */
  48156. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48157. /**
  48158. * Creates an environment texture from a loaded cube texture.
  48159. * @param texture defines the cube texture to convert in env file
  48160. * @return a promise containing the environment data if succesfull.
  48161. */
  48162. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48163. /**
  48164. * Creates a JSON representation of the spherical data.
  48165. * @param texture defines the texture containing the polynomials
  48166. * @return the JSON representation of the spherical info
  48167. */
  48168. private static _CreateEnvTextureIrradiance;
  48169. /**
  48170. * Uploads the texture info contained in the env file to the GPU.
  48171. * @param texture defines the internal texture to upload to
  48172. * @param arrayBuffer defines the buffer cotaining the data to load
  48173. * @param info defines the texture info retrieved through the GetEnvInfo method
  48174. * @returns a promise
  48175. */
  48176. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48177. /**
  48178. * Uploads the levels of image data to the GPU.
  48179. * @param texture defines the internal texture to upload to
  48180. * @param imageData defines the array buffer views of image data [mipmap][face]
  48181. * @returns a promise
  48182. */
  48183. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48184. /**
  48185. * Uploads spherical polynomials information to the texture.
  48186. * @param texture defines the texture we are trying to upload the information to
  48187. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48188. */
  48189. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48190. /** @hidden */
  48191. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48192. }
  48193. }
  48194. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48195. import { Nullable } from "babylonjs/types";
  48196. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48197. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48198. /**
  48199. * Implementation of the ENV Texture Loader.
  48200. * @hidden
  48201. */
  48202. export class _ENVTextureLoader implements IInternalTextureLoader {
  48203. /**
  48204. * Defines wether the loader supports cascade loading the different faces.
  48205. */
  48206. readonly supportCascades: boolean;
  48207. /**
  48208. * This returns if the loader support the current file information.
  48209. * @param extension defines the file extension of the file being loaded
  48210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48211. * @param fallback defines the fallback internal texture if any
  48212. * @param isBase64 defines whether the texture is encoded as a base64
  48213. * @param isBuffer defines whether the texture data are stored as a buffer
  48214. * @returns true if the loader can load the specified file
  48215. */
  48216. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48217. /**
  48218. * Transform the url before loading if required.
  48219. * @param rootUrl the url of the texture
  48220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48221. * @returns the transformed texture
  48222. */
  48223. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48224. /**
  48225. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48226. * @param rootUrl the url of the texture
  48227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48228. * @returns the fallback texture
  48229. */
  48230. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48231. /**
  48232. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48233. * @param data contains the texture data
  48234. * @param texture defines the BabylonJS internal texture
  48235. * @param createPolynomials will be true if polynomials have been requested
  48236. * @param onLoad defines the callback to trigger once the texture is ready
  48237. * @param onError defines the callback to trigger in case of error
  48238. */
  48239. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48240. /**
  48241. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48242. * @param data contains the texture data
  48243. * @param texture defines the BabylonJS internal texture
  48244. * @param callback defines the method to call once ready to upload
  48245. */
  48246. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48247. }
  48248. }
  48249. declare module "babylonjs/Misc/khronosTextureContainer" {
  48250. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48251. /**
  48252. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48253. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48254. */
  48255. export class KhronosTextureContainer {
  48256. /** contents of the KTX container file */
  48257. arrayBuffer: any;
  48258. private static HEADER_LEN;
  48259. private static COMPRESSED_2D;
  48260. private static COMPRESSED_3D;
  48261. private static TEX_2D;
  48262. private static TEX_3D;
  48263. /**
  48264. * Gets the openGL type
  48265. */
  48266. glType: number;
  48267. /**
  48268. * Gets the openGL type size
  48269. */
  48270. glTypeSize: number;
  48271. /**
  48272. * Gets the openGL format
  48273. */
  48274. glFormat: number;
  48275. /**
  48276. * Gets the openGL internal format
  48277. */
  48278. glInternalFormat: number;
  48279. /**
  48280. * Gets the base internal format
  48281. */
  48282. glBaseInternalFormat: number;
  48283. /**
  48284. * Gets image width in pixel
  48285. */
  48286. pixelWidth: number;
  48287. /**
  48288. * Gets image height in pixel
  48289. */
  48290. pixelHeight: number;
  48291. /**
  48292. * Gets image depth in pixels
  48293. */
  48294. pixelDepth: number;
  48295. /**
  48296. * Gets the number of array elements
  48297. */
  48298. numberOfArrayElements: number;
  48299. /**
  48300. * Gets the number of faces
  48301. */
  48302. numberOfFaces: number;
  48303. /**
  48304. * Gets the number of mipmap levels
  48305. */
  48306. numberOfMipmapLevels: number;
  48307. /**
  48308. * Gets the bytes of key value data
  48309. */
  48310. bytesOfKeyValueData: number;
  48311. /**
  48312. * Gets the load type
  48313. */
  48314. loadType: number;
  48315. /**
  48316. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48317. */
  48318. isInvalid: boolean;
  48319. /**
  48320. * Creates a new KhronosTextureContainer
  48321. * @param arrayBuffer contents of the KTX container file
  48322. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48323. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48324. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48325. */
  48326. constructor(
  48327. /** contents of the KTX container file */
  48328. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48329. /**
  48330. * Uploads KTX content to a Babylon Texture.
  48331. * It is assumed that the texture has already been created & is currently bound
  48332. * @hidden
  48333. */
  48334. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48335. private _upload2DCompressedLevels;
  48336. }
  48337. }
  48338. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48339. import { Nullable } from "babylonjs/types";
  48340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48341. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48342. /**
  48343. * Implementation of the KTX Texture Loader.
  48344. * @hidden
  48345. */
  48346. export class _KTXTextureLoader implements IInternalTextureLoader {
  48347. /**
  48348. * Defines wether the loader supports cascade loading the different faces.
  48349. */
  48350. readonly supportCascades: boolean;
  48351. /**
  48352. * This returns if the loader support the current file information.
  48353. * @param extension defines the file extension of the file being loaded
  48354. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48355. * @param fallback defines the fallback internal texture if any
  48356. * @param isBase64 defines whether the texture is encoded as a base64
  48357. * @param isBuffer defines whether the texture data are stored as a buffer
  48358. * @returns true if the loader can load the specified file
  48359. */
  48360. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48361. /**
  48362. * Transform the url before loading if required.
  48363. * @param rootUrl the url of the texture
  48364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48365. * @returns the transformed texture
  48366. */
  48367. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48368. /**
  48369. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48370. * @param rootUrl the url of the texture
  48371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48372. * @returns the fallback texture
  48373. */
  48374. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48375. /**
  48376. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48377. * @param data contains the texture data
  48378. * @param texture defines the BabylonJS internal texture
  48379. * @param createPolynomials will be true if polynomials have been requested
  48380. * @param onLoad defines the callback to trigger once the texture is ready
  48381. * @param onError defines the callback to trigger in case of error
  48382. */
  48383. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48384. /**
  48385. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48386. * @param data contains the texture data
  48387. * @param texture defines the BabylonJS internal texture
  48388. * @param callback defines the method to call once ready to upload
  48389. */
  48390. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48391. }
  48392. }
  48393. declare module "babylonjs/Helpers/sceneHelpers" {
  48394. import { Nullable } from "babylonjs/types";
  48395. import { Mesh } from "babylonjs/Meshes/mesh";
  48396. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48397. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48398. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48399. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48400. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48401. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48402. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48403. import "babylonjs/Meshes/Builders/boxBuilder";
  48404. /** @hidden */
  48405. export var _forceSceneHelpersToBundle: boolean;
  48406. module "babylonjs/scene" {
  48407. interface Scene {
  48408. /**
  48409. * Creates a default light for the scene.
  48410. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48411. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48412. */
  48413. createDefaultLight(replace?: boolean): void;
  48414. /**
  48415. * Creates a default camera for the scene.
  48416. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48417. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48418. * @param replace has default false, when true replaces the active camera in the scene
  48419. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48420. */
  48421. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48422. /**
  48423. * Creates a default camera and a default light.
  48424. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48425. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48426. * @param replace has the default false, when true replaces the active camera/light in the scene
  48427. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48428. */
  48429. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48430. /**
  48431. * Creates a new sky box
  48432. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48433. * @param environmentTexture defines the texture to use as environment texture
  48434. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48435. * @param scale defines the overall scale of the skybox
  48436. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48437. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48438. * @returns a new mesh holding the sky box
  48439. */
  48440. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48441. /**
  48442. * Creates a new environment
  48443. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48444. * @param options defines the options you can use to configure the environment
  48445. * @returns the new EnvironmentHelper
  48446. */
  48447. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48448. /**
  48449. * Creates a new VREXperienceHelper
  48450. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48451. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48452. * @returns a new VREXperienceHelper
  48453. */
  48454. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48455. /**
  48456. * Creates a new XREXperienceHelper
  48457. * @see http://doc.babylonjs.com/how_to/webxr
  48458. * @returns a promise for a new XREXperienceHelper
  48459. */
  48460. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48461. }
  48462. }
  48463. }
  48464. declare module "babylonjs/Helpers/videoDome" {
  48465. import { Scene } from "babylonjs/scene";
  48466. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48467. import { Mesh } from "babylonjs/Meshes/mesh";
  48468. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48469. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48470. import "babylonjs/Meshes/Builders/sphereBuilder";
  48471. /**
  48472. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48473. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48474. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48475. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48476. */
  48477. export class VideoDome extends TransformNode {
  48478. /**
  48479. * Define the video source as a Monoscopic panoramic 360 video.
  48480. */
  48481. static readonly MODE_MONOSCOPIC: number;
  48482. /**
  48483. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48484. */
  48485. static readonly MODE_TOPBOTTOM: number;
  48486. /**
  48487. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48488. */
  48489. static readonly MODE_SIDEBYSIDE: number;
  48490. private _useDirectMapping;
  48491. /**
  48492. * The video texture being displayed on the sphere
  48493. */
  48494. protected _videoTexture: VideoTexture;
  48495. /**
  48496. * Gets the video texture being displayed on the sphere
  48497. */
  48498. readonly videoTexture: VideoTexture;
  48499. /**
  48500. * The skybox material
  48501. */
  48502. protected _material: BackgroundMaterial;
  48503. /**
  48504. * The surface used for the skybox
  48505. */
  48506. protected _mesh: Mesh;
  48507. /**
  48508. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48509. * Also see the options.resolution property.
  48510. */
  48511. fovMultiplier: number;
  48512. private _videoMode;
  48513. /**
  48514. * Gets or set the current video mode for the video. It can be:
  48515. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48516. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48517. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48518. */
  48519. videoMode: number;
  48520. /**
  48521. * Oberserver used in Stereoscopic VR Mode.
  48522. */
  48523. private _onBeforeCameraRenderObserver;
  48524. /**
  48525. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48526. * @param name Element's name, child elements will append suffixes for their own names.
  48527. * @param urlsOrVideo defines the url(s) or the video element to use
  48528. * @param options An object containing optional or exposed sub element properties
  48529. */
  48530. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48531. resolution?: number;
  48532. clickToPlay?: boolean;
  48533. autoPlay?: boolean;
  48534. loop?: boolean;
  48535. size?: number;
  48536. poster?: string;
  48537. faceForward?: boolean;
  48538. useDirectMapping?: boolean;
  48539. }, scene: Scene);
  48540. private _changeVideoMode;
  48541. /**
  48542. * Releases resources associated with this node.
  48543. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48544. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48545. */
  48546. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48547. }
  48548. }
  48549. declare module "babylonjs/Helpers/index" {
  48550. export * from "babylonjs/Helpers/environmentHelper";
  48551. export * from "babylonjs/Helpers/photoDome";
  48552. export * from "babylonjs/Helpers/sceneHelpers";
  48553. export * from "babylonjs/Helpers/videoDome";
  48554. }
  48555. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48556. import { PerfCounter } from "babylonjs/Misc/tools";
  48557. import { IDisposable } from "babylonjs/scene";
  48558. import { Engine } from "babylonjs/Engines/engine";
  48559. /**
  48560. * This class can be used to get instrumentation data from a Babylon engine
  48561. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48562. */
  48563. export class EngineInstrumentation implements IDisposable {
  48564. /**
  48565. * Define the instrumented engine.
  48566. */
  48567. engine: Engine;
  48568. private _captureGPUFrameTime;
  48569. private _gpuFrameTimeToken;
  48570. private _gpuFrameTime;
  48571. private _captureShaderCompilationTime;
  48572. private _shaderCompilationTime;
  48573. private _onBeginFrameObserver;
  48574. private _onEndFrameObserver;
  48575. private _onBeforeShaderCompilationObserver;
  48576. private _onAfterShaderCompilationObserver;
  48577. /**
  48578. * Gets the perf counter used for GPU frame time
  48579. */
  48580. readonly gpuFrameTimeCounter: PerfCounter;
  48581. /**
  48582. * Gets the GPU frame time capture status
  48583. */
  48584. /**
  48585. * Enable or disable the GPU frame time capture
  48586. */
  48587. captureGPUFrameTime: boolean;
  48588. /**
  48589. * Gets the perf counter used for shader compilation time
  48590. */
  48591. readonly shaderCompilationTimeCounter: PerfCounter;
  48592. /**
  48593. * Gets the shader compilation time capture status
  48594. */
  48595. /**
  48596. * Enable or disable the shader compilation time capture
  48597. */
  48598. captureShaderCompilationTime: boolean;
  48599. /**
  48600. * Instantiates a new engine instrumentation.
  48601. * This class can be used to get instrumentation data from a Babylon engine
  48602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48603. * @param engine Defines the engine to instrument
  48604. */
  48605. constructor(
  48606. /**
  48607. * Define the instrumented engine.
  48608. */
  48609. engine: Engine);
  48610. /**
  48611. * Dispose and release associated resources.
  48612. */
  48613. dispose(): void;
  48614. }
  48615. }
  48616. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48617. import { PerfCounter } from "babylonjs/Misc/tools";
  48618. import { Scene, IDisposable } from "babylonjs/scene";
  48619. /**
  48620. * This class can be used to get instrumentation data from a Babylon engine
  48621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48622. */
  48623. export class SceneInstrumentation implements IDisposable {
  48624. /**
  48625. * Defines the scene to instrument
  48626. */
  48627. scene: Scene;
  48628. private _captureActiveMeshesEvaluationTime;
  48629. private _activeMeshesEvaluationTime;
  48630. private _captureRenderTargetsRenderTime;
  48631. private _renderTargetsRenderTime;
  48632. private _captureFrameTime;
  48633. private _frameTime;
  48634. private _captureRenderTime;
  48635. private _renderTime;
  48636. private _captureInterFrameTime;
  48637. private _interFrameTime;
  48638. private _captureParticlesRenderTime;
  48639. private _particlesRenderTime;
  48640. private _captureSpritesRenderTime;
  48641. private _spritesRenderTime;
  48642. private _capturePhysicsTime;
  48643. private _physicsTime;
  48644. private _captureAnimationsTime;
  48645. private _animationsTime;
  48646. private _captureCameraRenderTime;
  48647. private _cameraRenderTime;
  48648. private _onBeforeActiveMeshesEvaluationObserver;
  48649. private _onAfterActiveMeshesEvaluationObserver;
  48650. private _onBeforeRenderTargetsRenderObserver;
  48651. private _onAfterRenderTargetsRenderObserver;
  48652. private _onAfterRenderObserver;
  48653. private _onBeforeDrawPhaseObserver;
  48654. private _onAfterDrawPhaseObserver;
  48655. private _onBeforeAnimationsObserver;
  48656. private _onBeforeParticlesRenderingObserver;
  48657. private _onAfterParticlesRenderingObserver;
  48658. private _onBeforeSpritesRenderingObserver;
  48659. private _onAfterSpritesRenderingObserver;
  48660. private _onBeforePhysicsObserver;
  48661. private _onAfterPhysicsObserver;
  48662. private _onAfterAnimationsObserver;
  48663. private _onBeforeCameraRenderObserver;
  48664. private _onAfterCameraRenderObserver;
  48665. /**
  48666. * Gets the perf counter used for active meshes evaluation time
  48667. */
  48668. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48669. /**
  48670. * Gets the active meshes evaluation time capture status
  48671. */
  48672. /**
  48673. * Enable or disable the active meshes evaluation time capture
  48674. */
  48675. captureActiveMeshesEvaluationTime: boolean;
  48676. /**
  48677. * Gets the perf counter used for render targets render time
  48678. */
  48679. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48680. /**
  48681. * Gets the render targets render time capture status
  48682. */
  48683. /**
  48684. * Enable or disable the render targets render time capture
  48685. */
  48686. captureRenderTargetsRenderTime: boolean;
  48687. /**
  48688. * Gets the perf counter used for particles render time
  48689. */
  48690. readonly particlesRenderTimeCounter: PerfCounter;
  48691. /**
  48692. * Gets the particles render time capture status
  48693. */
  48694. /**
  48695. * Enable or disable the particles render time capture
  48696. */
  48697. captureParticlesRenderTime: boolean;
  48698. /**
  48699. * Gets the perf counter used for sprites render time
  48700. */
  48701. readonly spritesRenderTimeCounter: PerfCounter;
  48702. /**
  48703. * Gets the sprites render time capture status
  48704. */
  48705. /**
  48706. * Enable or disable the sprites render time capture
  48707. */
  48708. captureSpritesRenderTime: boolean;
  48709. /**
  48710. * Gets the perf counter used for physics time
  48711. */
  48712. readonly physicsTimeCounter: PerfCounter;
  48713. /**
  48714. * Gets the physics time capture status
  48715. */
  48716. /**
  48717. * Enable or disable the physics time capture
  48718. */
  48719. capturePhysicsTime: boolean;
  48720. /**
  48721. * Gets the perf counter used for animations time
  48722. */
  48723. readonly animationsTimeCounter: PerfCounter;
  48724. /**
  48725. * Gets the animations time capture status
  48726. */
  48727. /**
  48728. * Enable or disable the animations time capture
  48729. */
  48730. captureAnimationsTime: boolean;
  48731. /**
  48732. * Gets the perf counter used for frame time capture
  48733. */
  48734. readonly frameTimeCounter: PerfCounter;
  48735. /**
  48736. * Gets the frame time capture status
  48737. */
  48738. /**
  48739. * Enable or disable the frame time capture
  48740. */
  48741. captureFrameTime: boolean;
  48742. /**
  48743. * Gets the perf counter used for inter-frames time capture
  48744. */
  48745. readonly interFrameTimeCounter: PerfCounter;
  48746. /**
  48747. * Gets the inter-frames time capture status
  48748. */
  48749. /**
  48750. * Enable or disable the inter-frames time capture
  48751. */
  48752. captureInterFrameTime: boolean;
  48753. /**
  48754. * Gets the perf counter used for render time capture
  48755. */
  48756. readonly renderTimeCounter: PerfCounter;
  48757. /**
  48758. * Gets the render time capture status
  48759. */
  48760. /**
  48761. * Enable or disable the render time capture
  48762. */
  48763. captureRenderTime: boolean;
  48764. /**
  48765. * Gets the perf counter used for camera render time capture
  48766. */
  48767. readonly cameraRenderTimeCounter: PerfCounter;
  48768. /**
  48769. * Gets the camera render time capture status
  48770. */
  48771. /**
  48772. * Enable or disable the camera render time capture
  48773. */
  48774. captureCameraRenderTime: boolean;
  48775. /**
  48776. * Gets the perf counter used for draw calls
  48777. */
  48778. readonly drawCallsCounter: PerfCounter;
  48779. /**
  48780. * Instantiates a new scene instrumentation.
  48781. * This class can be used to get instrumentation data from a Babylon engine
  48782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48783. * @param scene Defines the scene to instrument
  48784. */
  48785. constructor(
  48786. /**
  48787. * Defines the scene to instrument
  48788. */
  48789. scene: Scene);
  48790. /**
  48791. * Dispose and release associated resources.
  48792. */
  48793. dispose(): void;
  48794. }
  48795. }
  48796. declare module "babylonjs/Instrumentation/index" {
  48797. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48798. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48799. export * from "babylonjs/Instrumentation/timeToken";
  48800. }
  48801. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48802. /** @hidden */
  48803. export var glowMapGenerationPixelShader: {
  48804. name: string;
  48805. shader: string;
  48806. };
  48807. }
  48808. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48809. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48810. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48812. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48813. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48814. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48815. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48816. /** @hidden */
  48817. export var glowMapGenerationVertexShader: {
  48818. name: string;
  48819. shader: string;
  48820. };
  48821. }
  48822. declare module "babylonjs/Layers/effectLayer" {
  48823. import { Observable } from "babylonjs/Misc/observable";
  48824. import { Nullable } from "babylonjs/types";
  48825. import { Camera } from "babylonjs/Cameras/camera";
  48826. import { Scene } from "babylonjs/scene";
  48827. import { Color4, ISize } from "babylonjs/Maths/math";
  48828. import { Engine } from "babylonjs/Engines/engine";
  48829. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48831. import { Mesh } from "babylonjs/Meshes/mesh";
  48832. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48834. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48835. import { Effect } from "babylonjs/Materials/effect";
  48836. import { Material } from "babylonjs/Materials/material";
  48837. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48838. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48839. /**
  48840. * Effect layer options. This helps customizing the behaviour
  48841. * of the effect layer.
  48842. */
  48843. export interface IEffectLayerOptions {
  48844. /**
  48845. * Multiplication factor apply to the canvas size to compute the render target size
  48846. * used to generated the objects (the smaller the faster).
  48847. */
  48848. mainTextureRatio: number;
  48849. /**
  48850. * Enforces a fixed size texture to ensure effect stability across devices.
  48851. */
  48852. mainTextureFixedSize?: number;
  48853. /**
  48854. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48855. */
  48856. alphaBlendingMode: number;
  48857. /**
  48858. * The camera attached to the layer.
  48859. */
  48860. camera: Nullable<Camera>;
  48861. /**
  48862. * The rendering group to draw the layer in.
  48863. */
  48864. renderingGroupId: number;
  48865. }
  48866. /**
  48867. * The effect layer Helps adding post process effect blended with the main pass.
  48868. *
  48869. * This can be for instance use to generate glow or higlight effects on the scene.
  48870. *
  48871. * The effect layer class can not be used directly and is intented to inherited from to be
  48872. * customized per effects.
  48873. */
  48874. export abstract class EffectLayer {
  48875. private _vertexBuffers;
  48876. private _indexBuffer;
  48877. private _cachedDefines;
  48878. private _effectLayerMapGenerationEffect;
  48879. private _effectLayerOptions;
  48880. private _mergeEffect;
  48881. protected _scene: Scene;
  48882. protected _engine: Engine;
  48883. protected _maxSize: number;
  48884. protected _mainTextureDesiredSize: ISize;
  48885. protected _mainTexture: RenderTargetTexture;
  48886. protected _shouldRender: boolean;
  48887. protected _postProcesses: PostProcess[];
  48888. protected _textures: BaseTexture[];
  48889. protected _emissiveTextureAndColor: {
  48890. texture: Nullable<BaseTexture>;
  48891. color: Color4;
  48892. };
  48893. /**
  48894. * The name of the layer
  48895. */
  48896. name: string;
  48897. /**
  48898. * The clear color of the texture used to generate the glow map.
  48899. */
  48900. neutralColor: Color4;
  48901. /**
  48902. * Specifies wether the highlight layer is enabled or not.
  48903. */
  48904. isEnabled: boolean;
  48905. /**
  48906. * Gets the camera attached to the layer.
  48907. */
  48908. readonly camera: Nullable<Camera>;
  48909. /**
  48910. * Gets the rendering group id the layer should render in.
  48911. */
  48912. readonly renderingGroupId: number;
  48913. /**
  48914. * An event triggered when the effect layer has been disposed.
  48915. */
  48916. onDisposeObservable: Observable<EffectLayer>;
  48917. /**
  48918. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48919. */
  48920. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48921. /**
  48922. * An event triggered when the generated texture is being merged in the scene.
  48923. */
  48924. onBeforeComposeObservable: Observable<EffectLayer>;
  48925. /**
  48926. * An event triggered when the generated texture has been merged in the scene.
  48927. */
  48928. onAfterComposeObservable: Observable<EffectLayer>;
  48929. /**
  48930. * An event triggered when the efffect layer changes its size.
  48931. */
  48932. onSizeChangedObservable: Observable<EffectLayer>;
  48933. /** @hidden */
  48934. static _SceneComponentInitialization: (scene: Scene) => void;
  48935. /**
  48936. * Instantiates a new effect Layer and references it in the scene.
  48937. * @param name The name of the layer
  48938. * @param scene The scene to use the layer in
  48939. */
  48940. constructor(
  48941. /** The Friendly of the effect in the scene */
  48942. name: string, scene: Scene);
  48943. /**
  48944. * Get the effect name of the layer.
  48945. * @return The effect name
  48946. */
  48947. abstract getEffectName(): string;
  48948. /**
  48949. * Checks for the readiness of the element composing the layer.
  48950. * @param subMesh the mesh to check for
  48951. * @param useInstances specify wether or not to use instances to render the mesh
  48952. * @return true if ready otherwise, false
  48953. */
  48954. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48955. /**
  48956. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48957. * @returns true if the effect requires stencil during the main canvas render pass.
  48958. */
  48959. abstract needStencil(): boolean;
  48960. /**
  48961. * Create the merge effect. This is the shader use to blit the information back
  48962. * to the main canvas at the end of the scene rendering.
  48963. * @returns The effect containing the shader used to merge the effect on the main canvas
  48964. */
  48965. protected abstract _createMergeEffect(): Effect;
  48966. /**
  48967. * Creates the render target textures and post processes used in the effect layer.
  48968. */
  48969. protected abstract _createTextureAndPostProcesses(): void;
  48970. /**
  48971. * Implementation specific of rendering the generating effect on the main canvas.
  48972. * @param effect The effect used to render through
  48973. */
  48974. protected abstract _internalRender(effect: Effect): void;
  48975. /**
  48976. * Sets the required values for both the emissive texture and and the main color.
  48977. */
  48978. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48979. /**
  48980. * Free any resources and references associated to a mesh.
  48981. * Internal use
  48982. * @param mesh The mesh to free.
  48983. */
  48984. abstract _disposeMesh(mesh: Mesh): void;
  48985. /**
  48986. * Serializes this layer (Glow or Highlight for example)
  48987. * @returns a serialized layer object
  48988. */
  48989. abstract serialize?(): any;
  48990. /**
  48991. * Initializes the effect layer with the required options.
  48992. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48993. */
  48994. protected _init(options: Partial<IEffectLayerOptions>): void;
  48995. /**
  48996. * Generates the index buffer of the full screen quad blending to the main canvas.
  48997. */
  48998. private _generateIndexBuffer;
  48999. /**
  49000. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49001. */
  49002. private _generateVertexBuffer;
  49003. /**
  49004. * Sets the main texture desired size which is the closest power of two
  49005. * of the engine canvas size.
  49006. */
  49007. private _setMainTextureSize;
  49008. /**
  49009. * Creates the main texture for the effect layer.
  49010. */
  49011. protected _createMainTexture(): void;
  49012. /**
  49013. * Adds specific effects defines.
  49014. * @param defines The defines to add specifics to.
  49015. */
  49016. protected _addCustomEffectDefines(defines: string[]): void;
  49017. /**
  49018. * Checks for the readiness of the element composing the layer.
  49019. * @param subMesh the mesh to check for
  49020. * @param useInstances specify wether or not to use instances to render the mesh
  49021. * @param emissiveTexture the associated emissive texture used to generate the glow
  49022. * @return true if ready otherwise, false
  49023. */
  49024. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49025. /**
  49026. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49027. */
  49028. render(): void;
  49029. /**
  49030. * Determine if a given mesh will be used in the current effect.
  49031. * @param mesh mesh to test
  49032. * @returns true if the mesh will be used
  49033. */
  49034. hasMesh(mesh: AbstractMesh): boolean;
  49035. /**
  49036. * Returns true if the layer contains information to display, otherwise false.
  49037. * @returns true if the glow layer should be rendered
  49038. */
  49039. shouldRender(): boolean;
  49040. /**
  49041. * Returns true if the mesh should render, otherwise false.
  49042. * @param mesh The mesh to render
  49043. * @returns true if it should render otherwise false
  49044. */
  49045. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49046. /**
  49047. * Returns true if the mesh can be rendered, otherwise false.
  49048. * @param mesh The mesh to render
  49049. * @param material The material used on the mesh
  49050. * @returns true if it can be rendered otherwise false
  49051. */
  49052. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49053. /**
  49054. * Returns true if the mesh should render, otherwise false.
  49055. * @param mesh The mesh to render
  49056. * @returns true if it should render otherwise false
  49057. */
  49058. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49059. /**
  49060. * Renders the submesh passed in parameter to the generation map.
  49061. */
  49062. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49063. /**
  49064. * Rebuild the required buffers.
  49065. * @hidden Internal use only.
  49066. */
  49067. _rebuild(): void;
  49068. /**
  49069. * Dispose only the render target textures and post process.
  49070. */
  49071. private _disposeTextureAndPostProcesses;
  49072. /**
  49073. * Dispose the highlight layer and free resources.
  49074. */
  49075. dispose(): void;
  49076. /**
  49077. * Gets the class name of the effect layer
  49078. * @returns the string with the class name of the effect layer
  49079. */
  49080. getClassName(): string;
  49081. /**
  49082. * Creates an effect layer from parsed effect layer data
  49083. * @param parsedEffectLayer defines effect layer data
  49084. * @param scene defines the current scene
  49085. * @param rootUrl defines the root URL containing the effect layer information
  49086. * @returns a parsed effect Layer
  49087. */
  49088. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49089. }
  49090. }
  49091. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49092. import { Scene } from "babylonjs/scene";
  49093. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49094. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49095. import { AbstractScene } from "babylonjs/abstractScene";
  49096. module "babylonjs/abstractScene" {
  49097. interface AbstractScene {
  49098. /**
  49099. * The list of effect layers (highlights/glow) added to the scene
  49100. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49101. * @see http://doc.babylonjs.com/how_to/glow_layer
  49102. */
  49103. effectLayers: Array<EffectLayer>;
  49104. /**
  49105. * Removes the given effect layer from this scene.
  49106. * @param toRemove defines the effect layer to remove
  49107. * @returns the index of the removed effect layer
  49108. */
  49109. removeEffectLayer(toRemove: EffectLayer): number;
  49110. /**
  49111. * Adds the given effect layer to this scene
  49112. * @param newEffectLayer defines the effect layer to add
  49113. */
  49114. addEffectLayer(newEffectLayer: EffectLayer): void;
  49115. }
  49116. }
  49117. /**
  49118. * Defines the layer scene component responsible to manage any effect layers
  49119. * in a given scene.
  49120. */
  49121. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49122. /**
  49123. * The component name helpfull to identify the component in the list of scene components.
  49124. */
  49125. readonly name: string;
  49126. /**
  49127. * The scene the component belongs to.
  49128. */
  49129. scene: Scene;
  49130. private _engine;
  49131. private _renderEffects;
  49132. private _needStencil;
  49133. private _previousStencilState;
  49134. /**
  49135. * Creates a new instance of the component for the given scene
  49136. * @param scene Defines the scene to register the component in
  49137. */
  49138. constructor(scene: Scene);
  49139. /**
  49140. * Registers the component in a given scene
  49141. */
  49142. register(): void;
  49143. /**
  49144. * Rebuilds the elements related to this component in case of
  49145. * context lost for instance.
  49146. */
  49147. rebuild(): void;
  49148. /**
  49149. * Serializes the component data to the specified json object
  49150. * @param serializationObject The object to serialize to
  49151. */
  49152. serialize(serializationObject: any): void;
  49153. /**
  49154. * Adds all the element from the container to the scene
  49155. * @param container the container holding the elements
  49156. */
  49157. addFromContainer(container: AbstractScene): void;
  49158. /**
  49159. * Removes all the elements in the container from the scene
  49160. * @param container contains the elements to remove
  49161. * @param dispose if the removed element should be disposed (default: false)
  49162. */
  49163. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49164. /**
  49165. * Disposes the component and the associated ressources.
  49166. */
  49167. dispose(): void;
  49168. private _isReadyForMesh;
  49169. private _renderMainTexture;
  49170. private _setStencil;
  49171. private _setStencilBack;
  49172. private _draw;
  49173. private _drawCamera;
  49174. private _drawRenderingGroup;
  49175. }
  49176. }
  49177. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49178. /** @hidden */
  49179. export var glowMapMergePixelShader: {
  49180. name: string;
  49181. shader: string;
  49182. };
  49183. }
  49184. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49185. /** @hidden */
  49186. export var glowMapMergeVertexShader: {
  49187. name: string;
  49188. shader: string;
  49189. };
  49190. }
  49191. declare module "babylonjs/Layers/glowLayer" {
  49192. import { Nullable } from "babylonjs/types";
  49193. import { Camera } from "babylonjs/Cameras/camera";
  49194. import { Scene } from "babylonjs/scene";
  49195. import { Color4 } from "babylonjs/Maths/math";
  49196. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49198. import { Mesh } from "babylonjs/Meshes/mesh";
  49199. import { Texture } from "babylonjs/Materials/Textures/texture";
  49200. import { Effect } from "babylonjs/Materials/effect";
  49201. import { Material } from "babylonjs/Materials/material";
  49202. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49203. import "babylonjs/Shaders/glowMapMerge.fragment";
  49204. import "babylonjs/Shaders/glowMapMerge.vertex";
  49205. import "babylonjs/Layers/effectLayerSceneComponent";
  49206. module "babylonjs/abstractScene" {
  49207. interface AbstractScene {
  49208. /**
  49209. * Return a the first highlight layer of the scene with a given name.
  49210. * @param name The name of the highlight layer to look for.
  49211. * @return The highlight layer if found otherwise null.
  49212. */
  49213. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49214. }
  49215. }
  49216. /**
  49217. * Glow layer options. This helps customizing the behaviour
  49218. * of the glow layer.
  49219. */
  49220. export interface IGlowLayerOptions {
  49221. /**
  49222. * Multiplication factor apply to the canvas size to compute the render target size
  49223. * used to generated the glowing objects (the smaller the faster).
  49224. */
  49225. mainTextureRatio: number;
  49226. /**
  49227. * Enforces a fixed size texture to ensure resize independant blur.
  49228. */
  49229. mainTextureFixedSize?: number;
  49230. /**
  49231. * How big is the kernel of the blur texture.
  49232. */
  49233. blurKernelSize: number;
  49234. /**
  49235. * The camera attached to the layer.
  49236. */
  49237. camera: Nullable<Camera>;
  49238. /**
  49239. * Enable MSAA by chosing the number of samples.
  49240. */
  49241. mainTextureSamples?: number;
  49242. /**
  49243. * The rendering group to draw the layer in.
  49244. */
  49245. renderingGroupId: number;
  49246. }
  49247. /**
  49248. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49249. *
  49250. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49251. * glowy meshes to your scene.
  49252. *
  49253. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49254. */
  49255. export class GlowLayer extends EffectLayer {
  49256. /**
  49257. * Effect Name of the layer.
  49258. */
  49259. static readonly EffectName: string;
  49260. /**
  49261. * The default blur kernel size used for the glow.
  49262. */
  49263. static DefaultBlurKernelSize: number;
  49264. /**
  49265. * The default texture size ratio used for the glow.
  49266. */
  49267. static DefaultTextureRatio: number;
  49268. /**
  49269. * Sets the kernel size of the blur.
  49270. */
  49271. /**
  49272. * Gets the kernel size of the blur.
  49273. */
  49274. blurKernelSize: number;
  49275. /**
  49276. * Sets the glow intensity.
  49277. */
  49278. /**
  49279. * Gets the glow intensity.
  49280. */
  49281. intensity: number;
  49282. private _options;
  49283. private _intensity;
  49284. private _horizontalBlurPostprocess1;
  49285. private _verticalBlurPostprocess1;
  49286. private _horizontalBlurPostprocess2;
  49287. private _verticalBlurPostprocess2;
  49288. private _blurTexture1;
  49289. private _blurTexture2;
  49290. private _postProcesses1;
  49291. private _postProcesses2;
  49292. private _includedOnlyMeshes;
  49293. private _excludedMeshes;
  49294. /**
  49295. * Callback used to let the user override the color selection on a per mesh basis
  49296. */
  49297. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49298. /**
  49299. * Callback used to let the user override the texture selection on a per mesh basis
  49300. */
  49301. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49302. /**
  49303. * Instantiates a new glow Layer and references it to the scene.
  49304. * @param name The name of the layer
  49305. * @param scene The scene to use the layer in
  49306. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49307. */
  49308. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49309. /**
  49310. * Get the effect name of the layer.
  49311. * @return The effect name
  49312. */
  49313. getEffectName(): string;
  49314. /**
  49315. * Create the merge effect. This is the shader use to blit the information back
  49316. * to the main canvas at the end of the scene rendering.
  49317. */
  49318. protected _createMergeEffect(): Effect;
  49319. /**
  49320. * Creates the render target textures and post processes used in the glow layer.
  49321. */
  49322. protected _createTextureAndPostProcesses(): void;
  49323. /**
  49324. * Checks for the readiness of the element composing the layer.
  49325. * @param subMesh the mesh to check for
  49326. * @param useInstances specify wether or not to use instances to render the mesh
  49327. * @param emissiveTexture the associated emissive texture used to generate the glow
  49328. * @return true if ready otherwise, false
  49329. */
  49330. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49331. /**
  49332. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49333. */
  49334. needStencil(): boolean;
  49335. /**
  49336. * Returns true if the mesh can be rendered, otherwise false.
  49337. * @param mesh The mesh to render
  49338. * @param material The material used on the mesh
  49339. * @returns true if it can be rendered otherwise false
  49340. */
  49341. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49342. /**
  49343. * Implementation specific of rendering the generating effect on the main canvas.
  49344. * @param effect The effect used to render through
  49345. */
  49346. protected _internalRender(effect: Effect): void;
  49347. /**
  49348. * Sets the required values for both the emissive texture and and the main color.
  49349. */
  49350. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49351. /**
  49352. * Returns true if the mesh should render, otherwise false.
  49353. * @param mesh The mesh to render
  49354. * @returns true if it should render otherwise false
  49355. */
  49356. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49357. /**
  49358. * Adds specific effects defines.
  49359. * @param defines The defines to add specifics to.
  49360. */
  49361. protected _addCustomEffectDefines(defines: string[]): void;
  49362. /**
  49363. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49364. * @param mesh The mesh to exclude from the glow layer
  49365. */
  49366. addExcludedMesh(mesh: Mesh): void;
  49367. /**
  49368. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49369. * @param mesh The mesh to remove
  49370. */
  49371. removeExcludedMesh(mesh: Mesh): void;
  49372. /**
  49373. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49374. * @param mesh The mesh to include in the glow layer
  49375. */
  49376. addIncludedOnlyMesh(mesh: Mesh): void;
  49377. /**
  49378. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49379. * @param mesh The mesh to remove
  49380. */
  49381. removeIncludedOnlyMesh(mesh: Mesh): void;
  49382. /**
  49383. * Determine if a given mesh will be used in the glow layer
  49384. * @param mesh The mesh to test
  49385. * @returns true if the mesh will be highlighted by the current glow layer
  49386. */
  49387. hasMesh(mesh: AbstractMesh): boolean;
  49388. /**
  49389. * Free any resources and references associated to a mesh.
  49390. * Internal use
  49391. * @param mesh The mesh to free.
  49392. * @hidden
  49393. */
  49394. _disposeMesh(mesh: Mesh): void;
  49395. /**
  49396. * Gets the class name of the effect layer
  49397. * @returns the string with the class name of the effect layer
  49398. */
  49399. getClassName(): string;
  49400. /**
  49401. * Serializes this glow layer
  49402. * @returns a serialized glow layer object
  49403. */
  49404. serialize(): any;
  49405. /**
  49406. * Creates a Glow Layer from parsed glow layer data
  49407. * @param parsedGlowLayer defines glow layer data
  49408. * @param scene defines the current scene
  49409. * @param rootUrl defines the root URL containing the glow layer information
  49410. * @returns a parsed Glow Layer
  49411. */
  49412. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49413. }
  49414. }
  49415. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49416. /** @hidden */
  49417. export var glowBlurPostProcessPixelShader: {
  49418. name: string;
  49419. shader: string;
  49420. };
  49421. }
  49422. declare module "babylonjs/Layers/highlightLayer" {
  49423. import { Observable } from "babylonjs/Misc/observable";
  49424. import { Nullable } from "babylonjs/types";
  49425. import { Camera } from "babylonjs/Cameras/camera";
  49426. import { Scene } from "babylonjs/scene";
  49427. import { Color3, Color4 } from "babylonjs/Maths/math";
  49428. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49430. import { Mesh } from "babylonjs/Meshes/mesh";
  49431. import { Effect } from "babylonjs/Materials/effect";
  49432. import { Material } from "babylonjs/Materials/material";
  49433. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49434. import "babylonjs/Shaders/glowMapMerge.fragment";
  49435. import "babylonjs/Shaders/glowMapMerge.vertex";
  49436. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49437. module "babylonjs/abstractScene" {
  49438. interface AbstractScene {
  49439. /**
  49440. * Return a the first highlight layer of the scene with a given name.
  49441. * @param name The name of the highlight layer to look for.
  49442. * @return The highlight layer if found otherwise null.
  49443. */
  49444. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49445. }
  49446. }
  49447. /**
  49448. * Highlight layer options. This helps customizing the behaviour
  49449. * of the highlight layer.
  49450. */
  49451. export interface IHighlightLayerOptions {
  49452. /**
  49453. * Multiplication factor apply to the canvas size to compute the render target size
  49454. * used to generated the glowing objects (the smaller the faster).
  49455. */
  49456. mainTextureRatio: number;
  49457. /**
  49458. * Enforces a fixed size texture to ensure resize independant blur.
  49459. */
  49460. mainTextureFixedSize?: number;
  49461. /**
  49462. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49463. * of the picture to blur (the smaller the faster).
  49464. */
  49465. blurTextureSizeRatio: number;
  49466. /**
  49467. * How big in texel of the blur texture is the vertical blur.
  49468. */
  49469. blurVerticalSize: number;
  49470. /**
  49471. * How big in texel of the blur texture is the horizontal blur.
  49472. */
  49473. blurHorizontalSize: number;
  49474. /**
  49475. * Alpha blending mode used to apply the blur. Default is combine.
  49476. */
  49477. alphaBlendingMode: number;
  49478. /**
  49479. * The camera attached to the layer.
  49480. */
  49481. camera: Nullable<Camera>;
  49482. /**
  49483. * Should we display highlight as a solid stroke?
  49484. */
  49485. isStroke?: boolean;
  49486. /**
  49487. * The rendering group to draw the layer in.
  49488. */
  49489. renderingGroupId: number;
  49490. }
  49491. /**
  49492. * The highlight layer Helps adding a glow effect around a mesh.
  49493. *
  49494. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49495. * glowy meshes to your scene.
  49496. *
  49497. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49498. */
  49499. export class HighlightLayer extends EffectLayer {
  49500. name: string;
  49501. /**
  49502. * Effect Name of the highlight layer.
  49503. */
  49504. static readonly EffectName: string;
  49505. /**
  49506. * The neutral color used during the preparation of the glow effect.
  49507. * This is black by default as the blend operation is a blend operation.
  49508. */
  49509. static NeutralColor: Color4;
  49510. /**
  49511. * Stencil value used for glowing meshes.
  49512. */
  49513. static GlowingMeshStencilReference: number;
  49514. /**
  49515. * Stencil value used for the other meshes in the scene.
  49516. */
  49517. static NormalMeshStencilReference: number;
  49518. /**
  49519. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49520. */
  49521. innerGlow: boolean;
  49522. /**
  49523. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49524. */
  49525. outerGlow: boolean;
  49526. /**
  49527. * Specifies the horizontal size of the blur.
  49528. */
  49529. /**
  49530. * Gets the horizontal size of the blur.
  49531. */
  49532. blurHorizontalSize: number;
  49533. /**
  49534. * Specifies the vertical size of the blur.
  49535. */
  49536. /**
  49537. * Gets the vertical size of the blur.
  49538. */
  49539. blurVerticalSize: number;
  49540. /**
  49541. * An event triggered when the highlight layer is being blurred.
  49542. */
  49543. onBeforeBlurObservable: Observable<HighlightLayer>;
  49544. /**
  49545. * An event triggered when the highlight layer has been blurred.
  49546. */
  49547. onAfterBlurObservable: Observable<HighlightLayer>;
  49548. private _instanceGlowingMeshStencilReference;
  49549. private _options;
  49550. private _downSamplePostprocess;
  49551. private _horizontalBlurPostprocess;
  49552. private _verticalBlurPostprocess;
  49553. private _blurTexture;
  49554. private _meshes;
  49555. private _excludedMeshes;
  49556. /**
  49557. * Instantiates a new highlight Layer and references it to the scene..
  49558. * @param name The name of the layer
  49559. * @param scene The scene to use the layer in
  49560. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49561. */
  49562. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49563. /**
  49564. * Get the effect name of the layer.
  49565. * @return The effect name
  49566. */
  49567. getEffectName(): string;
  49568. /**
  49569. * Create the merge effect. This is the shader use to blit the information back
  49570. * to the main canvas at the end of the scene rendering.
  49571. */
  49572. protected _createMergeEffect(): Effect;
  49573. /**
  49574. * Creates the render target textures and post processes used in the highlight layer.
  49575. */
  49576. protected _createTextureAndPostProcesses(): void;
  49577. /**
  49578. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49579. */
  49580. needStencil(): boolean;
  49581. /**
  49582. * Checks for the readiness of the element composing the layer.
  49583. * @param subMesh the mesh to check for
  49584. * @param useInstances specify wether or not to use instances to render the mesh
  49585. * @param emissiveTexture the associated emissive texture used to generate the glow
  49586. * @return true if ready otherwise, false
  49587. */
  49588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49589. /**
  49590. * Implementation specific of rendering the generating effect on the main canvas.
  49591. * @param effect The effect used to render through
  49592. */
  49593. protected _internalRender(effect: Effect): void;
  49594. /**
  49595. * Returns true if the layer contains information to display, otherwise false.
  49596. */
  49597. shouldRender(): boolean;
  49598. /**
  49599. * Returns true if the mesh should render, otherwise false.
  49600. * @param mesh The mesh to render
  49601. * @returns true if it should render otherwise false
  49602. */
  49603. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49604. /**
  49605. * Sets the required values for both the emissive texture and and the main color.
  49606. */
  49607. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49608. /**
  49609. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49610. * @param mesh The mesh to exclude from the highlight layer
  49611. */
  49612. addExcludedMesh(mesh: Mesh): void;
  49613. /**
  49614. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49615. * @param mesh The mesh to highlight
  49616. */
  49617. removeExcludedMesh(mesh: Mesh): void;
  49618. /**
  49619. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49620. * @param mesh mesh to test
  49621. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49622. */
  49623. hasMesh(mesh: AbstractMesh): boolean;
  49624. /**
  49625. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49626. * @param mesh The mesh to highlight
  49627. * @param color The color of the highlight
  49628. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49629. */
  49630. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49631. /**
  49632. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49633. * @param mesh The mesh to highlight
  49634. */
  49635. removeMesh(mesh: Mesh): void;
  49636. /**
  49637. * Force the stencil to the normal expected value for none glowing parts
  49638. */
  49639. private _defaultStencilReference;
  49640. /**
  49641. * Free any resources and references associated to a mesh.
  49642. * Internal use
  49643. * @param mesh The mesh to free.
  49644. * @hidden
  49645. */
  49646. _disposeMesh(mesh: Mesh): void;
  49647. /**
  49648. * Dispose the highlight layer and free resources.
  49649. */
  49650. dispose(): void;
  49651. /**
  49652. * Gets the class name of the effect layer
  49653. * @returns the string with the class name of the effect layer
  49654. */
  49655. getClassName(): string;
  49656. /**
  49657. * Serializes this Highlight layer
  49658. * @returns a serialized Highlight layer object
  49659. */
  49660. serialize(): any;
  49661. /**
  49662. * Creates a Highlight layer from parsed Highlight layer data
  49663. * @param parsedHightlightLayer defines the Highlight layer data
  49664. * @param scene defines the current scene
  49665. * @param rootUrl defines the root URL containing the Highlight layer information
  49666. * @returns a parsed Highlight layer
  49667. */
  49668. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49669. }
  49670. }
  49671. declare module "babylonjs/Layers/index" {
  49672. export * from "babylonjs/Layers/effectLayer";
  49673. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49674. export * from "babylonjs/Layers/glowLayer";
  49675. export * from "babylonjs/Layers/highlightLayer";
  49676. export * from "babylonjs/Layers/layer";
  49677. export * from "babylonjs/Layers/layerSceneComponent";
  49678. }
  49679. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49680. /** @hidden */
  49681. export var lensFlarePixelShader: {
  49682. name: string;
  49683. shader: string;
  49684. };
  49685. }
  49686. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49687. /** @hidden */
  49688. export var lensFlareVertexShader: {
  49689. name: string;
  49690. shader: string;
  49691. };
  49692. }
  49693. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49694. import { Scene } from "babylonjs/scene";
  49695. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49697. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49698. import "babylonjs/Shaders/lensFlare.fragment";
  49699. import "babylonjs/Shaders/lensFlare.vertex";
  49700. /**
  49701. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49702. * It is usually composed of several `lensFlare`.
  49703. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49704. */
  49705. export class LensFlareSystem {
  49706. /**
  49707. * Define the name of the lens flare system
  49708. */
  49709. name: string;
  49710. /**
  49711. * List of lens flares used in this system.
  49712. */
  49713. lensFlares: LensFlare[];
  49714. /**
  49715. * Define a limit from the border the lens flare can be visible.
  49716. */
  49717. borderLimit: number;
  49718. /**
  49719. * Define a viewport border we do not want to see the lens flare in.
  49720. */
  49721. viewportBorder: number;
  49722. /**
  49723. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49724. */
  49725. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49726. /**
  49727. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49728. */
  49729. layerMask: number;
  49730. /**
  49731. * Define the id of the lens flare system in the scene.
  49732. * (equal to name by default)
  49733. */
  49734. id: string;
  49735. private _scene;
  49736. private _emitter;
  49737. private _vertexBuffers;
  49738. private _indexBuffer;
  49739. private _effect;
  49740. private _positionX;
  49741. private _positionY;
  49742. private _isEnabled;
  49743. /** @hidden */
  49744. static _SceneComponentInitialization: (scene: Scene) => void;
  49745. /**
  49746. * Instantiates a lens flare system.
  49747. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49748. * It is usually composed of several `lensFlare`.
  49749. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49750. * @param name Define the name of the lens flare system in the scene
  49751. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49752. * @param scene Define the scene the lens flare system belongs to
  49753. */
  49754. constructor(
  49755. /**
  49756. * Define the name of the lens flare system
  49757. */
  49758. name: string, emitter: any, scene: Scene);
  49759. /**
  49760. * Define if the lens flare system is enabled.
  49761. */
  49762. isEnabled: boolean;
  49763. /**
  49764. * Get the scene the effects belongs to.
  49765. * @returns the scene holding the lens flare system
  49766. */
  49767. getScene(): Scene;
  49768. /**
  49769. * Get the emitter of the lens flare system.
  49770. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49771. * @returns the emitter of the lens flare system
  49772. */
  49773. getEmitter(): any;
  49774. /**
  49775. * Set the emitter of the lens flare system.
  49776. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49777. * @param newEmitter Define the new emitter of the system
  49778. */
  49779. setEmitter(newEmitter: any): void;
  49780. /**
  49781. * Get the lens flare system emitter position.
  49782. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49783. * @returns the position
  49784. */
  49785. getEmitterPosition(): Vector3;
  49786. /**
  49787. * @hidden
  49788. */
  49789. computeEffectivePosition(globalViewport: Viewport): boolean;
  49790. /** @hidden */
  49791. _isVisible(): boolean;
  49792. /**
  49793. * @hidden
  49794. */
  49795. render(): boolean;
  49796. /**
  49797. * Dispose and release the lens flare with its associated resources.
  49798. */
  49799. dispose(): void;
  49800. /**
  49801. * Parse a lens flare system from a JSON repressentation
  49802. * @param parsedLensFlareSystem Define the JSON to parse
  49803. * @param scene Define the scene the parsed system should be instantiated in
  49804. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49805. * @returns the parsed system
  49806. */
  49807. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49808. /**
  49809. * Serialize the current Lens Flare System into a JSON representation.
  49810. * @returns the serialized JSON
  49811. */
  49812. serialize(): any;
  49813. }
  49814. }
  49815. declare module "babylonjs/LensFlares/lensFlare" {
  49816. import { Nullable } from "babylonjs/types";
  49817. import { Color3 } from "babylonjs/Maths/math";
  49818. import { Texture } from "babylonjs/Materials/Textures/texture";
  49819. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49820. /**
  49821. * This represents one of the lens effect in a `lensFlareSystem`.
  49822. * It controls one of the indiviual texture used in the effect.
  49823. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49824. */
  49825. export class LensFlare {
  49826. /**
  49827. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49828. */
  49829. size: number;
  49830. /**
  49831. * 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.
  49832. */
  49833. position: number;
  49834. /**
  49835. * Define the lens color.
  49836. */
  49837. color: Color3;
  49838. /**
  49839. * Define the lens texture.
  49840. */
  49841. texture: Nullable<Texture>;
  49842. /**
  49843. * Define the alpha mode to render this particular lens.
  49844. */
  49845. alphaMode: number;
  49846. private _system;
  49847. /**
  49848. * Creates a new Lens Flare.
  49849. * This represents one of the lens effect in a `lensFlareSystem`.
  49850. * It controls one of the indiviual texture used in the effect.
  49851. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49852. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49853. * @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.
  49854. * @param color Define the lens color
  49855. * @param imgUrl Define the lens texture url
  49856. * @param system Define the `lensFlareSystem` this flare is part of
  49857. * @returns The newly created Lens Flare
  49858. */
  49859. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49860. /**
  49861. * Instantiates a new Lens Flare.
  49862. * This represents one of the lens effect in a `lensFlareSystem`.
  49863. * It controls one of the indiviual texture used in the effect.
  49864. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49865. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49866. * @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.
  49867. * @param color Define the lens color
  49868. * @param imgUrl Define the lens texture url
  49869. * @param system Define the `lensFlareSystem` this flare is part of
  49870. */
  49871. constructor(
  49872. /**
  49873. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49874. */
  49875. size: number,
  49876. /**
  49877. * 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.
  49878. */
  49879. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49880. /**
  49881. * Dispose and release the lens flare with its associated resources.
  49882. */
  49883. dispose(): void;
  49884. }
  49885. }
  49886. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49887. import { Nullable } from "babylonjs/types";
  49888. import { Scene } from "babylonjs/scene";
  49889. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49890. import { AbstractScene } from "babylonjs/abstractScene";
  49891. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49892. module "babylonjs/abstractScene" {
  49893. interface AbstractScene {
  49894. /**
  49895. * The list of lens flare system added to the scene
  49896. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49897. */
  49898. lensFlareSystems: Array<LensFlareSystem>;
  49899. /**
  49900. * Removes the given lens flare system from this scene.
  49901. * @param toRemove The lens flare system to remove
  49902. * @returns The index of the removed lens flare system
  49903. */
  49904. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49905. /**
  49906. * Adds the given lens flare system to this scene
  49907. * @param newLensFlareSystem The lens flare system to add
  49908. */
  49909. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49910. /**
  49911. * Gets a lens flare system using its name
  49912. * @param name defines the name to look for
  49913. * @returns the lens flare system or null if not found
  49914. */
  49915. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49916. /**
  49917. * Gets a lens flare system using its id
  49918. * @param id defines the id to look for
  49919. * @returns the lens flare system or null if not found
  49920. */
  49921. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49922. }
  49923. }
  49924. /**
  49925. * Defines the lens flare scene component responsible to manage any lens flares
  49926. * in a given scene.
  49927. */
  49928. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49929. /**
  49930. * The component name helpfull to identify the component in the list of scene components.
  49931. */
  49932. readonly name: string;
  49933. /**
  49934. * The scene the component belongs to.
  49935. */
  49936. scene: Scene;
  49937. /**
  49938. * Creates a new instance of the component for the given scene
  49939. * @param scene Defines the scene to register the component in
  49940. */
  49941. constructor(scene: Scene);
  49942. /**
  49943. * Registers the component in a given scene
  49944. */
  49945. register(): void;
  49946. /**
  49947. * Rebuilds the elements related to this component in case of
  49948. * context lost for instance.
  49949. */
  49950. rebuild(): void;
  49951. /**
  49952. * Adds all the element from the container to the scene
  49953. * @param container the container holding the elements
  49954. */
  49955. addFromContainer(container: AbstractScene): void;
  49956. /**
  49957. * Removes all the elements in the container from the scene
  49958. * @param container contains the elements to remove
  49959. * @param dispose if the removed element should be disposed (default: false)
  49960. */
  49961. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49962. /**
  49963. * Serializes the component data to the specified json object
  49964. * @param serializationObject The object to serialize to
  49965. */
  49966. serialize(serializationObject: any): void;
  49967. /**
  49968. * Disposes the component and the associated ressources.
  49969. */
  49970. dispose(): void;
  49971. private _draw;
  49972. }
  49973. }
  49974. declare module "babylonjs/LensFlares/index" {
  49975. export * from "babylonjs/LensFlares/lensFlare";
  49976. export * from "babylonjs/LensFlares/lensFlareSystem";
  49977. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49978. }
  49979. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49980. import { Scene } from "babylonjs/scene";
  49981. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49982. import { AbstractScene } from "babylonjs/abstractScene";
  49983. /**
  49984. * Defines the shadow generator component responsible to manage any shadow generators
  49985. * in a given scene.
  49986. */
  49987. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49988. /**
  49989. * The component name helpfull to identify the component in the list of scene components.
  49990. */
  49991. readonly name: string;
  49992. /**
  49993. * The scene the component belongs to.
  49994. */
  49995. scene: Scene;
  49996. /**
  49997. * Creates a new instance of the component for the given scene
  49998. * @param scene Defines the scene to register the component in
  49999. */
  50000. constructor(scene: Scene);
  50001. /**
  50002. * Registers the component in a given scene
  50003. */
  50004. register(): void;
  50005. /**
  50006. * Rebuilds the elements related to this component in case of
  50007. * context lost for instance.
  50008. */
  50009. rebuild(): void;
  50010. /**
  50011. * Serializes the component data to the specified json object
  50012. * @param serializationObject The object to serialize to
  50013. */
  50014. serialize(serializationObject: any): void;
  50015. /**
  50016. * Adds all the element from the container to the scene
  50017. * @param container the container holding the elements
  50018. */
  50019. addFromContainer(container: AbstractScene): void;
  50020. /**
  50021. * Removes all the elements in the container from the scene
  50022. * @param container contains the elements to remove
  50023. * @param dispose if the removed element should be disposed (default: false)
  50024. */
  50025. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50026. /**
  50027. * Rebuilds the elements related to this component in case of
  50028. * context lost for instance.
  50029. */
  50030. dispose(): void;
  50031. private _gatherRenderTargets;
  50032. }
  50033. }
  50034. declare module "babylonjs/Lights/Shadows/index" {
  50035. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50036. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50037. }
  50038. declare module "babylonjs/Lights/pointLight" {
  50039. import { Scene } from "babylonjs/scene";
  50040. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50042. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50043. import { Effect } from "babylonjs/Materials/effect";
  50044. /**
  50045. * A point light is a light defined by an unique point in world space.
  50046. * The light is emitted in every direction from this point.
  50047. * A good example of a point light is a standard light bulb.
  50048. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50049. */
  50050. export class PointLight extends ShadowLight {
  50051. private _shadowAngle;
  50052. /**
  50053. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50054. * This specifies what angle the shadow will use to be created.
  50055. *
  50056. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50057. */
  50058. /**
  50059. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50060. * This specifies what angle the shadow will use to be created.
  50061. *
  50062. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50063. */
  50064. shadowAngle: number;
  50065. /**
  50066. * Gets the direction if it has been set.
  50067. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50068. */
  50069. /**
  50070. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50071. */
  50072. direction: Vector3;
  50073. /**
  50074. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50075. * A PointLight emits the light in every direction.
  50076. * It can cast shadows.
  50077. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50078. * ```javascript
  50079. * var pointLight = new PointLight("pl", camera.position, scene);
  50080. * ```
  50081. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50082. * @param name The light friendly name
  50083. * @param position The position of the point light in the scene
  50084. * @param scene The scene the lights belongs to
  50085. */
  50086. constructor(name: string, position: Vector3, scene: Scene);
  50087. /**
  50088. * Returns the string "PointLight"
  50089. * @returns the class name
  50090. */
  50091. getClassName(): string;
  50092. /**
  50093. * Returns the integer 0.
  50094. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50095. */
  50096. getTypeID(): number;
  50097. /**
  50098. * Specifies wether or not the shadowmap should be a cube texture.
  50099. * @returns true if the shadowmap needs to be a cube texture.
  50100. */
  50101. needCube(): boolean;
  50102. /**
  50103. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50106. */
  50107. getShadowDirection(faceIndex?: number): Vector3;
  50108. /**
  50109. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50110. * - fov = PI / 2
  50111. * - aspect ratio : 1.0
  50112. * - z-near and far equal to the active camera minZ and maxZ.
  50113. * Returns the PointLight.
  50114. */
  50115. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50116. protected _buildUniformLayout(): void;
  50117. /**
  50118. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50119. * @param effect The effect to update
  50120. * @param lightIndex The index of the light in the effect to update
  50121. * @returns The point light
  50122. */
  50123. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50124. /**
  50125. * Prepares the list of defines specific to the light type.
  50126. * @param defines the list of defines
  50127. * @param lightIndex defines the index of the light for the effect
  50128. */
  50129. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50130. }
  50131. }
  50132. declare module "babylonjs/Lights/index" {
  50133. export * from "babylonjs/Lights/light";
  50134. export * from "babylonjs/Lights/shadowLight";
  50135. export * from "babylonjs/Lights/Shadows/index";
  50136. export * from "babylonjs/Lights/directionalLight";
  50137. export * from "babylonjs/Lights/hemisphericLight";
  50138. export * from "babylonjs/Lights/pointLight";
  50139. export * from "babylonjs/Lights/spotLight";
  50140. }
  50141. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50142. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50143. /**
  50144. * Header information of HDR texture files.
  50145. */
  50146. export interface HDRInfo {
  50147. /**
  50148. * The height of the texture in pixels.
  50149. */
  50150. height: number;
  50151. /**
  50152. * The width of the texture in pixels.
  50153. */
  50154. width: number;
  50155. /**
  50156. * The index of the beginning of the data in the binary file.
  50157. */
  50158. dataPosition: number;
  50159. }
  50160. /**
  50161. * This groups tools to convert HDR texture to native colors array.
  50162. */
  50163. export class HDRTools {
  50164. private static Ldexp;
  50165. private static Rgbe2float;
  50166. private static readStringLine;
  50167. /**
  50168. * Reads header information from an RGBE texture stored in a native array.
  50169. * More information on this format are available here:
  50170. * https://en.wikipedia.org/wiki/RGBE_image_format
  50171. *
  50172. * @param uint8array The binary file stored in native array.
  50173. * @return The header information.
  50174. */
  50175. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50176. /**
  50177. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50178. * This RGBE texture needs to store the information as a panorama.
  50179. *
  50180. * More information on this format are available here:
  50181. * https://en.wikipedia.org/wiki/RGBE_image_format
  50182. *
  50183. * @param buffer The binary file stored in an array buffer.
  50184. * @param size The expected size of the extracted cubemap.
  50185. * @return The Cube Map information.
  50186. */
  50187. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50188. /**
  50189. * Returns the pixels data extracted from an RGBE texture.
  50190. * This pixels will be stored left to right up to down in the R G B order in one array.
  50191. *
  50192. * More information on this format are available here:
  50193. * https://en.wikipedia.org/wiki/RGBE_image_format
  50194. *
  50195. * @param uint8array The binary file stored in an array buffer.
  50196. * @param hdrInfo The header information of the file.
  50197. * @return The pixels data in RGB right to left up to down order.
  50198. */
  50199. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50200. private static RGBE_ReadPixels_RLE;
  50201. }
  50202. }
  50203. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50204. import { Nullable } from "babylonjs/types";
  50205. import { Scene } from "babylonjs/scene";
  50206. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50207. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50208. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50209. /**
  50210. * This represents a texture coming from an HDR input.
  50211. *
  50212. * The only supported format is currently panorama picture stored in RGBE format.
  50213. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50214. */
  50215. export class HDRCubeTexture extends BaseTexture {
  50216. private static _facesMapping;
  50217. private _generateHarmonics;
  50218. private _noMipmap;
  50219. private _textureMatrix;
  50220. private _size;
  50221. private _onLoad;
  50222. private _onError;
  50223. /**
  50224. * The texture URL.
  50225. */
  50226. url: string;
  50227. /**
  50228. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50229. */
  50230. coordinatesMode: number;
  50231. protected _isBlocking: boolean;
  50232. /**
  50233. * Sets wether or not the texture is blocking during loading.
  50234. */
  50235. /**
  50236. * Gets wether or not the texture is blocking during loading.
  50237. */
  50238. isBlocking: boolean;
  50239. protected _rotationY: number;
  50240. /**
  50241. * Sets texture matrix rotation angle around Y axis in radians.
  50242. */
  50243. /**
  50244. * Gets texture matrix rotation angle around Y axis radians.
  50245. */
  50246. rotationY: number;
  50247. /**
  50248. * Gets or sets the center of the bounding box associated with the cube texture
  50249. * It must define where the camera used to render the texture was set
  50250. */
  50251. boundingBoxPosition: Vector3;
  50252. private _boundingBoxSize;
  50253. /**
  50254. * Gets or sets the size of the bounding box associated with the cube texture
  50255. * When defined, the cubemap will switch to local mode
  50256. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50257. * @example https://www.babylonjs-playground.com/#RNASML
  50258. */
  50259. boundingBoxSize: Vector3;
  50260. /**
  50261. * Instantiates an HDRTexture from the following parameters.
  50262. *
  50263. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50264. * @param scene The scene the texture will be used in
  50265. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50266. * @param noMipmap Forces to not generate the mipmap if true
  50267. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50268. * @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)
  50269. * @param reserved Reserved flag for internal use.
  50270. */
  50271. 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>);
  50272. /**
  50273. * Get the current class name of the texture useful for serialization or dynamic coding.
  50274. * @returns "HDRCubeTexture"
  50275. */
  50276. getClassName(): string;
  50277. /**
  50278. * Occurs when the file is raw .hdr file.
  50279. */
  50280. private loadTexture;
  50281. clone(): HDRCubeTexture;
  50282. delayLoad(): void;
  50283. /**
  50284. * Get the texture reflection matrix used to rotate/transform the reflection.
  50285. * @returns the reflection matrix
  50286. */
  50287. getReflectionTextureMatrix(): Matrix;
  50288. /**
  50289. * Set the texture reflection matrix used to rotate/transform the reflection.
  50290. * @param value Define the reflection matrix to set
  50291. */
  50292. setReflectionTextureMatrix(value: Matrix): void;
  50293. /**
  50294. * Parses a JSON representation of an HDR Texture in order to create the texture
  50295. * @param parsedTexture Define the JSON representation
  50296. * @param scene Define the scene the texture should be created in
  50297. * @param rootUrl Define the root url in case we need to load relative dependencies
  50298. * @returns the newly created texture after parsing
  50299. */
  50300. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50301. serialize(): any;
  50302. }
  50303. }
  50304. declare module "babylonjs/Physics/physicsEngine" {
  50305. import { Nullable } from "babylonjs/types";
  50306. import { Vector3 } from "babylonjs/Maths/math";
  50307. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50308. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50309. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50310. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50311. /**
  50312. * Class used to control physics engine
  50313. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50314. */
  50315. export class PhysicsEngine implements IPhysicsEngine {
  50316. private _physicsPlugin;
  50317. /**
  50318. * Global value used to control the smallest number supported by the simulation
  50319. */
  50320. static Epsilon: number;
  50321. private _impostors;
  50322. private _joints;
  50323. /**
  50324. * Gets the gravity vector used by the simulation
  50325. */
  50326. gravity: Vector3;
  50327. /**
  50328. * Factory used to create the default physics plugin.
  50329. * @returns The default physics plugin
  50330. */
  50331. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50332. /**
  50333. * Creates a new Physics Engine
  50334. * @param gravity defines the gravity vector used by the simulation
  50335. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50336. */
  50337. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50338. /**
  50339. * Sets the gravity vector used by the simulation
  50340. * @param gravity defines the gravity vector to use
  50341. */
  50342. setGravity(gravity: Vector3): void;
  50343. /**
  50344. * Set the time step of the physics engine.
  50345. * Default is 1/60.
  50346. * To slow it down, enter 1/600 for example.
  50347. * To speed it up, 1/30
  50348. * @param newTimeStep defines the new timestep to apply to this world.
  50349. */
  50350. setTimeStep(newTimeStep?: number): void;
  50351. /**
  50352. * Get the time step of the physics engine.
  50353. * @returns the current time step
  50354. */
  50355. getTimeStep(): number;
  50356. /**
  50357. * Release all resources
  50358. */
  50359. dispose(): void;
  50360. /**
  50361. * Gets the name of the current physics plugin
  50362. * @returns the name of the plugin
  50363. */
  50364. getPhysicsPluginName(): string;
  50365. /**
  50366. * Adding a new impostor for the impostor tracking.
  50367. * This will be done by the impostor itself.
  50368. * @param impostor the impostor to add
  50369. */
  50370. addImpostor(impostor: PhysicsImpostor): void;
  50371. /**
  50372. * Remove an impostor from the engine.
  50373. * This impostor and its mesh will not longer be updated by the physics engine.
  50374. * @param impostor the impostor to remove
  50375. */
  50376. removeImpostor(impostor: PhysicsImpostor): void;
  50377. /**
  50378. * Add a joint to the physics engine
  50379. * @param mainImpostor defines the main impostor to which the joint is added.
  50380. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50381. * @param joint defines the joint that will connect both impostors.
  50382. */
  50383. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50384. /**
  50385. * Removes a joint from the simulation
  50386. * @param mainImpostor defines the impostor used with the joint
  50387. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50388. * @param joint defines the joint to remove
  50389. */
  50390. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50391. /**
  50392. * Called by the scene. No need to call it.
  50393. * @param delta defines the timespam between frames
  50394. */
  50395. _step(delta: number): void;
  50396. /**
  50397. * Gets the current plugin used to run the simulation
  50398. * @returns current plugin
  50399. */
  50400. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50401. /**
  50402. * Gets the list of physic impostors
  50403. * @returns an array of PhysicsImpostor
  50404. */
  50405. getImpostors(): Array<PhysicsImpostor>;
  50406. /**
  50407. * Gets the impostor for a physics enabled object
  50408. * @param object defines the object impersonated by the impostor
  50409. * @returns the PhysicsImpostor or null if not found
  50410. */
  50411. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50412. /**
  50413. * Gets the impostor for a physics body object
  50414. * @param body defines physics body used by the impostor
  50415. * @returns the PhysicsImpostor or null if not found
  50416. */
  50417. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50418. /**
  50419. * Does a raycast in the physics world
  50420. * @param from when should the ray start?
  50421. * @param to when should the ray end?
  50422. * @returns PhysicsRaycastResult
  50423. */
  50424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50425. }
  50426. }
  50427. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50428. import { Nullable } from "babylonjs/types";
  50429. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50431. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50432. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50433. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50434. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50435. /** @hidden */
  50436. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50437. private _useDeltaForWorldStep;
  50438. world: any;
  50439. name: string;
  50440. private _physicsMaterials;
  50441. private _fixedTimeStep;
  50442. private _cannonRaycastResult;
  50443. private _raycastResult;
  50444. private _removeAfterStep;
  50445. BJSCANNON: any;
  50446. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50447. setGravity(gravity: Vector3): void;
  50448. setTimeStep(timeStep: number): void;
  50449. getTimeStep(): number;
  50450. executeStep(delta: number): void;
  50451. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50452. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50453. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50454. private _processChildMeshes;
  50455. removePhysicsBody(impostor: PhysicsImpostor): void;
  50456. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50457. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50458. private _addMaterial;
  50459. private _checkWithEpsilon;
  50460. private _createShape;
  50461. private _createHeightmap;
  50462. private _minus90X;
  50463. private _plus90X;
  50464. private _tmpPosition;
  50465. private _tmpDeltaPosition;
  50466. private _tmpUnityRotation;
  50467. private _updatePhysicsBodyTransformation;
  50468. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50469. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50470. isSupported(): boolean;
  50471. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50472. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50473. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50474. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50475. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50476. getBodyMass(impostor: PhysicsImpostor): number;
  50477. getBodyFriction(impostor: PhysicsImpostor): number;
  50478. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50479. getBodyRestitution(impostor: PhysicsImpostor): number;
  50480. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50481. sleepBody(impostor: PhysicsImpostor): void;
  50482. wakeUpBody(impostor: PhysicsImpostor): void;
  50483. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50484. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50485. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50486. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50487. getRadius(impostor: PhysicsImpostor): number;
  50488. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50489. dispose(): void;
  50490. private _extendNamespace;
  50491. /**
  50492. * Does a raycast in the physics world
  50493. * @param from when should the ray start?
  50494. * @param to when should the ray end?
  50495. * @returns PhysicsRaycastResult
  50496. */
  50497. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50498. }
  50499. }
  50500. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50501. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50502. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50503. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50505. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50506. import { Nullable } from "babylonjs/types";
  50507. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50508. /** @hidden */
  50509. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50510. world: any;
  50511. name: string;
  50512. BJSOIMO: any;
  50513. private _raycastResult;
  50514. constructor(iterations?: number, oimoInjection?: any);
  50515. setGravity(gravity: Vector3): void;
  50516. setTimeStep(timeStep: number): void;
  50517. getTimeStep(): number;
  50518. private _tmpImpostorsArray;
  50519. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50520. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50521. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50522. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50523. private _tmpPositionVector;
  50524. removePhysicsBody(impostor: PhysicsImpostor): void;
  50525. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50526. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50527. isSupported(): boolean;
  50528. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50529. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50530. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50531. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50532. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50533. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50534. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50535. getBodyMass(impostor: PhysicsImpostor): number;
  50536. getBodyFriction(impostor: PhysicsImpostor): number;
  50537. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50538. getBodyRestitution(impostor: PhysicsImpostor): number;
  50539. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50540. sleepBody(impostor: PhysicsImpostor): void;
  50541. wakeUpBody(impostor: PhysicsImpostor): void;
  50542. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50543. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50544. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50545. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50546. getRadius(impostor: PhysicsImpostor): number;
  50547. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50548. dispose(): void;
  50549. /**
  50550. * Does a raycast in the physics world
  50551. * @param from when should the ray start?
  50552. * @param to when should the ray end?
  50553. * @returns PhysicsRaycastResult
  50554. */
  50555. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50556. }
  50557. }
  50558. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50559. import { Nullable } from "babylonjs/types";
  50560. import { Scene } from "babylonjs/scene";
  50561. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50562. import { Mesh } from "babylonjs/Meshes/mesh";
  50563. /**
  50564. * Class containing static functions to help procedurally build meshes
  50565. */
  50566. export class RibbonBuilder {
  50567. /**
  50568. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50569. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50570. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50571. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50572. * * 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
  50573. * * 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
  50574. * * 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
  50575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50578. * * 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
  50579. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50580. * * 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
  50581. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50583. * @param name defines the name of the mesh
  50584. * @param options defines the options used to create the mesh
  50585. * @param scene defines the hosting scene
  50586. * @returns the ribbon mesh
  50587. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50589. */
  50590. static CreateRibbon(name: string, options: {
  50591. pathArray: Vector3[][];
  50592. closeArray?: boolean;
  50593. closePath?: boolean;
  50594. offset?: number;
  50595. updatable?: boolean;
  50596. sideOrientation?: number;
  50597. frontUVs?: Vector4;
  50598. backUVs?: Vector4;
  50599. instance?: Mesh;
  50600. invertUV?: boolean;
  50601. uvs?: Vector2[];
  50602. colors?: Color4[];
  50603. }, scene?: Nullable<Scene>): Mesh;
  50604. }
  50605. }
  50606. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50607. import { Nullable } from "babylonjs/types";
  50608. import { Scene } from "babylonjs/scene";
  50609. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50610. import { Mesh } from "babylonjs/Meshes/mesh";
  50611. /**
  50612. * Class containing static functions to help procedurally build meshes
  50613. */
  50614. export class ShapeBuilder {
  50615. /**
  50616. * 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.
  50617. * * 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.
  50618. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50619. * * 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.
  50620. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50621. * * 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
  50622. * * 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
  50623. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50626. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50628. * @param name defines the name of the mesh
  50629. * @param options defines the options used to create the mesh
  50630. * @param scene defines the hosting scene
  50631. * @returns the extruded shape mesh
  50632. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50634. */
  50635. static ExtrudeShape(name: string, options: {
  50636. shape: Vector3[];
  50637. path: Vector3[];
  50638. scale?: number;
  50639. rotation?: number;
  50640. cap?: number;
  50641. updatable?: boolean;
  50642. sideOrientation?: number;
  50643. frontUVs?: Vector4;
  50644. backUVs?: Vector4;
  50645. instance?: Mesh;
  50646. invertUV?: boolean;
  50647. }, scene?: Nullable<Scene>): Mesh;
  50648. /**
  50649. * Creates an custom extruded shape mesh.
  50650. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50651. * * 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.
  50652. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50653. * * 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
  50654. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50655. * * 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
  50656. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50657. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50658. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50659. * * 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
  50660. * * 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
  50661. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50666. * @param name defines the name of the mesh
  50667. * @param options defines the options used to create the mesh
  50668. * @param scene defines the hosting scene
  50669. * @returns the custom extruded shape mesh
  50670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50673. */
  50674. static ExtrudeShapeCustom(name: string, options: {
  50675. shape: Vector3[];
  50676. path: Vector3[];
  50677. scaleFunction?: any;
  50678. rotationFunction?: any;
  50679. ribbonCloseArray?: boolean;
  50680. ribbonClosePath?: boolean;
  50681. cap?: number;
  50682. updatable?: boolean;
  50683. sideOrientation?: number;
  50684. frontUVs?: Vector4;
  50685. backUVs?: Vector4;
  50686. instance?: Mesh;
  50687. invertUV?: boolean;
  50688. }, scene?: Nullable<Scene>): Mesh;
  50689. private static _ExtrudeShapeGeneric;
  50690. }
  50691. }
  50692. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50693. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50694. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50695. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50696. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50697. import { Nullable } from "babylonjs/types";
  50698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50699. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50700. /**
  50701. * AmmoJS Physics plugin
  50702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50703. * @see https://github.com/kripken/ammo.js/
  50704. */
  50705. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50706. private _useDeltaForWorldStep;
  50707. /**
  50708. * Reference to the Ammo library
  50709. */
  50710. bjsAMMO: any;
  50711. /**
  50712. * Created ammoJS world which physics bodies are added to
  50713. */
  50714. world: any;
  50715. /**
  50716. * Name of the plugin
  50717. */
  50718. name: string;
  50719. private _timeStep;
  50720. private _fixedTimeStep;
  50721. private _maxSteps;
  50722. private _tmpQuaternion;
  50723. private _tmpAmmoTransform;
  50724. private _tmpAmmoQuaternion;
  50725. private _tmpAmmoConcreteContactResultCallback;
  50726. private _collisionConfiguration;
  50727. private _dispatcher;
  50728. private _overlappingPairCache;
  50729. private _solver;
  50730. private _softBodySolver;
  50731. private _tmpAmmoVectorA;
  50732. private _tmpAmmoVectorB;
  50733. private _tmpAmmoVectorC;
  50734. private _tmpAmmoVectorD;
  50735. private _tmpContactCallbackResult;
  50736. private _tmpAmmoVectorRCA;
  50737. private _tmpAmmoVectorRCB;
  50738. private _raycastResult;
  50739. private static readonly DISABLE_COLLISION_FLAG;
  50740. private static readonly KINEMATIC_FLAG;
  50741. private static readonly DISABLE_DEACTIVATION_FLAG;
  50742. /**
  50743. * Initializes the ammoJS plugin
  50744. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50745. * @param ammoInjection can be used to inject your own ammo reference
  50746. */
  50747. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50748. /**
  50749. * Sets the gravity of the physics world (m/(s^2))
  50750. * @param gravity Gravity to set
  50751. */
  50752. setGravity(gravity: Vector3): void;
  50753. /**
  50754. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50755. * @param timeStep timestep to use in seconds
  50756. */
  50757. setTimeStep(timeStep: number): void;
  50758. /**
  50759. * 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)
  50760. * @param fixedTimeStep fixedTimeStep to use in seconds
  50761. */
  50762. setFixedTimeStep(fixedTimeStep: number): void;
  50763. /**
  50764. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50765. * @param maxSteps the maximum number of steps by the physics engine per frame
  50766. */
  50767. setMaxSteps(maxSteps: number): void;
  50768. /**
  50769. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50770. * @returns the current timestep in seconds
  50771. */
  50772. getTimeStep(): number;
  50773. private _isImpostorInContact;
  50774. private _isImpostorPairInContact;
  50775. private _stepSimulation;
  50776. /**
  50777. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50778. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50779. * After the step the babylon meshes are set to the position of the physics imposters
  50780. * @param delta amount of time to step forward
  50781. * @param impostors array of imposters to update before/after the step
  50782. */
  50783. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50784. /**
  50785. * Update babylon mesh to match physics world object
  50786. * @param impostor imposter to match
  50787. */
  50788. private _afterSoftStep;
  50789. /**
  50790. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50791. * @param impostor imposter to match
  50792. */
  50793. private _ropeStep;
  50794. /**
  50795. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50796. * @param impostor imposter to match
  50797. */
  50798. private _softbodyOrClothStep;
  50799. private _tmpVector;
  50800. private _tmpMatrix;
  50801. /**
  50802. * Applies an impulse on the imposter
  50803. * @param impostor imposter to apply impulse to
  50804. * @param force amount of force to be applied to the imposter
  50805. * @param contactPoint the location to apply the impulse on the imposter
  50806. */
  50807. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50808. /**
  50809. * Applies a force on the imposter
  50810. * @param impostor imposter to apply force
  50811. * @param force amount of force to be applied to the imposter
  50812. * @param contactPoint the location to apply the force on the imposter
  50813. */
  50814. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50815. /**
  50816. * Creates a physics body using the plugin
  50817. * @param impostor the imposter to create the physics body on
  50818. */
  50819. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50820. /**
  50821. * Removes the physics body from the imposter and disposes of the body's memory
  50822. * @param impostor imposter to remove the physics body from
  50823. */
  50824. removePhysicsBody(impostor: PhysicsImpostor): void;
  50825. /**
  50826. * Generates a joint
  50827. * @param impostorJoint the imposter joint to create the joint with
  50828. */
  50829. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50830. /**
  50831. * Removes a joint
  50832. * @param impostorJoint the imposter joint to remove the joint from
  50833. */
  50834. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50835. private _addMeshVerts;
  50836. /**
  50837. * Initialise the soft body vertices to match its object's (mesh) vertices
  50838. * Softbody vertices (nodes) are in world space and to match this
  50839. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50840. * @param impostor to create the softbody for
  50841. */
  50842. private _softVertexData;
  50843. /**
  50844. * Create an impostor's soft body
  50845. * @param impostor to create the softbody for
  50846. */
  50847. private _createSoftbody;
  50848. /**
  50849. * Create cloth for an impostor
  50850. * @param impostor to create the softbody for
  50851. */
  50852. private _createCloth;
  50853. /**
  50854. * Create rope for an impostor
  50855. * @param impostor to create the softbody for
  50856. */
  50857. private _createRope;
  50858. private _addHullVerts;
  50859. private _createShape;
  50860. /**
  50861. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50862. * @param impostor imposter containing the physics body and babylon object
  50863. */
  50864. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50865. /**
  50866. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50867. * @param impostor imposter containing the physics body and babylon object
  50868. * @param newPosition new position
  50869. * @param newRotation new rotation
  50870. */
  50871. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50872. /**
  50873. * If this plugin is supported
  50874. * @returns true if its supported
  50875. */
  50876. isSupported(): boolean;
  50877. /**
  50878. * Sets the linear velocity of the physics body
  50879. * @param impostor imposter to set the velocity on
  50880. * @param velocity velocity to set
  50881. */
  50882. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50883. /**
  50884. * Sets the angular velocity of the physics body
  50885. * @param impostor imposter to set the velocity on
  50886. * @param velocity velocity to set
  50887. */
  50888. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50889. /**
  50890. * gets the linear velocity
  50891. * @param impostor imposter to get linear velocity from
  50892. * @returns linear velocity
  50893. */
  50894. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50895. /**
  50896. * gets the angular velocity
  50897. * @param impostor imposter to get angular velocity from
  50898. * @returns angular velocity
  50899. */
  50900. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50901. /**
  50902. * Sets the mass of physics body
  50903. * @param impostor imposter to set the mass on
  50904. * @param mass mass to set
  50905. */
  50906. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50907. /**
  50908. * Gets the mass of the physics body
  50909. * @param impostor imposter to get the mass from
  50910. * @returns mass
  50911. */
  50912. getBodyMass(impostor: PhysicsImpostor): number;
  50913. /**
  50914. * Gets friction of the impostor
  50915. * @param impostor impostor to get friction from
  50916. * @returns friction value
  50917. */
  50918. getBodyFriction(impostor: PhysicsImpostor): number;
  50919. /**
  50920. * Sets friction of the impostor
  50921. * @param impostor impostor to set friction on
  50922. * @param friction friction value
  50923. */
  50924. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50925. /**
  50926. * Gets restitution of the impostor
  50927. * @param impostor impostor to get restitution from
  50928. * @returns restitution value
  50929. */
  50930. getBodyRestitution(impostor: PhysicsImpostor): number;
  50931. /**
  50932. * Sets resitution of the impostor
  50933. * @param impostor impostor to set resitution on
  50934. * @param restitution resitution value
  50935. */
  50936. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50937. /**
  50938. * Gets pressure inside the impostor
  50939. * @param impostor impostor to get pressure from
  50940. * @returns pressure value
  50941. */
  50942. getBodyPressure(impostor: PhysicsImpostor): number;
  50943. /**
  50944. * Sets pressure inside a soft body impostor
  50945. * Cloth and rope must remain 0 pressure
  50946. * @param impostor impostor to set pressure on
  50947. * @param pressure pressure value
  50948. */
  50949. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50950. /**
  50951. * Gets stiffness of the impostor
  50952. * @param impostor impostor to get stiffness from
  50953. * @returns pressure value
  50954. */
  50955. getBodyStiffness(impostor: PhysicsImpostor): number;
  50956. /**
  50957. * Sets stiffness of the impostor
  50958. * @param impostor impostor to set stiffness on
  50959. * @param stiffness stiffness value from 0 to 1
  50960. */
  50961. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50962. /**
  50963. * Gets velocityIterations of the impostor
  50964. * @param impostor impostor to get velocity iterations from
  50965. * @returns velocityIterations value
  50966. */
  50967. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50968. /**
  50969. * Sets velocityIterations of the impostor
  50970. * @param impostor impostor to set velocity iterations on
  50971. * @param velocityIterations velocityIterations value
  50972. */
  50973. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50974. /**
  50975. * Gets positionIterations of the impostor
  50976. * @param impostor impostor to get position iterations from
  50977. * @returns positionIterations value
  50978. */
  50979. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50980. /**
  50981. * Sets positionIterations of the impostor
  50982. * @param impostor impostor to set position on
  50983. * @param positionIterations positionIterations value
  50984. */
  50985. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50986. /**
  50987. * Append an anchor to a cloth object
  50988. * @param impostor is the cloth impostor to add anchor to
  50989. * @param otherImpostor is the rigid impostor to anchor to
  50990. * @param width ratio across width from 0 to 1
  50991. * @param height ratio up height from 0 to 1
  50992. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50993. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50994. */
  50995. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50996. /**
  50997. * Append an hook to a rope object
  50998. * @param impostor is the rope impostor to add hook to
  50999. * @param otherImpostor is the rigid impostor to hook to
  51000. * @param length ratio along the rope from 0 to 1
  51001. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51002. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51003. */
  51004. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51005. /**
  51006. * Sleeps the physics body and stops it from being active
  51007. * @param impostor impostor to sleep
  51008. */
  51009. sleepBody(impostor: PhysicsImpostor): void;
  51010. /**
  51011. * Activates the physics body
  51012. * @param impostor impostor to activate
  51013. */
  51014. wakeUpBody(impostor: PhysicsImpostor): void;
  51015. /**
  51016. * Updates the distance parameters of the joint
  51017. * @param joint joint to update
  51018. * @param maxDistance maximum distance of the joint
  51019. * @param minDistance minimum distance of the joint
  51020. */
  51021. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51022. /**
  51023. * Sets a motor on the joint
  51024. * @param joint joint to set motor on
  51025. * @param speed speed of the motor
  51026. * @param maxForce maximum force of the motor
  51027. * @param motorIndex index of the motor
  51028. */
  51029. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51030. /**
  51031. * Sets the motors limit
  51032. * @param joint joint to set limit on
  51033. * @param upperLimit upper limit
  51034. * @param lowerLimit lower limit
  51035. */
  51036. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51037. /**
  51038. * Syncs the position and rotation of a mesh with the impostor
  51039. * @param mesh mesh to sync
  51040. * @param impostor impostor to update the mesh with
  51041. */
  51042. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51043. /**
  51044. * Gets the radius of the impostor
  51045. * @param impostor impostor to get radius from
  51046. * @returns the radius
  51047. */
  51048. getRadius(impostor: PhysicsImpostor): number;
  51049. /**
  51050. * Gets the box size of the impostor
  51051. * @param impostor impostor to get box size from
  51052. * @param result the resulting box size
  51053. */
  51054. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51055. /**
  51056. * Disposes of the impostor
  51057. */
  51058. dispose(): void;
  51059. /**
  51060. * Does a raycast in the physics world
  51061. * @param from when should the ray start?
  51062. * @param to when should the ray end?
  51063. * @returns PhysicsRaycastResult
  51064. */
  51065. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51066. }
  51067. }
  51068. declare module "babylonjs/Probes/reflectionProbe" {
  51069. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51070. import { Vector3 } from "babylonjs/Maths/math";
  51071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51072. import { Nullable } from "babylonjs/types";
  51073. import { Scene } from "babylonjs/scene";
  51074. module "babylonjs/abstractScene" {
  51075. interface AbstractScene {
  51076. /**
  51077. * The list of reflection probes added to the scene
  51078. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51079. */
  51080. reflectionProbes: Array<ReflectionProbe>;
  51081. /**
  51082. * Removes the given reflection probe from this scene.
  51083. * @param toRemove The reflection probe to remove
  51084. * @returns The index of the removed reflection probe
  51085. */
  51086. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51087. /**
  51088. * Adds the given reflection probe to this scene.
  51089. * @param newReflectionProbe The reflection probe to add
  51090. */
  51091. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51092. }
  51093. }
  51094. /**
  51095. * Class used to generate realtime reflection / refraction cube textures
  51096. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51097. */
  51098. export class ReflectionProbe {
  51099. /** defines the name of the probe */
  51100. name: string;
  51101. private _scene;
  51102. private _renderTargetTexture;
  51103. private _projectionMatrix;
  51104. private _viewMatrix;
  51105. private _target;
  51106. private _add;
  51107. private _attachedMesh;
  51108. private _invertYAxis;
  51109. /** Gets or sets probe position (center of the cube map) */
  51110. position: Vector3;
  51111. /**
  51112. * Creates a new reflection probe
  51113. * @param name defines the name of the probe
  51114. * @param size defines the texture resolution (for each face)
  51115. * @param scene defines the hosting scene
  51116. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51117. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51118. */
  51119. constructor(
  51120. /** defines the name of the probe */
  51121. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51122. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51123. samples: number;
  51124. /** Gets or sets the refresh rate to use (on every frame by default) */
  51125. refreshRate: number;
  51126. /**
  51127. * Gets the hosting scene
  51128. * @returns a Scene
  51129. */
  51130. getScene(): Scene;
  51131. /** Gets the internal CubeTexture used to render to */
  51132. readonly cubeTexture: RenderTargetTexture;
  51133. /** Gets the list of meshes to render */
  51134. readonly renderList: Nullable<AbstractMesh[]>;
  51135. /**
  51136. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51137. * @param mesh defines the mesh to attach to
  51138. */
  51139. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51140. /**
  51141. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51142. * @param renderingGroupId The rendering group id corresponding to its index
  51143. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51144. */
  51145. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51146. /**
  51147. * Clean all associated resources
  51148. */
  51149. dispose(): void;
  51150. /**
  51151. * Converts the reflection probe information to a readable string for debug purpose.
  51152. * @param fullDetails Supports for multiple levels of logging within scene loading
  51153. * @returns the human readable reflection probe info
  51154. */
  51155. toString(fullDetails?: boolean): string;
  51156. /**
  51157. * Get the class name of the relfection probe.
  51158. * @returns "ReflectionProbe"
  51159. */
  51160. getClassName(): string;
  51161. /**
  51162. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51163. * @returns The JSON representation of the texture
  51164. */
  51165. serialize(): any;
  51166. /**
  51167. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51168. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51169. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51170. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51171. * @returns The parsed reflection probe if successful
  51172. */
  51173. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51174. }
  51175. }
  51176. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51177. /** @hidden */
  51178. export var _BabylonLoaderRegistered: boolean;
  51179. }
  51180. declare module "babylonjs/Loading/Plugins/index" {
  51181. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51182. }
  51183. declare module "babylonjs/Loading/index" {
  51184. export * from "babylonjs/Loading/loadingScreen";
  51185. export * from "babylonjs/Loading/Plugins/index";
  51186. export * from "babylonjs/Loading/sceneLoader";
  51187. export * from "babylonjs/Loading/sceneLoaderFlags";
  51188. }
  51189. declare module "babylonjs/Materials/Background/index" {
  51190. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51191. }
  51192. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51193. import { Scene } from "babylonjs/scene";
  51194. import { Color3 } from "babylonjs/Maths/math";
  51195. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51196. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51197. /**
  51198. * The Physically based simple base material of BJS.
  51199. *
  51200. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51201. * It is used as the base class for both the specGloss and metalRough conventions.
  51202. */
  51203. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51204. /**
  51205. * Number of Simultaneous lights allowed on the material.
  51206. */
  51207. maxSimultaneousLights: number;
  51208. /**
  51209. * If sets to true, disables all the lights affecting the material.
  51210. */
  51211. disableLighting: boolean;
  51212. /**
  51213. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51214. */
  51215. environmentTexture: BaseTexture;
  51216. /**
  51217. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51218. */
  51219. invertNormalMapX: boolean;
  51220. /**
  51221. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51222. */
  51223. invertNormalMapY: boolean;
  51224. /**
  51225. * Normal map used in the model.
  51226. */
  51227. normalTexture: BaseTexture;
  51228. /**
  51229. * Emissivie color used to self-illuminate the model.
  51230. */
  51231. emissiveColor: Color3;
  51232. /**
  51233. * Emissivie texture used to self-illuminate the model.
  51234. */
  51235. emissiveTexture: BaseTexture;
  51236. /**
  51237. * Occlusion Channel Strenght.
  51238. */
  51239. occlusionStrength: number;
  51240. /**
  51241. * Occlusion Texture of the material (adding extra occlusion effects).
  51242. */
  51243. occlusionTexture: BaseTexture;
  51244. /**
  51245. * Defines the alpha limits in alpha test mode.
  51246. */
  51247. alphaCutOff: number;
  51248. /**
  51249. * Gets the current double sided mode.
  51250. */
  51251. /**
  51252. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51253. */
  51254. doubleSided: boolean;
  51255. /**
  51256. * Stores the pre-calculated light information of a mesh in a texture.
  51257. */
  51258. lightmapTexture: BaseTexture;
  51259. /**
  51260. * If true, the light map contains occlusion information instead of lighting info.
  51261. */
  51262. useLightmapAsShadowmap: boolean;
  51263. /**
  51264. * Instantiates a new PBRMaterial instance.
  51265. *
  51266. * @param name The material name
  51267. * @param scene The scene the material will be use in.
  51268. */
  51269. constructor(name: string, scene: Scene);
  51270. getClassName(): string;
  51271. }
  51272. }
  51273. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51274. import { Scene } from "babylonjs/scene";
  51275. import { Color3 } from "babylonjs/Maths/math";
  51276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51277. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51278. /**
  51279. * The PBR material of BJS following the metal roughness convention.
  51280. *
  51281. * This fits to the PBR convention in the GLTF definition:
  51282. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51283. */
  51284. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51285. /**
  51286. * The base color has two different interpretations depending on the value of metalness.
  51287. * When the material is a metal, the base color is the specific measured reflectance value
  51288. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51289. * of the material.
  51290. */
  51291. baseColor: Color3;
  51292. /**
  51293. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51294. * well as opacity information in the alpha channel.
  51295. */
  51296. baseTexture: BaseTexture;
  51297. /**
  51298. * Specifies the metallic scalar value of the material.
  51299. * Can also be used to scale the metalness values of the metallic texture.
  51300. */
  51301. metallic: number;
  51302. /**
  51303. * Specifies the roughness scalar value of the material.
  51304. * Can also be used to scale the roughness values of the metallic texture.
  51305. */
  51306. roughness: number;
  51307. /**
  51308. * Texture containing both the metallic value in the B channel and the
  51309. * roughness value in the G channel to keep better precision.
  51310. */
  51311. metallicRoughnessTexture: BaseTexture;
  51312. /**
  51313. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51314. *
  51315. * @param name The material name
  51316. * @param scene The scene the material will be use in.
  51317. */
  51318. constructor(name: string, scene: Scene);
  51319. /**
  51320. * Return the currrent class name of the material.
  51321. */
  51322. getClassName(): string;
  51323. /**
  51324. * Makes a duplicate of the current material.
  51325. * @param name - name to use for the new material.
  51326. */
  51327. clone(name: string): PBRMetallicRoughnessMaterial;
  51328. /**
  51329. * Serialize the material to a parsable JSON object.
  51330. */
  51331. serialize(): any;
  51332. /**
  51333. * Parses a JSON object correponding to the serialize function.
  51334. */
  51335. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51336. }
  51337. }
  51338. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51339. import { Scene } from "babylonjs/scene";
  51340. import { Color3 } from "babylonjs/Maths/math";
  51341. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51342. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51343. /**
  51344. * The PBR material of BJS following the specular glossiness convention.
  51345. *
  51346. * This fits to the PBR convention in the GLTF definition:
  51347. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51348. */
  51349. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51350. /**
  51351. * Specifies the diffuse color of the material.
  51352. */
  51353. diffuseColor: Color3;
  51354. /**
  51355. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51356. * channel.
  51357. */
  51358. diffuseTexture: BaseTexture;
  51359. /**
  51360. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51361. */
  51362. specularColor: Color3;
  51363. /**
  51364. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51365. */
  51366. glossiness: number;
  51367. /**
  51368. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51369. */
  51370. specularGlossinessTexture: BaseTexture;
  51371. /**
  51372. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51373. *
  51374. * @param name The material name
  51375. * @param scene The scene the material will be use in.
  51376. */
  51377. constructor(name: string, scene: Scene);
  51378. /**
  51379. * Return the currrent class name of the material.
  51380. */
  51381. getClassName(): string;
  51382. /**
  51383. * Makes a duplicate of the current material.
  51384. * @param name - name to use for the new material.
  51385. */
  51386. clone(name: string): PBRSpecularGlossinessMaterial;
  51387. /**
  51388. * Serialize the material to a parsable JSON object.
  51389. */
  51390. serialize(): any;
  51391. /**
  51392. * Parses a JSON object correponding to the serialize function.
  51393. */
  51394. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51395. }
  51396. }
  51397. declare module "babylonjs/Materials/PBR/index" {
  51398. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51399. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51400. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51401. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51402. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51403. }
  51404. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51405. import { Nullable } from "babylonjs/types";
  51406. import { Scene } from "babylonjs/scene";
  51407. import { Matrix } from "babylonjs/Maths/math";
  51408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51409. /**
  51410. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51411. * It can help converting any input color in a desired output one. This can then be used to create effects
  51412. * from sepia, black and white to sixties or futuristic rendering...
  51413. *
  51414. * The only supported format is currently 3dl.
  51415. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51416. */
  51417. export class ColorGradingTexture extends BaseTexture {
  51418. /**
  51419. * The current texture matrix. (will always be identity in color grading texture)
  51420. */
  51421. private _textureMatrix;
  51422. /**
  51423. * The texture URL.
  51424. */
  51425. url: string;
  51426. /**
  51427. * Empty line regex stored for GC.
  51428. */
  51429. private static _noneEmptyLineRegex;
  51430. private _engine;
  51431. /**
  51432. * Instantiates a ColorGradingTexture from the following parameters.
  51433. *
  51434. * @param url The location of the color gradind data (currently only supporting 3dl)
  51435. * @param scene The scene the texture will be used in
  51436. */
  51437. constructor(url: string, scene: Scene);
  51438. /**
  51439. * Returns the texture matrix used in most of the material.
  51440. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51441. */
  51442. getTextureMatrix(): Matrix;
  51443. /**
  51444. * Occurs when the file being loaded is a .3dl LUT file.
  51445. */
  51446. private load3dlTexture;
  51447. /**
  51448. * Starts the loading process of the texture.
  51449. */
  51450. private loadTexture;
  51451. /**
  51452. * Clones the color gradind texture.
  51453. */
  51454. clone(): ColorGradingTexture;
  51455. /**
  51456. * Called during delayed load for textures.
  51457. */
  51458. delayLoad(): void;
  51459. /**
  51460. * Parses a color grading texture serialized by Babylon.
  51461. * @param parsedTexture The texture information being parsedTexture
  51462. * @param scene The scene to load the texture in
  51463. * @param rootUrl The root url of the data assets to load
  51464. * @return A color gradind texture
  51465. */
  51466. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51467. /**
  51468. * Serializes the LUT texture to json format.
  51469. */
  51470. serialize(): any;
  51471. }
  51472. }
  51473. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51475. import { Scene } from "babylonjs/scene";
  51476. import { Nullable } from "babylonjs/types";
  51477. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51478. /**
  51479. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51480. */
  51481. export class EquiRectangularCubeTexture extends BaseTexture {
  51482. /** The six faces of the cube. */
  51483. private static _FacesMapping;
  51484. private _noMipmap;
  51485. private _onLoad;
  51486. private _onError;
  51487. /** The size of the cubemap. */
  51488. private _size;
  51489. /** The buffer of the image. */
  51490. private _buffer;
  51491. /** The width of the input image. */
  51492. private _width;
  51493. /** The height of the input image. */
  51494. private _height;
  51495. /** The URL to the image. */
  51496. url: string;
  51497. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51498. coordinatesMode: number;
  51499. /**
  51500. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51501. * @param url The location of the image
  51502. * @param scene The scene the texture will be used in
  51503. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51504. * @param noMipmap Forces to not generate the mipmap if true
  51505. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51506. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51507. * @param onLoad — defines a callback called when texture is loaded
  51508. * @param onError — defines a callback called if there is an error
  51509. */
  51510. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51511. /**
  51512. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51513. */
  51514. private loadImage;
  51515. /**
  51516. * Convert the image buffer into a cubemap and create a CubeTexture.
  51517. */
  51518. private loadTexture;
  51519. /**
  51520. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51521. * @param buffer The ArrayBuffer that should be converted.
  51522. * @returns The buffer as Float32Array.
  51523. */
  51524. private getFloat32ArrayFromArrayBuffer;
  51525. /**
  51526. * Get the current class name of the texture useful for serialization or dynamic coding.
  51527. * @returns "EquiRectangularCubeTexture"
  51528. */
  51529. getClassName(): string;
  51530. /**
  51531. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51532. * @returns A clone of the current EquiRectangularCubeTexture.
  51533. */
  51534. clone(): EquiRectangularCubeTexture;
  51535. }
  51536. }
  51537. declare module "babylonjs/Misc/tga" {
  51538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51539. /**
  51540. * Based on jsTGALoader - Javascript loader for TGA file
  51541. * By Vincent Thibault
  51542. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51543. */
  51544. export class TGATools {
  51545. private static _TYPE_INDEXED;
  51546. private static _TYPE_RGB;
  51547. private static _TYPE_GREY;
  51548. private static _TYPE_RLE_INDEXED;
  51549. private static _TYPE_RLE_RGB;
  51550. private static _TYPE_RLE_GREY;
  51551. private static _ORIGIN_MASK;
  51552. private static _ORIGIN_SHIFT;
  51553. private static _ORIGIN_BL;
  51554. private static _ORIGIN_BR;
  51555. private static _ORIGIN_UL;
  51556. private static _ORIGIN_UR;
  51557. /**
  51558. * Gets the header of a TGA file
  51559. * @param data defines the TGA data
  51560. * @returns the header
  51561. */
  51562. static GetTGAHeader(data: Uint8Array): any;
  51563. /**
  51564. * Uploads TGA content to a Babylon Texture
  51565. * @hidden
  51566. */
  51567. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51568. /** @hidden */
  51569. 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;
  51570. /** @hidden */
  51571. 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;
  51572. /** @hidden */
  51573. 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;
  51574. /** @hidden */
  51575. 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;
  51576. /** @hidden */
  51577. 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;
  51578. /** @hidden */
  51579. 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;
  51580. }
  51581. }
  51582. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51583. import { Nullable } from "babylonjs/types";
  51584. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51585. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51586. /**
  51587. * Implementation of the TGA Texture Loader.
  51588. * @hidden
  51589. */
  51590. export class _TGATextureLoader implements IInternalTextureLoader {
  51591. /**
  51592. * Defines wether the loader supports cascade loading the different faces.
  51593. */
  51594. readonly supportCascades: boolean;
  51595. /**
  51596. * This returns if the loader support the current file information.
  51597. * @param extension defines the file extension of the file being loaded
  51598. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51599. * @param fallback defines the fallback internal texture if any
  51600. * @param isBase64 defines whether the texture is encoded as a base64
  51601. * @param isBuffer defines whether the texture data are stored as a buffer
  51602. * @returns true if the loader can load the specified file
  51603. */
  51604. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51605. /**
  51606. * Transform the url before loading if required.
  51607. * @param rootUrl the url of the texture
  51608. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51609. * @returns the transformed texture
  51610. */
  51611. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51612. /**
  51613. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51614. * @param rootUrl the url of the texture
  51615. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51616. * @returns the fallback texture
  51617. */
  51618. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51619. /**
  51620. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51621. * @param data contains the texture data
  51622. * @param texture defines the BabylonJS internal texture
  51623. * @param createPolynomials will be true if polynomials have been requested
  51624. * @param onLoad defines the callback to trigger once the texture is ready
  51625. * @param onError defines the callback to trigger in case of error
  51626. */
  51627. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51628. /**
  51629. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51630. * @param data contains the texture data
  51631. * @param texture defines the BabylonJS internal texture
  51632. * @param callback defines the method to call once ready to upload
  51633. */
  51634. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51635. }
  51636. }
  51637. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51638. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51639. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51640. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51641. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51642. }
  51643. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51644. import { Scene } from "babylonjs/scene";
  51645. import { Texture } from "babylonjs/Materials/Textures/texture";
  51646. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51647. /**
  51648. * 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.
  51649. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51651. */
  51652. export class CustomProceduralTexture extends ProceduralTexture {
  51653. private _animate;
  51654. private _time;
  51655. private _config;
  51656. private _texturePath;
  51657. /**
  51658. * Instantiates a new Custom Procedural Texture.
  51659. * 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.
  51660. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51661. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51662. * @param name Define the name of the texture
  51663. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51664. * @param size Define the size of the texture to create
  51665. * @param scene Define the scene the texture belongs to
  51666. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51667. * @param generateMipMaps Define if the texture should creates mip maps or not
  51668. */
  51669. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51670. private _loadJson;
  51671. /**
  51672. * Is the texture ready to be used ? (rendered at least once)
  51673. * @returns true if ready, otherwise, false.
  51674. */
  51675. isReady(): boolean;
  51676. /**
  51677. * Render the texture to its associated render target.
  51678. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51679. */
  51680. render(useCameraPostProcess?: boolean): void;
  51681. /**
  51682. * Update the list of dependant textures samplers in the shader.
  51683. */
  51684. updateTextures(): void;
  51685. /**
  51686. * Update the uniform values of the procedural texture in the shader.
  51687. */
  51688. updateShaderUniforms(): void;
  51689. /**
  51690. * Define if the texture animates or not.
  51691. */
  51692. animate: boolean;
  51693. }
  51694. }
  51695. declare module "babylonjs/Shaders/noise.fragment" {
  51696. /** @hidden */
  51697. export var noisePixelShader: {
  51698. name: string;
  51699. shader: string;
  51700. };
  51701. }
  51702. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51703. import { Nullable } from "babylonjs/types";
  51704. import { Scene } from "babylonjs/scene";
  51705. import { Texture } from "babylonjs/Materials/Textures/texture";
  51706. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51707. import "babylonjs/Shaders/noise.fragment";
  51708. /**
  51709. * Class used to generate noise procedural textures
  51710. */
  51711. export class NoiseProceduralTexture extends ProceduralTexture {
  51712. private _time;
  51713. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51714. brightness: number;
  51715. /** Defines the number of octaves to process */
  51716. octaves: number;
  51717. /** Defines the level of persistence (0.8 by default) */
  51718. persistence: number;
  51719. /** Gets or sets animation speed factor (default is 1) */
  51720. animationSpeedFactor: number;
  51721. /**
  51722. * Creates a new NoiseProceduralTexture
  51723. * @param name defines the name fo the texture
  51724. * @param size defines the size of the texture (default is 256)
  51725. * @param scene defines the hosting scene
  51726. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51727. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51728. */
  51729. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51730. private _updateShaderUniforms;
  51731. protected _getDefines(): string;
  51732. /** Generate the current state of the procedural texture */
  51733. render(useCameraPostProcess?: boolean): void;
  51734. /**
  51735. * Serializes this noise procedural texture
  51736. * @returns a serialized noise procedural texture object
  51737. */
  51738. serialize(): any;
  51739. /**
  51740. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51741. * @param parsedTexture defines parsed texture data
  51742. * @param scene defines the current scene
  51743. * @param rootUrl defines the root URL containing noise procedural texture information
  51744. * @returns a parsed NoiseProceduralTexture
  51745. */
  51746. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51747. }
  51748. }
  51749. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51750. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51751. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51752. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51753. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51754. }
  51755. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51756. import { Nullable } from "babylonjs/types";
  51757. import { Scene } from "babylonjs/scene";
  51758. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51759. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51760. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51761. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51762. /**
  51763. * Raw cube texture where the raw buffers are passed in
  51764. */
  51765. export class RawCubeTexture extends CubeTexture {
  51766. /**
  51767. * Creates a cube texture where the raw buffers are passed in.
  51768. * @param scene defines the scene the texture is attached to
  51769. * @param data defines the array of data to use to create each face
  51770. * @param size defines the size of the textures
  51771. * @param format defines the format of the data
  51772. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51773. * @param generateMipMaps defines if the engine should generate the mip levels
  51774. * @param invertY defines if data must be stored with Y axis inverted
  51775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51776. * @param compression defines the compression used (null by default)
  51777. */
  51778. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51779. /**
  51780. * Updates the raw cube texture.
  51781. * @param data defines the data to store
  51782. * @param format defines the data format
  51783. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51784. * @param invertY defines if data must be stored with Y axis inverted
  51785. * @param compression defines the compression used (null by default)
  51786. * @param level defines which level of the texture to update
  51787. */
  51788. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51789. /**
  51790. * Updates a raw cube texture with RGBD encoded data.
  51791. * @param data defines the array of data [mipmap][face] to use to create each face
  51792. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51793. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51794. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51795. * @returns a promsie that resolves when the operation is complete
  51796. */
  51797. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51798. /**
  51799. * Clones the raw cube texture.
  51800. * @return a new cube texture
  51801. */
  51802. clone(): CubeTexture;
  51803. /** @hidden */
  51804. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51805. }
  51806. }
  51807. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51808. import { Scene } from "babylonjs/scene";
  51809. import { Texture } from "babylonjs/Materials/Textures/texture";
  51810. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51811. /**
  51812. * Class used to store 3D textures containing user data
  51813. */
  51814. export class RawTexture3D extends Texture {
  51815. /** Gets or sets the texture format to use */
  51816. format: number;
  51817. private _engine;
  51818. /**
  51819. * Create a new RawTexture3D
  51820. * @param data defines the data of the texture
  51821. * @param width defines the width of the texture
  51822. * @param height defines the height of the texture
  51823. * @param depth defines the depth of the texture
  51824. * @param format defines the texture format to use
  51825. * @param scene defines the hosting scene
  51826. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51827. * @param invertY defines if texture must be stored with Y axis inverted
  51828. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51829. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51830. */
  51831. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51832. /** Gets or sets the texture format to use */
  51833. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51834. /**
  51835. * Update the texture with new data
  51836. * @param data defines the data to store in the texture
  51837. */
  51838. update(data: ArrayBufferView): void;
  51839. }
  51840. }
  51841. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51842. import { Scene } from "babylonjs/scene";
  51843. import { Plane } from "babylonjs/Maths/math";
  51844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51845. /**
  51846. * Creates a refraction texture used by refraction channel of the standard material.
  51847. * It is like a mirror but to see through a material.
  51848. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51849. */
  51850. export class RefractionTexture extends RenderTargetTexture {
  51851. /**
  51852. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51853. * 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.
  51854. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51855. */
  51856. refractionPlane: Plane;
  51857. /**
  51858. * Define how deep under the surface we should see.
  51859. */
  51860. depth: number;
  51861. /**
  51862. * Creates a refraction texture used by refraction channel of the standard material.
  51863. * It is like a mirror but to see through a material.
  51864. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51865. * @param name Define the texture name
  51866. * @param size Define the size of the underlying texture
  51867. * @param scene Define the scene the refraction belongs to
  51868. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51869. */
  51870. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51871. /**
  51872. * Clone the refraction texture.
  51873. * @returns the cloned texture
  51874. */
  51875. clone(): RefractionTexture;
  51876. /**
  51877. * Serialize the texture to a JSON representation you could use in Parse later on
  51878. * @returns the serialized JSON representation
  51879. */
  51880. serialize(): any;
  51881. }
  51882. }
  51883. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51884. import { Nullable } from "babylonjs/types";
  51885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51886. import { Matrix } from "babylonjs/Maths/math";
  51887. import { Engine } from "babylonjs/Engines/engine";
  51888. import { Scene } from "babylonjs/scene";
  51889. /**
  51890. * Defines the options related to the creation of an HtmlElementTexture
  51891. */
  51892. export interface IHtmlElementTextureOptions {
  51893. /**
  51894. * Defines wether mip maps should be created or not.
  51895. */
  51896. generateMipMaps?: boolean;
  51897. /**
  51898. * Defines the sampling mode of the texture.
  51899. */
  51900. samplingMode?: number;
  51901. /**
  51902. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51903. */
  51904. engine: Nullable<Engine>;
  51905. /**
  51906. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51907. */
  51908. scene: Nullable<Scene>;
  51909. }
  51910. /**
  51911. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51912. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51913. * is automatically managed.
  51914. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51915. * in your application.
  51916. *
  51917. * As the update is not automatic, you need to call them manually.
  51918. */
  51919. export class HtmlElementTexture extends BaseTexture {
  51920. /**
  51921. * The texture URL.
  51922. */
  51923. element: HTMLVideoElement | HTMLCanvasElement;
  51924. private static readonly DefaultOptions;
  51925. private _textureMatrix;
  51926. private _engine;
  51927. private _isVideo;
  51928. private _generateMipMaps;
  51929. private _samplingMode;
  51930. /**
  51931. * Instantiates a HtmlElementTexture from the following parameters.
  51932. *
  51933. * @param name Defines the name of the texture
  51934. * @param element Defines the video or canvas the texture is filled with
  51935. * @param options Defines the other none mandatory texture creation options
  51936. */
  51937. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51938. private _createInternalTexture;
  51939. /**
  51940. * Returns the texture matrix used in most of the material.
  51941. */
  51942. getTextureMatrix(): Matrix;
  51943. /**
  51944. * Updates the content of the texture.
  51945. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51946. */
  51947. update(invertY?: Nullable<boolean>): void;
  51948. }
  51949. }
  51950. declare module "babylonjs/Materials/Textures/index" {
  51951. export * from "babylonjs/Materials/Textures/baseTexture";
  51952. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51953. export * from "babylonjs/Materials/Textures/cubeTexture";
  51954. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51955. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51956. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51957. export * from "babylonjs/Materials/Textures/internalTexture";
  51958. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51959. export * from "babylonjs/Materials/Textures/Loaders/index";
  51960. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51961. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51962. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51963. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51964. export * from "babylonjs/Materials/Textures/rawTexture";
  51965. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51966. export * from "babylonjs/Materials/Textures/refractionTexture";
  51967. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51968. export * from "babylonjs/Materials/Textures/texture";
  51969. export * from "babylonjs/Materials/Textures/videoTexture";
  51970. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51971. }
  51972. declare module "babylonjs/Materials/index" {
  51973. export * from "babylonjs/Materials/Background/index";
  51974. export * from "babylonjs/Materials/colorCurves";
  51975. export * from "babylonjs/Materials/effect";
  51976. export * from "babylonjs/Materials/fresnelParameters";
  51977. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51978. export * from "babylonjs/Materials/material";
  51979. export * from "babylonjs/Materials/materialDefines";
  51980. export * from "babylonjs/Materials/materialHelper";
  51981. export * from "babylonjs/Materials/multiMaterial";
  51982. export * from "babylonjs/Materials/PBR/index";
  51983. export * from "babylonjs/Materials/pushMaterial";
  51984. export * from "babylonjs/Materials/shaderMaterial";
  51985. export * from "babylonjs/Materials/standardMaterial";
  51986. export * from "babylonjs/Materials/Textures/index";
  51987. export * from "babylonjs/Materials/uniformBuffer";
  51988. export * from "babylonjs/Materials/materialFlags";
  51989. }
  51990. declare module "babylonjs/Maths/index" {
  51991. export * from "babylonjs/Maths/math.scalar";
  51992. export * from "babylonjs/Maths/math";
  51993. export * from "babylonjs/Maths/sphericalPolynomial";
  51994. }
  51995. declare module "babylonjs/Misc/workerPool" {
  51996. import { IDisposable } from "babylonjs/scene";
  51997. /**
  51998. * Helper class to push actions to a pool of workers.
  51999. */
  52000. export class WorkerPool implements IDisposable {
  52001. private _workerInfos;
  52002. private _pendingActions;
  52003. /**
  52004. * Constructor
  52005. * @param workers Array of workers to use for actions
  52006. */
  52007. constructor(workers: Array<Worker>);
  52008. /**
  52009. * Terminates all workers and clears any pending actions.
  52010. */
  52011. dispose(): void;
  52012. /**
  52013. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52014. * pended until a worker has completed its action.
  52015. * @param action The action to perform. Call onComplete when the action is complete.
  52016. */
  52017. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52018. private _execute;
  52019. }
  52020. }
  52021. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  52022. import { IDisposable } from "babylonjs/scene";
  52023. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52024. /**
  52025. * Configuration for Draco compression
  52026. */
  52027. export interface IDracoCompressionConfiguration {
  52028. /**
  52029. * Configuration for the decoder.
  52030. */
  52031. decoder: {
  52032. /**
  52033. * The url to the WebAssembly module.
  52034. */
  52035. wasmUrl?: string;
  52036. /**
  52037. * The url to the WebAssembly binary.
  52038. */
  52039. wasmBinaryUrl?: string;
  52040. /**
  52041. * The url to the fallback JavaScript module.
  52042. */
  52043. fallbackUrl?: string;
  52044. };
  52045. }
  52046. /**
  52047. * Draco compression (https://google.github.io/draco/)
  52048. *
  52049. * This class wraps the Draco module.
  52050. *
  52051. * **Encoder**
  52052. *
  52053. * The encoder is not currently implemented.
  52054. *
  52055. * **Decoder**
  52056. *
  52057. * 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.
  52058. *
  52059. * To update the configuration, use the following code:
  52060. * ```javascript
  52061. * DracoCompression.Configuration = {
  52062. * decoder: {
  52063. * wasmUrl: "<url to the WebAssembly library>",
  52064. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52065. * fallbackUrl: "<url to the fallback JavaScript library>",
  52066. * }
  52067. * };
  52068. * ```
  52069. *
  52070. * 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.
  52071. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52072. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52073. *
  52074. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52075. * ```javascript
  52076. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52077. * ```
  52078. *
  52079. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52080. */
  52081. export class DracoCompression implements IDisposable {
  52082. private _workerPoolPromise?;
  52083. private _decoderModulePromise?;
  52084. /**
  52085. * The configuration. Defaults to the following urls:
  52086. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52087. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52088. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52089. */
  52090. static Configuration: IDracoCompressionConfiguration;
  52091. /**
  52092. * Returns true if the decoder configuration is available.
  52093. */
  52094. static readonly DecoderAvailable: boolean;
  52095. /**
  52096. * Default number of workers to create when creating the draco compression object.
  52097. */
  52098. static DefaultNumWorkers: number;
  52099. private static GetDefaultNumWorkers;
  52100. private static _Default;
  52101. /**
  52102. * Default instance for the draco compression object.
  52103. */
  52104. static readonly Default: DracoCompression;
  52105. /**
  52106. * Constructor
  52107. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52108. */
  52109. constructor(numWorkers?: number);
  52110. /**
  52111. * Stop all async operations and release resources.
  52112. */
  52113. dispose(): void;
  52114. /**
  52115. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52116. * @returns a promise that resolves when ready
  52117. */
  52118. whenReadyAsync(): Promise<void>;
  52119. /**
  52120. * Decode Draco compressed mesh data to vertex data.
  52121. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52122. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52123. * @returns A promise that resolves with the decoded vertex data
  52124. */
  52125. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52126. [kind: string]: number;
  52127. }): Promise<VertexData>;
  52128. }
  52129. }
  52130. declare module "babylonjs/Meshes/Compression/index" {
  52131. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52132. }
  52133. declare module "babylonjs/Meshes/csg" {
  52134. import { Nullable } from "babylonjs/types";
  52135. import { Scene } from "babylonjs/scene";
  52136. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52137. import { Mesh } from "babylonjs/Meshes/mesh";
  52138. import { Material } from "babylonjs/Materials/material";
  52139. /**
  52140. * Class for building Constructive Solid Geometry
  52141. */
  52142. export class CSG {
  52143. private polygons;
  52144. /**
  52145. * The world matrix
  52146. */
  52147. matrix: Matrix;
  52148. /**
  52149. * Stores the position
  52150. */
  52151. position: Vector3;
  52152. /**
  52153. * Stores the rotation
  52154. */
  52155. rotation: Vector3;
  52156. /**
  52157. * Stores the rotation quaternion
  52158. */
  52159. rotationQuaternion: Nullable<Quaternion>;
  52160. /**
  52161. * Stores the scaling vector
  52162. */
  52163. scaling: Vector3;
  52164. /**
  52165. * Convert the Mesh to CSG
  52166. * @param mesh The Mesh to convert to CSG
  52167. * @returns A new CSG from the Mesh
  52168. */
  52169. static FromMesh(mesh: Mesh): CSG;
  52170. /**
  52171. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52172. * @param polygons Polygons used to construct a CSG solid
  52173. */
  52174. private static FromPolygons;
  52175. /**
  52176. * Clones, or makes a deep copy, of the CSG
  52177. * @returns A new CSG
  52178. */
  52179. clone(): CSG;
  52180. /**
  52181. * Unions this CSG with another CSG
  52182. * @param csg The CSG to union against this CSG
  52183. * @returns The unioned CSG
  52184. */
  52185. union(csg: CSG): CSG;
  52186. /**
  52187. * Unions this CSG with another CSG in place
  52188. * @param csg The CSG to union against this CSG
  52189. */
  52190. unionInPlace(csg: CSG): void;
  52191. /**
  52192. * Subtracts this CSG with another CSG
  52193. * @param csg The CSG to subtract against this CSG
  52194. * @returns A new CSG
  52195. */
  52196. subtract(csg: CSG): CSG;
  52197. /**
  52198. * Subtracts this CSG with another CSG in place
  52199. * @param csg The CSG to subtact against this CSG
  52200. */
  52201. subtractInPlace(csg: CSG): void;
  52202. /**
  52203. * Intersect this CSG with another CSG
  52204. * @param csg The CSG to intersect against this CSG
  52205. * @returns A new CSG
  52206. */
  52207. intersect(csg: CSG): CSG;
  52208. /**
  52209. * Intersects this CSG with another CSG in place
  52210. * @param csg The CSG to intersect against this CSG
  52211. */
  52212. intersectInPlace(csg: CSG): void;
  52213. /**
  52214. * Return a new CSG solid with solid and empty space switched. This solid is
  52215. * not modified.
  52216. * @returns A new CSG solid with solid and empty space switched
  52217. */
  52218. inverse(): CSG;
  52219. /**
  52220. * Inverses the CSG in place
  52221. */
  52222. inverseInPlace(): void;
  52223. /**
  52224. * This is used to keep meshes transformations so they can be restored
  52225. * when we build back a Babylon Mesh
  52226. * NB : All CSG operations are performed in world coordinates
  52227. * @param csg The CSG to copy the transform attributes from
  52228. * @returns This CSG
  52229. */
  52230. copyTransformAttributes(csg: CSG): CSG;
  52231. /**
  52232. * Build Raw mesh from CSG
  52233. * Coordinates here are in world space
  52234. * @param name The name of the mesh geometry
  52235. * @param scene The Scene
  52236. * @param keepSubMeshes Specifies if the submeshes should be kept
  52237. * @returns A new Mesh
  52238. */
  52239. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52240. /**
  52241. * Build Mesh from CSG taking material and transforms into account
  52242. * @param name The name of the Mesh
  52243. * @param material The material of the Mesh
  52244. * @param scene The Scene
  52245. * @param keepSubMeshes Specifies if submeshes should be kept
  52246. * @returns The new Mesh
  52247. */
  52248. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52249. }
  52250. }
  52251. declare module "babylonjs/Meshes/trailMesh" {
  52252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52253. import { Mesh } from "babylonjs/Meshes/mesh";
  52254. import { Scene } from "babylonjs/scene";
  52255. /**
  52256. * Class used to create a trail following a mesh
  52257. */
  52258. export class TrailMesh extends Mesh {
  52259. private _generator;
  52260. private _autoStart;
  52261. private _running;
  52262. private _diameter;
  52263. private _length;
  52264. private _sectionPolygonPointsCount;
  52265. private _sectionVectors;
  52266. private _sectionNormalVectors;
  52267. private _beforeRenderObserver;
  52268. /**
  52269. * @constructor
  52270. * @param name The value used by scene.getMeshByName() to do a lookup.
  52271. * @param generator The mesh to generate a trail.
  52272. * @param scene The scene to add this mesh to.
  52273. * @param diameter Diameter of trailing mesh. Default is 1.
  52274. * @param length Length of trailing mesh. Default is 60.
  52275. * @param autoStart Automatically start trailing mesh. Default true.
  52276. */
  52277. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52278. /**
  52279. * "TrailMesh"
  52280. * @returns "TrailMesh"
  52281. */
  52282. getClassName(): string;
  52283. private _createMesh;
  52284. /**
  52285. * Start trailing mesh.
  52286. */
  52287. start(): void;
  52288. /**
  52289. * Stop trailing mesh.
  52290. */
  52291. stop(): void;
  52292. /**
  52293. * Update trailing mesh geometry.
  52294. */
  52295. update(): void;
  52296. /**
  52297. * Returns a new TrailMesh object.
  52298. * @param name is a string, the name given to the new mesh
  52299. * @param newGenerator use new generator object for cloned trail mesh
  52300. * @returns a new mesh
  52301. */
  52302. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52303. /**
  52304. * Serializes this trail mesh
  52305. * @param serializationObject object to write serialization to
  52306. */
  52307. serialize(serializationObject: any): void;
  52308. /**
  52309. * Parses a serialized trail mesh
  52310. * @param parsedMesh the serialized mesh
  52311. * @param scene the scene to create the trail mesh in
  52312. * @returns the created trail mesh
  52313. */
  52314. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52315. }
  52316. }
  52317. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52318. import { Vector4 } from "babylonjs/Maths/math";
  52319. import { Mesh } from "babylonjs/Meshes/mesh";
  52320. /**
  52321. * Class containing static functions to help procedurally build meshes
  52322. */
  52323. export class TorusKnotBuilder {
  52324. /**
  52325. * Creates a torus knot mesh
  52326. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52327. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52328. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52329. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52333. * @param name defines the name of the mesh
  52334. * @param options defines the options used to create the mesh
  52335. * @param scene defines the hosting scene
  52336. * @returns the torus knot mesh
  52337. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52338. */
  52339. static CreateTorusKnot(name: string, options: {
  52340. radius?: number;
  52341. tube?: number;
  52342. radialSegments?: number;
  52343. tubularSegments?: number;
  52344. p?: number;
  52345. q?: number;
  52346. updatable?: boolean;
  52347. sideOrientation?: number;
  52348. frontUVs?: Vector4;
  52349. backUVs?: Vector4;
  52350. }, scene: any): Mesh;
  52351. }
  52352. }
  52353. declare module "babylonjs/Meshes/polygonMesh" {
  52354. import { Scene } from "babylonjs/scene";
  52355. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52356. import { Mesh } from "babylonjs/Meshes/mesh";
  52357. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52358. /**
  52359. * Polygon
  52360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52361. */
  52362. export class Polygon {
  52363. /**
  52364. * Creates a rectangle
  52365. * @param xmin bottom X coord
  52366. * @param ymin bottom Y coord
  52367. * @param xmax top X coord
  52368. * @param ymax top Y coord
  52369. * @returns points that make the resulting rectation
  52370. */
  52371. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52372. /**
  52373. * Creates a circle
  52374. * @param radius radius of circle
  52375. * @param cx scale in x
  52376. * @param cy scale in y
  52377. * @param numberOfSides number of sides that make up the circle
  52378. * @returns points that make the resulting circle
  52379. */
  52380. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52381. /**
  52382. * Creates a polygon from input string
  52383. * @param input Input polygon data
  52384. * @returns the parsed points
  52385. */
  52386. static Parse(input: string): Vector2[];
  52387. /**
  52388. * Starts building a polygon from x and y coordinates
  52389. * @param x x coordinate
  52390. * @param y y coordinate
  52391. * @returns the started path2
  52392. */
  52393. static StartingAt(x: number, y: number): Path2;
  52394. }
  52395. /**
  52396. * Builds a polygon
  52397. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52398. */
  52399. export class PolygonMeshBuilder {
  52400. private _points;
  52401. private _outlinepoints;
  52402. private _holes;
  52403. private _name;
  52404. private _scene;
  52405. private _epoints;
  52406. private _eholes;
  52407. private _addToepoint;
  52408. /**
  52409. * Babylon reference to the earcut plugin.
  52410. */
  52411. bjsEarcut: any;
  52412. /**
  52413. * Creates a PolygonMeshBuilder
  52414. * @param name name of the builder
  52415. * @param contours Path of the polygon
  52416. * @param scene scene to add to when creating the mesh
  52417. * @param earcutInjection can be used to inject your own earcut reference
  52418. */
  52419. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52420. /**
  52421. * Adds a whole within the polygon
  52422. * @param hole Array of points defining the hole
  52423. * @returns this
  52424. */
  52425. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52426. /**
  52427. * Creates the polygon
  52428. * @param updatable If the mesh should be updatable
  52429. * @param depth The depth of the mesh created
  52430. * @returns the created mesh
  52431. */
  52432. build(updatable?: boolean, depth?: number): Mesh;
  52433. /**
  52434. * Creates the polygon
  52435. * @param depth The depth of the mesh created
  52436. * @returns the created VertexData
  52437. */
  52438. buildVertexData(depth?: number): VertexData;
  52439. /**
  52440. * Adds a side to the polygon
  52441. * @param positions points that make the polygon
  52442. * @param normals normals of the polygon
  52443. * @param uvs uvs of the polygon
  52444. * @param indices indices of the polygon
  52445. * @param bounds bounds of the polygon
  52446. * @param points points of the polygon
  52447. * @param depth depth of the polygon
  52448. * @param flip flip of the polygon
  52449. */
  52450. private addSide;
  52451. }
  52452. }
  52453. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52454. import { Scene } from "babylonjs/scene";
  52455. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52456. import { Mesh } from "babylonjs/Meshes/mesh";
  52457. import { Nullable } from "babylonjs/types";
  52458. /**
  52459. * Class containing static functions to help procedurally build meshes
  52460. */
  52461. export class PolygonBuilder {
  52462. /**
  52463. * Creates a polygon mesh
  52464. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52465. * * 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
  52466. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52469. * * Remember you can only change the shape positions, not their number when updating a polygon
  52470. * @param name defines the name of the mesh
  52471. * @param options defines the options used to create the mesh
  52472. * @param scene defines the hosting scene
  52473. * @param earcutInjection can be used to inject your own earcut reference
  52474. * @returns the polygon mesh
  52475. */
  52476. static CreatePolygon(name: string, options: {
  52477. shape: Vector3[];
  52478. holes?: Vector3[][];
  52479. depth?: number;
  52480. faceUV?: Vector4[];
  52481. faceColors?: Color4[];
  52482. updatable?: boolean;
  52483. sideOrientation?: number;
  52484. frontUVs?: Vector4;
  52485. backUVs?: Vector4;
  52486. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52487. /**
  52488. * Creates an extruded polygon mesh, with depth in the Y direction.
  52489. * * 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)
  52490. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52491. * @param name defines the name of the mesh
  52492. * @param options defines the options used to create the mesh
  52493. * @param scene defines the hosting scene
  52494. * @param earcutInjection can be used to inject your own earcut reference
  52495. * @returns the polygon mesh
  52496. */
  52497. static ExtrudePolygon(name: string, options: {
  52498. shape: Vector3[];
  52499. holes?: Vector3[][];
  52500. depth?: number;
  52501. faceUV?: Vector4[];
  52502. faceColors?: Color4[];
  52503. updatable?: boolean;
  52504. sideOrientation?: number;
  52505. frontUVs?: Vector4;
  52506. backUVs?: Vector4;
  52507. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52508. }
  52509. }
  52510. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52511. import { Scene } from "babylonjs/scene";
  52512. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52513. import { Mesh } from "babylonjs/Meshes/mesh";
  52514. import { Nullable } from "babylonjs/types";
  52515. /**
  52516. * Class containing static functions to help procedurally build meshes
  52517. */
  52518. export class LatheBuilder {
  52519. /**
  52520. * Creates lathe mesh.
  52521. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52522. * * 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
  52523. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52524. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52525. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52526. * * 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
  52527. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52528. * * 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
  52529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52531. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52533. * @param name defines the name of the mesh
  52534. * @param options defines the options used to create the mesh
  52535. * @param scene defines the hosting scene
  52536. * @returns the lathe mesh
  52537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52538. */
  52539. static CreateLathe(name: string, options: {
  52540. shape: Vector3[];
  52541. radius?: number;
  52542. tessellation?: number;
  52543. clip?: number;
  52544. arc?: number;
  52545. closed?: boolean;
  52546. updatable?: boolean;
  52547. sideOrientation?: number;
  52548. frontUVs?: Vector4;
  52549. backUVs?: Vector4;
  52550. cap?: number;
  52551. invertUV?: boolean;
  52552. }, scene?: Nullable<Scene>): Mesh;
  52553. }
  52554. }
  52555. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52556. import { Nullable } from "babylonjs/types";
  52557. import { Scene } from "babylonjs/scene";
  52558. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52559. import { Mesh } from "babylonjs/Meshes/mesh";
  52560. /**
  52561. * Class containing static functions to help procedurally build meshes
  52562. */
  52563. export class TubeBuilder {
  52564. /**
  52565. * Creates a tube mesh.
  52566. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52567. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52568. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52569. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52570. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52571. * * 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)
  52572. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52573. * * 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
  52574. * * 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
  52575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52579. * @param name defines the name of the mesh
  52580. * @param options defines the options used to create the mesh
  52581. * @param scene defines the hosting scene
  52582. * @returns the tube mesh
  52583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52584. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52585. */
  52586. static CreateTube(name: string, options: {
  52587. path: Vector3[];
  52588. radius?: number;
  52589. tessellation?: number;
  52590. radiusFunction?: {
  52591. (i: number, distance: number): number;
  52592. };
  52593. cap?: number;
  52594. arc?: number;
  52595. updatable?: boolean;
  52596. sideOrientation?: number;
  52597. frontUVs?: Vector4;
  52598. backUVs?: Vector4;
  52599. instance?: Mesh;
  52600. invertUV?: boolean;
  52601. }, scene?: Nullable<Scene>): Mesh;
  52602. }
  52603. }
  52604. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52605. import { Scene } from "babylonjs/scene";
  52606. import { Vector4 } from "babylonjs/Maths/math";
  52607. import { Mesh } from "babylonjs/Meshes/mesh";
  52608. import { Nullable } from "babylonjs/types";
  52609. /**
  52610. * Class containing static functions to help procedurally build meshes
  52611. */
  52612. export class IcoSphereBuilder {
  52613. /**
  52614. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52615. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52616. * * 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`)
  52617. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52618. * * 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
  52619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52622. * @param name defines the name of the mesh
  52623. * @param options defines the options used to create the mesh
  52624. * @param scene defines the hosting scene
  52625. * @returns the icosahedron mesh
  52626. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52627. */
  52628. static CreateIcoSphere(name: string, options: {
  52629. radius?: number;
  52630. radiusX?: number;
  52631. radiusY?: number;
  52632. radiusZ?: number;
  52633. flat?: boolean;
  52634. subdivisions?: number;
  52635. sideOrientation?: number;
  52636. frontUVs?: Vector4;
  52637. backUVs?: Vector4;
  52638. updatable?: boolean;
  52639. }, scene?: Nullable<Scene>): Mesh;
  52640. }
  52641. }
  52642. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52643. import { Vector3 } from "babylonjs/Maths/math";
  52644. import { Mesh } from "babylonjs/Meshes/mesh";
  52645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52646. /**
  52647. * Class containing static functions to help procedurally build meshes
  52648. */
  52649. export class DecalBuilder {
  52650. /**
  52651. * Creates a decal mesh.
  52652. * 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
  52653. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52654. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52655. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52656. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52657. * @param name defines the name of the mesh
  52658. * @param sourceMesh defines the mesh where the decal must be applied
  52659. * @param options defines the options used to create the mesh
  52660. * @param scene defines the hosting scene
  52661. * @returns the decal mesh
  52662. * @see https://doc.babylonjs.com/how_to/decals
  52663. */
  52664. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52665. position?: Vector3;
  52666. normal?: Vector3;
  52667. size?: Vector3;
  52668. angle?: number;
  52669. }): Mesh;
  52670. }
  52671. }
  52672. declare module "babylonjs/Meshes/meshBuilder" {
  52673. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52674. import { Nullable } from "babylonjs/types";
  52675. import { Scene } from "babylonjs/scene";
  52676. import { Mesh } from "babylonjs/Meshes/mesh";
  52677. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52678. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52680. /**
  52681. * Class containing static functions to help procedurally build meshes
  52682. */
  52683. export class MeshBuilder {
  52684. /**
  52685. * Creates a box mesh
  52686. * * The parameter `size` sets the size (float) of each box side (default 1)
  52687. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52688. * * 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)
  52689. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52693. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52694. * @param name defines the name of the mesh
  52695. * @param options defines the options used to create the mesh
  52696. * @param scene defines the hosting scene
  52697. * @returns the box mesh
  52698. */
  52699. static CreateBox(name: string, options: {
  52700. size?: number;
  52701. width?: number;
  52702. height?: number;
  52703. depth?: number;
  52704. faceUV?: Vector4[];
  52705. faceColors?: Color4[];
  52706. sideOrientation?: number;
  52707. frontUVs?: Vector4;
  52708. backUVs?: Vector4;
  52709. updatable?: boolean;
  52710. }, scene?: Nullable<Scene>): Mesh;
  52711. /**
  52712. * Creates a sphere mesh
  52713. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52714. * * 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`)
  52715. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52716. * * 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
  52717. * * 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)
  52718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52721. * @param name defines the name of the mesh
  52722. * @param options defines the options used to create the mesh
  52723. * @param scene defines the hosting scene
  52724. * @returns the sphere mesh
  52725. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52726. */
  52727. static CreateSphere(name: string, options: {
  52728. segments?: number;
  52729. diameter?: number;
  52730. diameterX?: number;
  52731. diameterY?: number;
  52732. diameterZ?: number;
  52733. arc?: number;
  52734. slice?: number;
  52735. sideOrientation?: number;
  52736. frontUVs?: Vector4;
  52737. backUVs?: Vector4;
  52738. updatable?: boolean;
  52739. }, scene?: Nullable<Scene>): Mesh;
  52740. /**
  52741. * Creates a plane polygonal mesh. By default, this is a disc
  52742. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52743. * * 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
  52744. * * 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
  52745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52748. * @param name defines the name of the mesh
  52749. * @param options defines the options used to create the mesh
  52750. * @param scene defines the hosting scene
  52751. * @returns the plane polygonal mesh
  52752. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52753. */
  52754. static CreateDisc(name: string, options: {
  52755. radius?: number;
  52756. tessellation?: number;
  52757. arc?: number;
  52758. updatable?: boolean;
  52759. sideOrientation?: number;
  52760. frontUVs?: Vector4;
  52761. backUVs?: Vector4;
  52762. }, scene?: Nullable<Scene>): Mesh;
  52763. /**
  52764. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52765. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52766. * * 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`)
  52767. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52768. * * 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
  52769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52772. * @param name defines the name of the mesh
  52773. * @param options defines the options used to create the mesh
  52774. * @param scene defines the hosting scene
  52775. * @returns the icosahedron mesh
  52776. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52777. */
  52778. static CreateIcoSphere(name: string, options: {
  52779. radius?: number;
  52780. radiusX?: number;
  52781. radiusY?: number;
  52782. radiusZ?: number;
  52783. flat?: boolean;
  52784. subdivisions?: number;
  52785. sideOrientation?: number;
  52786. frontUVs?: Vector4;
  52787. backUVs?: Vector4;
  52788. updatable?: boolean;
  52789. }, scene?: Nullable<Scene>): Mesh;
  52790. /**
  52791. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52792. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52793. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52794. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52795. * * 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
  52796. * * 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
  52797. * * 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
  52798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52800. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52801. * * 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
  52802. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52803. * * 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
  52804. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52806. * @param name defines the name of the mesh
  52807. * @param options defines the options used to create the mesh
  52808. * @param scene defines the hosting scene
  52809. * @returns the ribbon mesh
  52810. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52811. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52812. */
  52813. static CreateRibbon(name: string, options: {
  52814. pathArray: Vector3[][];
  52815. closeArray?: boolean;
  52816. closePath?: boolean;
  52817. offset?: number;
  52818. updatable?: boolean;
  52819. sideOrientation?: number;
  52820. frontUVs?: Vector4;
  52821. backUVs?: Vector4;
  52822. instance?: Mesh;
  52823. invertUV?: boolean;
  52824. uvs?: Vector2[];
  52825. colors?: Color4[];
  52826. }, scene?: Nullable<Scene>): Mesh;
  52827. /**
  52828. * Creates a cylinder or a cone mesh
  52829. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52830. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52831. * * 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.
  52832. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52833. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52834. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52835. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52836. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52837. * * 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).
  52838. * * 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
  52839. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52840. * * 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
  52841. * * 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.
  52842. * * If `enclose` is false, a ring surface is one element.
  52843. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52844. * * 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
  52845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52848. * @param name defines the name of the mesh
  52849. * @param options defines the options used to create the mesh
  52850. * @param scene defines the hosting scene
  52851. * @returns the cylinder mesh
  52852. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52853. */
  52854. static CreateCylinder(name: string, options: {
  52855. height?: number;
  52856. diameterTop?: number;
  52857. diameterBottom?: number;
  52858. diameter?: number;
  52859. tessellation?: number;
  52860. subdivisions?: number;
  52861. arc?: number;
  52862. faceColors?: Color4[];
  52863. faceUV?: Vector4[];
  52864. updatable?: boolean;
  52865. hasRings?: boolean;
  52866. enclose?: boolean;
  52867. sideOrientation?: number;
  52868. frontUVs?: Vector4;
  52869. backUVs?: Vector4;
  52870. }, scene?: Nullable<Scene>): Mesh;
  52871. /**
  52872. * Creates a torus mesh
  52873. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52874. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52875. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52877. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52879. * @param name defines the name of the mesh
  52880. * @param options defines the options used to create the mesh
  52881. * @param scene defines the hosting scene
  52882. * @returns the torus mesh
  52883. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52884. */
  52885. static CreateTorus(name: string, options: {
  52886. diameter?: number;
  52887. thickness?: number;
  52888. tessellation?: number;
  52889. updatable?: boolean;
  52890. sideOrientation?: number;
  52891. frontUVs?: Vector4;
  52892. backUVs?: Vector4;
  52893. }, scene?: Nullable<Scene>): Mesh;
  52894. /**
  52895. * Creates a torus knot mesh
  52896. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52897. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52898. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52899. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52903. * @param name defines the name of the mesh
  52904. * @param options defines the options used to create the mesh
  52905. * @param scene defines the hosting scene
  52906. * @returns the torus knot mesh
  52907. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52908. */
  52909. static CreateTorusKnot(name: string, options: {
  52910. radius?: number;
  52911. tube?: number;
  52912. radialSegments?: number;
  52913. tubularSegments?: number;
  52914. p?: number;
  52915. q?: number;
  52916. updatable?: boolean;
  52917. sideOrientation?: number;
  52918. frontUVs?: Vector4;
  52919. backUVs?: Vector4;
  52920. }, scene?: Nullable<Scene>): Mesh;
  52921. /**
  52922. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52923. * * 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
  52924. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52925. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52926. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52927. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52928. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52929. * * 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
  52930. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52933. * @param name defines the name of the new line system
  52934. * @param options defines the options used to create the line system
  52935. * @param scene defines the hosting scene
  52936. * @returns a new line system mesh
  52937. */
  52938. static CreateLineSystem(name: string, options: {
  52939. lines: Vector3[][];
  52940. updatable?: boolean;
  52941. instance?: Nullable<LinesMesh>;
  52942. colors?: Nullable<Color4[][]>;
  52943. useVertexAlpha?: boolean;
  52944. }, scene: Nullable<Scene>): LinesMesh;
  52945. /**
  52946. * Creates a line mesh
  52947. * 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
  52948. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52949. * * The parameter `points` is an array successive Vector3
  52950. * * 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
  52951. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52952. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52953. * * When updating an instance, remember that only point positions can change, not the number of points
  52954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52956. * @param name defines the name of the new line system
  52957. * @param options defines the options used to create the line system
  52958. * @param scene defines the hosting scene
  52959. * @returns a new line mesh
  52960. */
  52961. static CreateLines(name: string, options: {
  52962. points: Vector3[];
  52963. updatable?: boolean;
  52964. instance?: Nullable<LinesMesh>;
  52965. colors?: Color4[];
  52966. useVertexAlpha?: boolean;
  52967. }, scene?: Nullable<Scene>): LinesMesh;
  52968. /**
  52969. * Creates a dashed line mesh
  52970. * * 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
  52971. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52972. * * The parameter `points` is an array successive Vector3
  52973. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52974. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52975. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52976. * * 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
  52977. * * When updating an instance, remember that only point positions can change, not the number of points
  52978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52979. * @param name defines the name of the mesh
  52980. * @param options defines the options used to create the mesh
  52981. * @param scene defines the hosting scene
  52982. * @returns the dashed line mesh
  52983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52984. */
  52985. static CreateDashedLines(name: string, options: {
  52986. points: Vector3[];
  52987. dashSize?: number;
  52988. gapSize?: number;
  52989. dashNb?: number;
  52990. updatable?: boolean;
  52991. instance?: LinesMesh;
  52992. }, scene?: Nullable<Scene>): LinesMesh;
  52993. /**
  52994. * 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.
  52995. * * 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.
  52996. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52997. * * 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.
  52998. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52999. * * 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
  53000. * * 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
  53001. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53004. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53006. * @param name defines the name of the mesh
  53007. * @param options defines the options used to create the mesh
  53008. * @param scene defines the hosting scene
  53009. * @returns the extruded shape mesh
  53010. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53012. */
  53013. static ExtrudeShape(name: string, options: {
  53014. shape: Vector3[];
  53015. path: Vector3[];
  53016. scale?: number;
  53017. rotation?: number;
  53018. cap?: number;
  53019. updatable?: boolean;
  53020. sideOrientation?: number;
  53021. frontUVs?: Vector4;
  53022. backUVs?: Vector4;
  53023. instance?: Mesh;
  53024. invertUV?: boolean;
  53025. }, scene?: Nullable<Scene>): Mesh;
  53026. /**
  53027. * Creates an custom extruded shape mesh.
  53028. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53029. * * 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.
  53030. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53031. * * 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
  53032. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53033. * * 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
  53034. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53035. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53036. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53037. * * 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
  53038. * * 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
  53039. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53042. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53044. * @param name defines the name of the mesh
  53045. * @param options defines the options used to create the mesh
  53046. * @param scene defines the hosting scene
  53047. * @returns the custom extruded shape mesh
  53048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53049. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53051. */
  53052. static ExtrudeShapeCustom(name: string, options: {
  53053. shape: Vector3[];
  53054. path: Vector3[];
  53055. scaleFunction?: any;
  53056. rotationFunction?: any;
  53057. ribbonCloseArray?: boolean;
  53058. ribbonClosePath?: boolean;
  53059. cap?: number;
  53060. updatable?: boolean;
  53061. sideOrientation?: number;
  53062. frontUVs?: Vector4;
  53063. backUVs?: Vector4;
  53064. instance?: Mesh;
  53065. invertUV?: boolean;
  53066. }, scene?: Nullable<Scene>): Mesh;
  53067. /**
  53068. * Creates lathe mesh.
  53069. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53070. * * 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
  53071. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53072. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53073. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53074. * * 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
  53075. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53076. * * 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
  53077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53079. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53081. * @param name defines the name of the mesh
  53082. * @param options defines the options used to create the mesh
  53083. * @param scene defines the hosting scene
  53084. * @returns the lathe mesh
  53085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53086. */
  53087. static CreateLathe(name: string, options: {
  53088. shape: Vector3[];
  53089. radius?: number;
  53090. tessellation?: number;
  53091. clip?: number;
  53092. arc?: number;
  53093. closed?: boolean;
  53094. updatable?: boolean;
  53095. sideOrientation?: number;
  53096. frontUVs?: Vector4;
  53097. backUVs?: Vector4;
  53098. cap?: number;
  53099. invertUV?: boolean;
  53100. }, scene?: Nullable<Scene>): Mesh;
  53101. /**
  53102. * Creates a plane mesh
  53103. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53104. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53105. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53109. * @param name defines the name of the mesh
  53110. * @param options defines the options used to create the mesh
  53111. * @param scene defines the hosting scene
  53112. * @returns the plane mesh
  53113. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53114. */
  53115. static CreatePlane(name: string, options: {
  53116. size?: number;
  53117. width?: number;
  53118. height?: number;
  53119. sideOrientation?: number;
  53120. frontUVs?: Vector4;
  53121. backUVs?: Vector4;
  53122. updatable?: boolean;
  53123. sourcePlane?: Plane;
  53124. }, scene?: Nullable<Scene>): Mesh;
  53125. /**
  53126. * Creates a ground mesh
  53127. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53128. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53130. * @param name defines the name of the mesh
  53131. * @param options defines the options used to create the mesh
  53132. * @param scene defines the hosting scene
  53133. * @returns the ground mesh
  53134. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53135. */
  53136. static CreateGround(name: string, options: {
  53137. width?: number;
  53138. height?: number;
  53139. subdivisions?: number;
  53140. subdivisionsX?: number;
  53141. subdivisionsY?: number;
  53142. updatable?: boolean;
  53143. }, scene?: Nullable<Scene>): Mesh;
  53144. /**
  53145. * Creates a tiled ground mesh
  53146. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53147. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53148. * * 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
  53149. * * 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
  53150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53151. * @param name defines the name of the mesh
  53152. * @param options defines the options used to create the mesh
  53153. * @param scene defines the hosting scene
  53154. * @returns the tiled ground mesh
  53155. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53156. */
  53157. static CreateTiledGround(name: string, options: {
  53158. xmin: number;
  53159. zmin: number;
  53160. xmax: number;
  53161. zmax: number;
  53162. subdivisions?: {
  53163. w: number;
  53164. h: number;
  53165. };
  53166. precision?: {
  53167. w: number;
  53168. h: number;
  53169. };
  53170. updatable?: boolean;
  53171. }, scene?: Nullable<Scene>): Mesh;
  53172. /**
  53173. * Creates a ground mesh from a height map
  53174. * * The parameter `url` sets the URL of the height map image resource.
  53175. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53176. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53177. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53178. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53179. * * 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.
  53180. * * 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).
  53181. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53183. * @param name defines the name of the mesh
  53184. * @param url defines the url to the height map
  53185. * @param options defines the options used to create the mesh
  53186. * @param scene defines the hosting scene
  53187. * @returns the ground mesh
  53188. * @see https://doc.babylonjs.com/babylon101/height_map
  53189. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53190. */
  53191. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53192. width?: number;
  53193. height?: number;
  53194. subdivisions?: number;
  53195. minHeight?: number;
  53196. maxHeight?: number;
  53197. colorFilter?: Color3;
  53198. alphaFilter?: number;
  53199. updatable?: boolean;
  53200. onReady?: (mesh: GroundMesh) => void;
  53201. }, scene?: Nullable<Scene>): GroundMesh;
  53202. /**
  53203. * Creates a polygon mesh
  53204. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53205. * * 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
  53206. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53209. * * Remember you can only change the shape positions, not their number when updating a polygon
  53210. * @param name defines the name of the mesh
  53211. * @param options defines the options used to create the mesh
  53212. * @param scene defines the hosting scene
  53213. * @param earcutInjection can be used to inject your own earcut reference
  53214. * @returns the polygon mesh
  53215. */
  53216. static CreatePolygon(name: string, options: {
  53217. shape: Vector3[];
  53218. holes?: Vector3[][];
  53219. depth?: number;
  53220. faceUV?: Vector4[];
  53221. faceColors?: Color4[];
  53222. updatable?: boolean;
  53223. sideOrientation?: number;
  53224. frontUVs?: Vector4;
  53225. backUVs?: Vector4;
  53226. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53227. /**
  53228. * Creates an extruded polygon mesh, with depth in the Y direction.
  53229. * * 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)
  53230. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53231. * @param name defines the name of the mesh
  53232. * @param options defines the options used to create the mesh
  53233. * @param scene defines the hosting scene
  53234. * @param earcutInjection can be used to inject your own earcut reference
  53235. * @returns the polygon mesh
  53236. */
  53237. static ExtrudePolygon(name: string, options: {
  53238. shape: Vector3[];
  53239. holes?: Vector3[][];
  53240. depth?: number;
  53241. faceUV?: Vector4[];
  53242. faceColors?: Color4[];
  53243. updatable?: boolean;
  53244. sideOrientation?: number;
  53245. frontUVs?: Vector4;
  53246. backUVs?: Vector4;
  53247. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53248. /**
  53249. * Creates a tube mesh.
  53250. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53251. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53252. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53253. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53254. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53255. * * 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)
  53256. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53257. * * 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
  53258. * * 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
  53259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53261. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53263. * @param name defines the name of the mesh
  53264. * @param options defines the options used to create the mesh
  53265. * @param scene defines the hosting scene
  53266. * @returns the tube mesh
  53267. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53268. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53269. */
  53270. static CreateTube(name: string, options: {
  53271. path: Vector3[];
  53272. radius?: number;
  53273. tessellation?: number;
  53274. radiusFunction?: {
  53275. (i: number, distance: number): number;
  53276. };
  53277. cap?: number;
  53278. arc?: number;
  53279. updatable?: boolean;
  53280. sideOrientation?: number;
  53281. frontUVs?: Vector4;
  53282. backUVs?: Vector4;
  53283. instance?: Mesh;
  53284. invertUV?: boolean;
  53285. }, scene?: Nullable<Scene>): Mesh;
  53286. /**
  53287. * Creates a polyhedron mesh
  53288. * * 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
  53289. * * The parameter `size` (positive float, default 1) sets the polygon size
  53290. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53291. * * 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`
  53292. * * 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
  53293. * * 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)`)
  53294. * * 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
  53295. * * 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
  53296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53299. * @param name defines the name of the mesh
  53300. * @param options defines the options used to create the mesh
  53301. * @param scene defines the hosting scene
  53302. * @returns the polyhedron mesh
  53303. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53304. */
  53305. static CreatePolyhedron(name: string, options: {
  53306. type?: number;
  53307. size?: number;
  53308. sizeX?: number;
  53309. sizeY?: number;
  53310. sizeZ?: number;
  53311. custom?: any;
  53312. faceUV?: Vector4[];
  53313. faceColors?: Color4[];
  53314. flat?: boolean;
  53315. updatable?: boolean;
  53316. sideOrientation?: number;
  53317. frontUVs?: Vector4;
  53318. backUVs?: Vector4;
  53319. }, scene?: Nullable<Scene>): Mesh;
  53320. /**
  53321. * Creates a decal mesh.
  53322. * 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
  53323. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53324. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53325. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53326. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53327. * @param name defines the name of the mesh
  53328. * @param sourceMesh defines the mesh where the decal must be applied
  53329. * @param options defines the options used to create the mesh
  53330. * @param scene defines the hosting scene
  53331. * @returns the decal mesh
  53332. * @see https://doc.babylonjs.com/how_to/decals
  53333. */
  53334. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53335. position?: Vector3;
  53336. normal?: Vector3;
  53337. size?: Vector3;
  53338. angle?: number;
  53339. }): Mesh;
  53340. }
  53341. }
  53342. declare module "babylonjs/Meshes/meshSimplification" {
  53343. import { Mesh } from "babylonjs/Meshes/mesh";
  53344. /**
  53345. * A simplifier interface for future simplification implementations
  53346. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53347. */
  53348. export interface ISimplifier {
  53349. /**
  53350. * Simplification of a given mesh according to the given settings.
  53351. * Since this requires computation, it is assumed that the function runs async.
  53352. * @param settings The settings of the simplification, including quality and distance
  53353. * @param successCallback A callback that will be called after the mesh was simplified.
  53354. * @param errorCallback in case of an error, this callback will be called. optional.
  53355. */
  53356. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53357. }
  53358. /**
  53359. * Expected simplification settings.
  53360. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53361. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53362. */
  53363. export interface ISimplificationSettings {
  53364. /**
  53365. * Gets or sets the expected quality
  53366. */
  53367. quality: number;
  53368. /**
  53369. * Gets or sets the distance when this optimized version should be used
  53370. */
  53371. distance: number;
  53372. /**
  53373. * Gets an already optimized mesh
  53374. */
  53375. optimizeMesh?: boolean;
  53376. }
  53377. /**
  53378. * Class used to specify simplification options
  53379. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53380. */
  53381. export class SimplificationSettings implements ISimplificationSettings {
  53382. /** expected quality */
  53383. quality: number;
  53384. /** distance when this optimized version should be used */
  53385. distance: number;
  53386. /** already optimized mesh */
  53387. optimizeMesh?: boolean | undefined;
  53388. /**
  53389. * Creates a SimplificationSettings
  53390. * @param quality expected quality
  53391. * @param distance distance when this optimized version should be used
  53392. * @param optimizeMesh already optimized mesh
  53393. */
  53394. constructor(
  53395. /** expected quality */
  53396. quality: number,
  53397. /** distance when this optimized version should be used */
  53398. distance: number,
  53399. /** already optimized mesh */
  53400. optimizeMesh?: boolean | undefined);
  53401. }
  53402. /**
  53403. * Interface used to define a simplification task
  53404. */
  53405. export interface ISimplificationTask {
  53406. /**
  53407. * Array of settings
  53408. */
  53409. settings: Array<ISimplificationSettings>;
  53410. /**
  53411. * Simplification type
  53412. */
  53413. simplificationType: SimplificationType;
  53414. /**
  53415. * Mesh to simplify
  53416. */
  53417. mesh: Mesh;
  53418. /**
  53419. * Callback called on success
  53420. */
  53421. successCallback?: () => void;
  53422. /**
  53423. * Defines if parallel processing can be used
  53424. */
  53425. parallelProcessing: boolean;
  53426. }
  53427. /**
  53428. * Queue used to order the simplification tasks
  53429. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53430. */
  53431. export class SimplificationQueue {
  53432. private _simplificationArray;
  53433. /**
  53434. * Gets a boolean indicating that the process is still running
  53435. */
  53436. running: boolean;
  53437. /**
  53438. * Creates a new queue
  53439. */
  53440. constructor();
  53441. /**
  53442. * Adds a new simplification task
  53443. * @param task defines a task to add
  53444. */
  53445. addTask(task: ISimplificationTask): void;
  53446. /**
  53447. * Execute next task
  53448. */
  53449. executeNext(): void;
  53450. /**
  53451. * Execute a simplification task
  53452. * @param task defines the task to run
  53453. */
  53454. runSimplification(task: ISimplificationTask): void;
  53455. private getSimplifier;
  53456. }
  53457. /**
  53458. * The implemented types of simplification
  53459. * At the moment only Quadratic Error Decimation is implemented
  53460. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53461. */
  53462. export enum SimplificationType {
  53463. /** Quadratic error decimation */
  53464. QUADRATIC = 0
  53465. }
  53466. }
  53467. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53468. import { Scene } from "babylonjs/scene";
  53469. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53470. import { ISceneComponent } from "babylonjs/sceneComponent";
  53471. module "babylonjs/scene" {
  53472. interface Scene {
  53473. /** @hidden (Backing field) */
  53474. _simplificationQueue: SimplificationQueue;
  53475. /**
  53476. * Gets or sets the simplification queue attached to the scene
  53477. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53478. */
  53479. simplificationQueue: SimplificationQueue;
  53480. }
  53481. }
  53482. module "babylonjs/Meshes/mesh" {
  53483. interface Mesh {
  53484. /**
  53485. * Simplify the mesh according to the given array of settings.
  53486. * Function will return immediately and will simplify async
  53487. * @param settings a collection of simplification settings
  53488. * @param parallelProcessing should all levels calculate parallel or one after the other
  53489. * @param simplificationType the type of simplification to run
  53490. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53491. * @returns the current mesh
  53492. */
  53493. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53494. }
  53495. }
  53496. /**
  53497. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53498. * created in a scene
  53499. */
  53500. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53501. /**
  53502. * The component name helpfull to identify the component in the list of scene components.
  53503. */
  53504. readonly name: string;
  53505. /**
  53506. * The scene the component belongs to.
  53507. */
  53508. scene: Scene;
  53509. /**
  53510. * Creates a new instance of the component for the given scene
  53511. * @param scene Defines the scene to register the component in
  53512. */
  53513. constructor(scene: Scene);
  53514. /**
  53515. * Registers the component in a given scene
  53516. */
  53517. register(): void;
  53518. /**
  53519. * Rebuilds the elements related to this component in case of
  53520. * context lost for instance.
  53521. */
  53522. rebuild(): void;
  53523. /**
  53524. * Disposes the component and the associated ressources
  53525. */
  53526. dispose(): void;
  53527. private _beforeCameraUpdate;
  53528. }
  53529. }
  53530. declare module "babylonjs/Meshes/Builders/index" {
  53531. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53532. export * from "babylonjs/Meshes/Builders/discBuilder";
  53533. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53534. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53535. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53536. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53537. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53538. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53539. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53540. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53541. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53542. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53543. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53544. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53545. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53546. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53547. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53548. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53549. }
  53550. declare module "babylonjs/Meshes/index" {
  53551. export * from "babylonjs/Meshes/abstractMesh";
  53552. export * from "babylonjs/Meshes/buffer";
  53553. export * from "babylonjs/Meshes/Compression/index";
  53554. export * from "babylonjs/Meshes/csg";
  53555. export * from "babylonjs/Meshes/geometry";
  53556. export * from "babylonjs/Meshes/groundMesh";
  53557. export * from "babylonjs/Meshes/trailMesh";
  53558. export * from "babylonjs/Meshes/instancedMesh";
  53559. export * from "babylonjs/Meshes/linesMesh";
  53560. export * from "babylonjs/Meshes/mesh";
  53561. export * from "babylonjs/Meshes/mesh.vertexData";
  53562. export * from "babylonjs/Meshes/meshBuilder";
  53563. export * from "babylonjs/Meshes/meshSimplification";
  53564. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53565. export * from "babylonjs/Meshes/polygonMesh";
  53566. export * from "babylonjs/Meshes/subMesh";
  53567. export * from "babylonjs/Meshes/meshLODLevel";
  53568. export * from "babylonjs/Meshes/transformNode";
  53569. export * from "babylonjs/Meshes/Builders/index";
  53570. export * from "babylonjs/Meshes/dataBuffer";
  53571. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53572. }
  53573. declare module "babylonjs/Morph/index" {
  53574. export * from "babylonjs/Morph/morphTarget";
  53575. export * from "babylonjs/Morph/morphTargetManager";
  53576. }
  53577. declare module "babylonjs/Offline/database" {
  53578. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53579. /**
  53580. * Class used to enable access to IndexedDB
  53581. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53582. */
  53583. export class Database implements IOfflineProvider {
  53584. private _callbackManifestChecked;
  53585. private _currentSceneUrl;
  53586. private _db;
  53587. private _enableSceneOffline;
  53588. private _enableTexturesOffline;
  53589. private _manifestVersionFound;
  53590. private _mustUpdateRessources;
  53591. private _hasReachedQuota;
  53592. private _isSupported;
  53593. private _idbFactory;
  53594. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53595. private static IsUASupportingBlobStorage;
  53596. /**
  53597. * Gets a boolean indicating if Database storate is enabled (off by default)
  53598. */
  53599. static IDBStorageEnabled: boolean;
  53600. /**
  53601. * Gets a boolean indicating if scene must be saved in the database
  53602. */
  53603. readonly enableSceneOffline: boolean;
  53604. /**
  53605. * Gets a boolean indicating if textures must be saved in the database
  53606. */
  53607. readonly enableTexturesOffline: boolean;
  53608. /**
  53609. * Creates a new Database
  53610. * @param urlToScene defines the url to load the scene
  53611. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53612. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53613. */
  53614. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53615. private static _ParseURL;
  53616. private static _ReturnFullUrlLocation;
  53617. private _checkManifestFile;
  53618. /**
  53619. * Open the database and make it available
  53620. * @param successCallback defines the callback to call on success
  53621. * @param errorCallback defines the callback to call on error
  53622. */
  53623. open(successCallback: () => void, errorCallback: () => void): void;
  53624. /**
  53625. * Loads an image from the database
  53626. * @param url defines the url to load from
  53627. * @param image defines the target DOM image
  53628. */
  53629. loadImage(url: string, image: HTMLImageElement): void;
  53630. private _loadImageFromDBAsync;
  53631. private _saveImageIntoDBAsync;
  53632. private _checkVersionFromDB;
  53633. private _loadVersionFromDBAsync;
  53634. private _saveVersionIntoDBAsync;
  53635. /**
  53636. * Loads a file from database
  53637. * @param url defines the URL to load from
  53638. * @param sceneLoaded defines a callback to call on success
  53639. * @param progressCallBack defines a callback to call when progress changed
  53640. * @param errorCallback defines a callback to call on error
  53641. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53642. */
  53643. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53644. private _loadFileAsync;
  53645. private _saveFileAsync;
  53646. /**
  53647. * Validates if xhr data is correct
  53648. * @param xhr defines the request to validate
  53649. * @param dataType defines the expected data type
  53650. * @returns true if data is correct
  53651. */
  53652. private static _ValidateXHRData;
  53653. }
  53654. }
  53655. declare module "babylonjs/Offline/index" {
  53656. export * from "babylonjs/Offline/database";
  53657. export * from "babylonjs/Offline/IOfflineProvider";
  53658. }
  53659. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53660. /** @hidden */
  53661. export var gpuUpdateParticlesPixelShader: {
  53662. name: string;
  53663. shader: string;
  53664. };
  53665. }
  53666. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53667. /** @hidden */
  53668. export var gpuUpdateParticlesVertexShader: {
  53669. name: string;
  53670. shader: string;
  53671. };
  53672. }
  53673. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53674. /** @hidden */
  53675. export var clipPlaneFragmentDeclaration2: {
  53676. name: string;
  53677. shader: string;
  53678. };
  53679. }
  53680. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53681. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53682. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53683. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53684. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53685. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53686. /** @hidden */
  53687. export var gpuRenderParticlesPixelShader: {
  53688. name: string;
  53689. shader: string;
  53690. };
  53691. }
  53692. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53693. /** @hidden */
  53694. export var clipPlaneVertexDeclaration2: {
  53695. name: string;
  53696. shader: string;
  53697. };
  53698. }
  53699. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53700. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53701. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53702. /** @hidden */
  53703. export var gpuRenderParticlesVertexShader: {
  53704. name: string;
  53705. shader: string;
  53706. };
  53707. }
  53708. declare module "babylonjs/Particles/gpuParticleSystem" {
  53709. import { Nullable } from "babylonjs/types";
  53710. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53711. import { Observable } from "babylonjs/Misc/observable";
  53712. import { Color4, Color3 } from "babylonjs/Maths/math";
  53713. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53714. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53715. import { Scene, IDisposable } from "babylonjs/scene";
  53716. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53717. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53718. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53719. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53720. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53721. /**
  53722. * This represents a GPU particle system in Babylon
  53723. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53724. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53725. */
  53726. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53727. /**
  53728. * The layer mask we are rendering the particles through.
  53729. */
  53730. layerMask: number;
  53731. private _capacity;
  53732. private _activeCount;
  53733. private _currentActiveCount;
  53734. private _accumulatedCount;
  53735. private _renderEffect;
  53736. private _updateEffect;
  53737. private _buffer0;
  53738. private _buffer1;
  53739. private _spriteBuffer;
  53740. private _updateVAO;
  53741. private _renderVAO;
  53742. private _targetIndex;
  53743. private _sourceBuffer;
  53744. private _targetBuffer;
  53745. private _engine;
  53746. private _currentRenderId;
  53747. private _started;
  53748. private _stopped;
  53749. private _timeDelta;
  53750. private _randomTexture;
  53751. private _randomTexture2;
  53752. private _attributesStrideSize;
  53753. private _updateEffectOptions;
  53754. private _randomTextureSize;
  53755. private _actualFrame;
  53756. private readonly _rawTextureWidth;
  53757. /**
  53758. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53759. */
  53760. static readonly IsSupported: boolean;
  53761. /**
  53762. * An event triggered when the system is disposed.
  53763. */
  53764. onDisposeObservable: Observable<GPUParticleSystem>;
  53765. /**
  53766. * Gets the maximum number of particles active at the same time.
  53767. * @returns The max number of active particles.
  53768. */
  53769. getCapacity(): number;
  53770. /**
  53771. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53772. * to override the particles.
  53773. */
  53774. forceDepthWrite: boolean;
  53775. /**
  53776. * Gets or set the number of active particles
  53777. */
  53778. activeParticleCount: number;
  53779. private _preWarmDone;
  53780. /**
  53781. * Is this system ready to be used/rendered
  53782. * @return true if the system is ready
  53783. */
  53784. isReady(): boolean;
  53785. /**
  53786. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53787. * @returns True if it has been started, otherwise false.
  53788. */
  53789. isStarted(): boolean;
  53790. /**
  53791. * Starts the particle system and begins to emit
  53792. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53793. */
  53794. start(delay?: number): void;
  53795. /**
  53796. * Stops the particle system.
  53797. */
  53798. stop(): void;
  53799. /**
  53800. * Remove all active particles
  53801. */
  53802. reset(): void;
  53803. /**
  53804. * Returns the string "GPUParticleSystem"
  53805. * @returns a string containing the class name
  53806. */
  53807. getClassName(): string;
  53808. private _colorGradientsTexture;
  53809. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53810. /**
  53811. * Adds a new color gradient
  53812. * @param gradient defines the gradient to use (between 0 and 1)
  53813. * @param color1 defines the color to affect to the specified gradient
  53814. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53815. * @returns the current particle system
  53816. */
  53817. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53818. /**
  53819. * Remove a specific color gradient
  53820. * @param gradient defines the gradient to remove
  53821. * @returns the current particle system
  53822. */
  53823. removeColorGradient(gradient: number): GPUParticleSystem;
  53824. private _angularSpeedGradientsTexture;
  53825. private _sizeGradientsTexture;
  53826. private _velocityGradientsTexture;
  53827. private _limitVelocityGradientsTexture;
  53828. private _dragGradientsTexture;
  53829. private _addFactorGradient;
  53830. /**
  53831. * Adds a new size gradient
  53832. * @param gradient defines the gradient to use (between 0 and 1)
  53833. * @param factor defines the size factor to affect to the specified gradient
  53834. * @returns the current particle system
  53835. */
  53836. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53837. /**
  53838. * Remove a specific size gradient
  53839. * @param gradient defines the gradient to remove
  53840. * @returns the current particle system
  53841. */
  53842. removeSizeGradient(gradient: number): GPUParticleSystem;
  53843. /**
  53844. * Adds a new angular speed gradient
  53845. * @param gradient defines the gradient to use (between 0 and 1)
  53846. * @param factor defines the angular speed to affect to the specified gradient
  53847. * @returns the current particle system
  53848. */
  53849. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53850. /**
  53851. * Remove a specific angular speed gradient
  53852. * @param gradient defines the gradient to remove
  53853. * @returns the current particle system
  53854. */
  53855. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53856. /**
  53857. * Adds a new velocity gradient
  53858. * @param gradient defines the gradient to use (between 0 and 1)
  53859. * @param factor defines the velocity to affect to the specified gradient
  53860. * @returns the current particle system
  53861. */
  53862. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53863. /**
  53864. * Remove a specific velocity gradient
  53865. * @param gradient defines the gradient to remove
  53866. * @returns the current particle system
  53867. */
  53868. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53869. /**
  53870. * Adds a new limit velocity gradient
  53871. * @param gradient defines the gradient to use (between 0 and 1)
  53872. * @param factor defines the limit velocity value to affect to the specified gradient
  53873. * @returns the current particle system
  53874. */
  53875. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53876. /**
  53877. * Remove a specific limit velocity gradient
  53878. * @param gradient defines the gradient to remove
  53879. * @returns the current particle system
  53880. */
  53881. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53882. /**
  53883. * Adds a new drag gradient
  53884. * @param gradient defines the gradient to use (between 0 and 1)
  53885. * @param factor defines the drag value to affect to the specified gradient
  53886. * @returns the current particle system
  53887. */
  53888. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53889. /**
  53890. * Remove a specific drag gradient
  53891. * @param gradient defines the gradient to remove
  53892. * @returns the current particle system
  53893. */
  53894. removeDragGradient(gradient: number): GPUParticleSystem;
  53895. /**
  53896. * Not supported by GPUParticleSystem
  53897. * @param gradient defines the gradient to use (between 0 and 1)
  53898. * @param factor defines the emit rate value to affect to the specified gradient
  53899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53900. * @returns the current particle system
  53901. */
  53902. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53903. /**
  53904. * Not supported by GPUParticleSystem
  53905. * @param gradient defines the gradient to remove
  53906. * @returns the current particle system
  53907. */
  53908. removeEmitRateGradient(gradient: number): IParticleSystem;
  53909. /**
  53910. * Not supported by GPUParticleSystem
  53911. * @param gradient defines the gradient to use (between 0 and 1)
  53912. * @param factor defines the start size value to affect to the specified gradient
  53913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53914. * @returns the current particle system
  53915. */
  53916. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53917. /**
  53918. * Not supported by GPUParticleSystem
  53919. * @param gradient defines the gradient to remove
  53920. * @returns the current particle system
  53921. */
  53922. removeStartSizeGradient(gradient: number): IParticleSystem;
  53923. /**
  53924. * Not supported by GPUParticleSystem
  53925. * @param gradient defines the gradient to use (between 0 and 1)
  53926. * @param min defines the color remap minimal range
  53927. * @param max defines the color remap maximal range
  53928. * @returns the current particle system
  53929. */
  53930. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53931. /**
  53932. * Not supported by GPUParticleSystem
  53933. * @param gradient defines the gradient to remove
  53934. * @returns the current particle system
  53935. */
  53936. removeColorRemapGradient(): IParticleSystem;
  53937. /**
  53938. * Not supported by GPUParticleSystem
  53939. * @param gradient defines the gradient to use (between 0 and 1)
  53940. * @param min defines the alpha remap minimal range
  53941. * @param max defines the alpha remap maximal range
  53942. * @returns the current particle system
  53943. */
  53944. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53945. /**
  53946. * Not supported by GPUParticleSystem
  53947. * @param gradient defines the gradient to remove
  53948. * @returns the current particle system
  53949. */
  53950. removeAlphaRemapGradient(): IParticleSystem;
  53951. /**
  53952. * Not supported by GPUParticleSystem
  53953. * @param gradient defines the gradient to use (between 0 and 1)
  53954. * @param color defines the color to affect to the specified gradient
  53955. * @returns the current particle system
  53956. */
  53957. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53958. /**
  53959. * Not supported by GPUParticleSystem
  53960. * @param gradient defines the gradient to remove
  53961. * @returns the current particle system
  53962. */
  53963. removeRampGradient(): IParticleSystem;
  53964. /**
  53965. * Not supported by GPUParticleSystem
  53966. * @returns the list of ramp gradients
  53967. */
  53968. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53969. /**
  53970. * Not supported by GPUParticleSystem
  53971. * Gets or sets a boolean indicating that ramp gradients must be used
  53972. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53973. */
  53974. useRampGradients: boolean;
  53975. /**
  53976. * Not supported by GPUParticleSystem
  53977. * @param gradient defines the gradient to use (between 0 and 1)
  53978. * @param factor defines the life time factor to affect to the specified gradient
  53979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53980. * @returns the current particle system
  53981. */
  53982. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53983. /**
  53984. * Not supported by GPUParticleSystem
  53985. * @param gradient defines the gradient to remove
  53986. * @returns the current particle system
  53987. */
  53988. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53989. /**
  53990. * Instantiates a GPU particle system.
  53991. * 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.
  53992. * @param name The name of the particle system
  53993. * @param options The options used to create the system
  53994. * @param scene The scene the particle system belongs to
  53995. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53996. */
  53997. constructor(name: string, options: Partial<{
  53998. capacity: number;
  53999. randomTextureSize: number;
  54000. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54001. protected _reset(): void;
  54002. private _createUpdateVAO;
  54003. private _createRenderVAO;
  54004. private _initialize;
  54005. /** @hidden */
  54006. _recreateUpdateEffect(): void;
  54007. /** @hidden */
  54008. _recreateRenderEffect(): void;
  54009. /**
  54010. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54011. * @param preWarm defines if we are in the pre-warmimg phase
  54012. */
  54013. animate(preWarm?: boolean): void;
  54014. private _createFactorGradientTexture;
  54015. private _createSizeGradientTexture;
  54016. private _createAngularSpeedGradientTexture;
  54017. private _createVelocityGradientTexture;
  54018. private _createLimitVelocityGradientTexture;
  54019. private _createDragGradientTexture;
  54020. private _createColorGradientTexture;
  54021. /**
  54022. * Renders the particle system in its current state
  54023. * @param preWarm defines if the system should only update the particles but not render them
  54024. * @returns the current number of particles
  54025. */
  54026. render(preWarm?: boolean): number;
  54027. /**
  54028. * Rebuilds the particle system
  54029. */
  54030. rebuild(): void;
  54031. private _releaseBuffers;
  54032. private _releaseVAOs;
  54033. /**
  54034. * Disposes the particle system and free the associated resources
  54035. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54036. */
  54037. dispose(disposeTexture?: boolean): void;
  54038. /**
  54039. * Clones the particle system.
  54040. * @param name The name of the cloned object
  54041. * @param newEmitter The new emitter to use
  54042. * @returns the cloned particle system
  54043. */
  54044. clone(name: string, newEmitter: any): GPUParticleSystem;
  54045. /**
  54046. * Serializes the particle system to a JSON object.
  54047. * @returns the JSON object
  54048. */
  54049. serialize(): any;
  54050. /**
  54051. * Parses a JSON object to create a GPU particle system.
  54052. * @param parsedParticleSystem The JSON object to parse
  54053. * @param scene The scene to create the particle system in
  54054. * @param rootUrl The root url to use to load external dependencies like texture
  54055. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54056. * @returns the parsed GPU particle system
  54057. */
  54058. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54059. }
  54060. }
  54061. declare module "babylonjs/Particles/particleSystemSet" {
  54062. import { Nullable } from "babylonjs/types";
  54063. import { Color3 } from "babylonjs/Maths/math";
  54064. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54066. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54067. import { Scene, IDisposable } from "babylonjs/scene";
  54068. /**
  54069. * Represents a set of particle systems working together to create a specific effect
  54070. */
  54071. export class ParticleSystemSet implements IDisposable {
  54072. private _emitterCreationOptions;
  54073. private _emitterNode;
  54074. /**
  54075. * Gets the particle system list
  54076. */
  54077. systems: IParticleSystem[];
  54078. /**
  54079. * Gets the emitter node used with this set
  54080. */
  54081. readonly emitterNode: Nullable<TransformNode>;
  54082. /**
  54083. * Creates a new emitter mesh as a sphere
  54084. * @param options defines the options used to create the sphere
  54085. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54086. * @param scene defines the hosting scene
  54087. */
  54088. setEmitterAsSphere(options: {
  54089. diameter: number;
  54090. segments: number;
  54091. color: Color3;
  54092. }, renderingGroupId: number, scene: Scene): void;
  54093. /**
  54094. * Starts all particle systems of the set
  54095. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54096. */
  54097. start(emitter?: AbstractMesh): void;
  54098. /**
  54099. * Release all associated resources
  54100. */
  54101. dispose(): void;
  54102. /**
  54103. * Serialize the set into a JSON compatible object
  54104. * @returns a JSON compatible representation of the set
  54105. */
  54106. serialize(): any;
  54107. /**
  54108. * Parse a new ParticleSystemSet from a serialized source
  54109. * @param data defines a JSON compatible representation of the set
  54110. * @param scene defines the hosting scene
  54111. * @param gpu defines if we want GPU particles or CPU particles
  54112. * @returns a new ParticleSystemSet
  54113. */
  54114. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54115. }
  54116. }
  54117. declare module "babylonjs/Particles/particleHelper" {
  54118. import { Nullable } from "babylonjs/types";
  54119. import { Scene } from "babylonjs/scene";
  54120. import { Vector3 } from "babylonjs/Maths/math";
  54121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54122. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54123. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54124. /**
  54125. * This class is made for on one-liner static method to help creating particle system set.
  54126. */
  54127. export class ParticleHelper {
  54128. /**
  54129. * Gets or sets base Assets URL
  54130. */
  54131. static BaseAssetsUrl: string;
  54132. /**
  54133. * Create a default particle system that you can tweak
  54134. * @param emitter defines the emitter to use
  54135. * @param capacity defines the system capacity (default is 500 particles)
  54136. * @param scene defines the hosting scene
  54137. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54138. * @returns the new Particle system
  54139. */
  54140. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54141. /**
  54142. * This is the main static method (one-liner) of this helper to create different particle systems
  54143. * @param type This string represents the type to the particle system to create
  54144. * @param scene The scene where the particle system should live
  54145. * @param gpu If the system will use gpu
  54146. * @returns the ParticleSystemSet created
  54147. */
  54148. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54149. /**
  54150. * Static function used to export a particle system to a ParticleSystemSet variable.
  54151. * Please note that the emitter shape is not exported
  54152. * @param systems defines the particle systems to export
  54153. * @returns the created particle system set
  54154. */
  54155. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54156. }
  54157. }
  54158. declare module "babylonjs/Particles/particleSystemComponent" {
  54159. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54160. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54161. import "babylonjs/Shaders/particles.vertex";
  54162. module "babylonjs/Engines/engine" {
  54163. interface Engine {
  54164. /**
  54165. * Create an effect to use with particle systems.
  54166. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54167. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54168. * @param uniformsNames defines a list of attribute names
  54169. * @param samplers defines an array of string used to represent textures
  54170. * @param defines defines the string containing the defines to use to compile the shaders
  54171. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54172. * @param onCompiled defines a function to call when the effect creation is successful
  54173. * @param onError defines a function to call when the effect creation has failed
  54174. * @returns the new Effect
  54175. */
  54176. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54177. }
  54178. }
  54179. module "babylonjs/Meshes/mesh" {
  54180. interface Mesh {
  54181. /**
  54182. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54183. * @returns an array of IParticleSystem
  54184. */
  54185. getEmittedParticleSystems(): IParticleSystem[];
  54186. /**
  54187. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54188. * @returns an array of IParticleSystem
  54189. */
  54190. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54191. }
  54192. }
  54193. /**
  54194. * @hidden
  54195. */
  54196. export var _IDoNeedToBeInTheBuild: number;
  54197. }
  54198. declare module "babylonjs/Particles/index" {
  54199. export * from "babylonjs/Particles/baseParticleSystem";
  54200. export * from "babylonjs/Particles/EmitterTypes/index";
  54201. export * from "babylonjs/Particles/gpuParticleSystem";
  54202. export * from "babylonjs/Particles/IParticleSystem";
  54203. export * from "babylonjs/Particles/particle";
  54204. export * from "babylonjs/Particles/particleHelper";
  54205. export * from "babylonjs/Particles/particleSystem";
  54206. export * from "babylonjs/Particles/particleSystemComponent";
  54207. export * from "babylonjs/Particles/particleSystemSet";
  54208. export * from "babylonjs/Particles/solidParticle";
  54209. export * from "babylonjs/Particles/solidParticleSystem";
  54210. export * from "babylonjs/Particles/subEmitter";
  54211. }
  54212. declare module "babylonjs/Physics/physicsEngineComponent" {
  54213. import { Nullable } from "babylonjs/types";
  54214. import { Observable, Observer } from "babylonjs/Misc/observable";
  54215. import { Vector3 } from "babylonjs/Maths/math";
  54216. import { Mesh } from "babylonjs/Meshes/mesh";
  54217. import { ISceneComponent } from "babylonjs/sceneComponent";
  54218. import { Scene } from "babylonjs/scene";
  54219. import { Node } from "babylonjs/node";
  54220. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54221. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54222. module "babylonjs/scene" {
  54223. interface Scene {
  54224. /** @hidden (Backing field) */
  54225. _physicsEngine: Nullable<IPhysicsEngine>;
  54226. /**
  54227. * Gets the current physics engine
  54228. * @returns a IPhysicsEngine or null if none attached
  54229. */
  54230. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54231. /**
  54232. * Enables physics to the current scene
  54233. * @param gravity defines the scene's gravity for the physics engine
  54234. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54235. * @return a boolean indicating if the physics engine was initialized
  54236. */
  54237. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54238. /**
  54239. * Disables and disposes the physics engine associated with the scene
  54240. */
  54241. disablePhysicsEngine(): void;
  54242. /**
  54243. * Gets a boolean indicating if there is an active physics engine
  54244. * @returns a boolean indicating if there is an active physics engine
  54245. */
  54246. isPhysicsEnabled(): boolean;
  54247. /**
  54248. * Deletes a physics compound impostor
  54249. * @param compound defines the compound to delete
  54250. */
  54251. deleteCompoundImpostor(compound: any): void;
  54252. /**
  54253. * An event triggered when physic simulation is about to be run
  54254. */
  54255. onBeforePhysicsObservable: Observable<Scene>;
  54256. /**
  54257. * An event triggered when physic simulation has been done
  54258. */
  54259. onAfterPhysicsObservable: Observable<Scene>;
  54260. }
  54261. }
  54262. module "babylonjs/Meshes/abstractMesh" {
  54263. interface AbstractMesh {
  54264. /** @hidden */
  54265. _physicsImpostor: Nullable<PhysicsImpostor>;
  54266. /**
  54267. * Gets or sets impostor used for physic simulation
  54268. * @see http://doc.babylonjs.com/features/physics_engine
  54269. */
  54270. physicsImpostor: Nullable<PhysicsImpostor>;
  54271. /**
  54272. * Gets the current physics impostor
  54273. * @see http://doc.babylonjs.com/features/physics_engine
  54274. * @returns a physics impostor or null
  54275. */
  54276. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54277. /** Apply a physic impulse to the mesh
  54278. * @param force defines the force to apply
  54279. * @param contactPoint defines where to apply the force
  54280. * @returns the current mesh
  54281. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54282. */
  54283. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54284. /**
  54285. * Creates a physic joint between two meshes
  54286. * @param otherMesh defines the other mesh to use
  54287. * @param pivot1 defines the pivot to use on this mesh
  54288. * @param pivot2 defines the pivot to use on the other mesh
  54289. * @param options defines additional options (can be plugin dependent)
  54290. * @returns the current mesh
  54291. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54292. */
  54293. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54294. /** @hidden */
  54295. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54296. }
  54297. }
  54298. /**
  54299. * Defines the physics engine scene component responsible to manage a physics engine
  54300. */
  54301. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54302. /**
  54303. * The component name helpful to identify the component in the list of scene components.
  54304. */
  54305. readonly name: string;
  54306. /**
  54307. * The scene the component belongs to.
  54308. */
  54309. scene: Scene;
  54310. /**
  54311. * Creates a new instance of the component for the given scene
  54312. * @param scene Defines the scene to register the component in
  54313. */
  54314. constructor(scene: Scene);
  54315. /**
  54316. * Registers the component in a given scene
  54317. */
  54318. register(): void;
  54319. /**
  54320. * Rebuilds the elements related to this component in case of
  54321. * context lost for instance.
  54322. */
  54323. rebuild(): void;
  54324. /**
  54325. * Disposes the component and the associated ressources
  54326. */
  54327. dispose(): void;
  54328. }
  54329. }
  54330. declare module "babylonjs/Physics/physicsHelper" {
  54331. import { Nullable } from "babylonjs/types";
  54332. import { Vector3 } from "babylonjs/Maths/math";
  54333. import { Mesh } from "babylonjs/Meshes/mesh";
  54334. import { Scene } from "babylonjs/scene";
  54335. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54336. /**
  54337. * A helper for physics simulations
  54338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54339. */
  54340. export class PhysicsHelper {
  54341. private _scene;
  54342. private _physicsEngine;
  54343. /**
  54344. * Initializes the Physics helper
  54345. * @param scene Babylon.js scene
  54346. */
  54347. constructor(scene: Scene);
  54348. /**
  54349. * Applies a radial explosion impulse
  54350. * @param origin the origin of the explosion
  54351. * @param radiusOrEventOptions the radius or the options of radial explosion
  54352. * @param strength the explosion strength
  54353. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54354. * @returns A physics radial explosion event, or null
  54355. */
  54356. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54357. /**
  54358. * Applies a radial explosion force
  54359. * @param origin the origin of the explosion
  54360. * @param radiusOrEventOptions the radius or the options of radial explosion
  54361. * @param strength the explosion strength
  54362. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54363. * @returns A physics radial explosion event, or null
  54364. */
  54365. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54366. /**
  54367. * Creates a gravitational field
  54368. * @param origin the origin of the explosion
  54369. * @param radiusOrEventOptions the radius or the options of radial explosion
  54370. * @param strength the explosion strength
  54371. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54372. * @returns A physics gravitational field event, or null
  54373. */
  54374. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54375. /**
  54376. * Creates a physics updraft event
  54377. * @param origin the origin of the updraft
  54378. * @param radiusOrEventOptions the radius or the options of the updraft
  54379. * @param strength the strength of the updraft
  54380. * @param height the height of the updraft
  54381. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54382. * @returns A physics updraft event, or null
  54383. */
  54384. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54385. /**
  54386. * Creates a physics vortex event
  54387. * @param origin the of the vortex
  54388. * @param radiusOrEventOptions the radius or the options of the vortex
  54389. * @param strength the strength of the vortex
  54390. * @param height the height of the vortex
  54391. * @returns a Physics vortex event, or null
  54392. * A physics vortex event or null
  54393. */
  54394. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54395. }
  54396. /**
  54397. * Represents a physics radial explosion event
  54398. */
  54399. class PhysicsRadialExplosionEvent {
  54400. private _scene;
  54401. private _options;
  54402. private _sphere;
  54403. private _dataFetched;
  54404. /**
  54405. * Initializes a radial explosioin event
  54406. * @param _scene BabylonJS scene
  54407. * @param _options The options for the vortex event
  54408. */
  54409. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54410. /**
  54411. * Returns the data related to the radial explosion event (sphere).
  54412. * @returns The radial explosion event data
  54413. */
  54414. getData(): PhysicsRadialExplosionEventData;
  54415. /**
  54416. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54417. * @param impostor A physics imposter
  54418. * @param origin the origin of the explosion
  54419. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54420. */
  54421. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54422. /**
  54423. * Triggers affecterd impostors callbacks
  54424. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54425. */
  54426. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54427. /**
  54428. * Disposes the sphere.
  54429. * @param force Specifies if the sphere should be disposed by force
  54430. */
  54431. dispose(force?: boolean): void;
  54432. /*** Helpers ***/
  54433. private _prepareSphere;
  54434. private _intersectsWithSphere;
  54435. }
  54436. /**
  54437. * Represents a gravitational field event
  54438. */
  54439. class PhysicsGravitationalFieldEvent {
  54440. private _physicsHelper;
  54441. private _scene;
  54442. private _origin;
  54443. private _options;
  54444. private _tickCallback;
  54445. private _sphere;
  54446. private _dataFetched;
  54447. /**
  54448. * Initializes the physics gravitational field event
  54449. * @param _physicsHelper A physics helper
  54450. * @param _scene BabylonJS scene
  54451. * @param _origin The origin position of the gravitational field event
  54452. * @param _options The options for the vortex event
  54453. */
  54454. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54455. /**
  54456. * Returns the data related to the gravitational field event (sphere).
  54457. * @returns A gravitational field event
  54458. */
  54459. getData(): PhysicsGravitationalFieldEventData;
  54460. /**
  54461. * Enables the gravitational field.
  54462. */
  54463. enable(): void;
  54464. /**
  54465. * Disables the gravitational field.
  54466. */
  54467. disable(): void;
  54468. /**
  54469. * Disposes the sphere.
  54470. * @param force The force to dispose from the gravitational field event
  54471. */
  54472. dispose(force?: boolean): void;
  54473. private _tick;
  54474. }
  54475. /**
  54476. * Represents a physics updraft event
  54477. */
  54478. class PhysicsUpdraftEvent {
  54479. private _scene;
  54480. private _origin;
  54481. private _options;
  54482. private _physicsEngine;
  54483. private _originTop;
  54484. private _originDirection;
  54485. private _tickCallback;
  54486. private _cylinder;
  54487. private _cylinderPosition;
  54488. private _dataFetched;
  54489. /**
  54490. * Initializes the physics updraft event
  54491. * @param _scene BabylonJS scene
  54492. * @param _origin The origin position of the updraft
  54493. * @param _options The options for the updraft event
  54494. */
  54495. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54496. /**
  54497. * Returns the data related to the updraft event (cylinder).
  54498. * @returns A physics updraft event
  54499. */
  54500. getData(): PhysicsUpdraftEventData;
  54501. /**
  54502. * Enables the updraft.
  54503. */
  54504. enable(): void;
  54505. /**
  54506. * Disables the updraft.
  54507. */
  54508. disable(): void;
  54509. /**
  54510. * Disposes the cylinder.
  54511. * @param force Specifies if the updraft should be disposed by force
  54512. */
  54513. dispose(force?: boolean): void;
  54514. private getImpostorHitData;
  54515. private _tick;
  54516. /*** Helpers ***/
  54517. private _prepareCylinder;
  54518. private _intersectsWithCylinder;
  54519. }
  54520. /**
  54521. * Represents a physics vortex event
  54522. */
  54523. class PhysicsVortexEvent {
  54524. private _scene;
  54525. private _origin;
  54526. private _options;
  54527. private _physicsEngine;
  54528. private _originTop;
  54529. private _tickCallback;
  54530. private _cylinder;
  54531. private _cylinderPosition;
  54532. private _dataFetched;
  54533. /**
  54534. * Initializes the physics vortex event
  54535. * @param _scene The BabylonJS scene
  54536. * @param _origin The origin position of the vortex
  54537. * @param _options The options for the vortex event
  54538. */
  54539. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54540. /**
  54541. * Returns the data related to the vortex event (cylinder).
  54542. * @returns The physics vortex event data
  54543. */
  54544. getData(): PhysicsVortexEventData;
  54545. /**
  54546. * Enables the vortex.
  54547. */
  54548. enable(): void;
  54549. /**
  54550. * Disables the cortex.
  54551. */
  54552. disable(): void;
  54553. /**
  54554. * Disposes the sphere.
  54555. * @param force
  54556. */
  54557. dispose(force?: boolean): void;
  54558. private getImpostorHitData;
  54559. private _tick;
  54560. /*** Helpers ***/
  54561. private _prepareCylinder;
  54562. private _intersectsWithCylinder;
  54563. }
  54564. /**
  54565. * Options fot the radial explosion event
  54566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54567. */
  54568. export class PhysicsRadialExplosionEventOptions {
  54569. /**
  54570. * The radius of the sphere for the radial explosion.
  54571. */
  54572. radius: number;
  54573. /**
  54574. * The strenth of the explosion.
  54575. */
  54576. strength: number;
  54577. /**
  54578. * The strenght of the force in correspondence to the distance of the affected object
  54579. */
  54580. falloff: PhysicsRadialImpulseFalloff;
  54581. /**
  54582. * Sphere options for the radial explosion.
  54583. */
  54584. sphere: {
  54585. segments: number;
  54586. diameter: number;
  54587. };
  54588. /**
  54589. * Sphere options for the radial explosion.
  54590. */
  54591. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54592. }
  54593. /**
  54594. * Options fot the updraft event
  54595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54596. */
  54597. export class PhysicsUpdraftEventOptions {
  54598. /**
  54599. * The radius of the cylinder for the vortex
  54600. */
  54601. radius: number;
  54602. /**
  54603. * The strenth of the updraft.
  54604. */
  54605. strength: number;
  54606. /**
  54607. * The height of the cylinder for the updraft.
  54608. */
  54609. height: number;
  54610. /**
  54611. * The mode for the the updraft.
  54612. */
  54613. updraftMode: PhysicsUpdraftMode;
  54614. }
  54615. /**
  54616. * Options fot the vortex event
  54617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54618. */
  54619. export class PhysicsVortexEventOptions {
  54620. /**
  54621. * The radius of the cylinder for the vortex
  54622. */
  54623. radius: number;
  54624. /**
  54625. * The strenth of the vortex.
  54626. */
  54627. strength: number;
  54628. /**
  54629. * The height of the cylinder for the vortex.
  54630. */
  54631. height: number;
  54632. /**
  54633. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54634. */
  54635. centripetalForceThreshold: number;
  54636. /**
  54637. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54638. */
  54639. centripetalForceMultiplier: number;
  54640. /**
  54641. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54642. */
  54643. centrifugalForceMultiplier: number;
  54644. /**
  54645. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54646. */
  54647. updraftForceMultiplier: number;
  54648. }
  54649. /**
  54650. * The strenght of the force in correspondence to the distance of the affected object
  54651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54652. */
  54653. export enum PhysicsRadialImpulseFalloff {
  54654. /** Defines that impulse is constant in strength across it's whole radius */
  54655. Constant = 0,
  54656. /** Defines that impulse gets weaker if it's further from the origin */
  54657. Linear = 1
  54658. }
  54659. /**
  54660. * The strength of the force in correspondence to the distance of the affected object
  54661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54662. */
  54663. export enum PhysicsUpdraftMode {
  54664. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54665. Center = 0,
  54666. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54667. Perpendicular = 1
  54668. }
  54669. /**
  54670. * Interface for a physics hit data
  54671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54672. */
  54673. export interface PhysicsHitData {
  54674. /**
  54675. * The force applied at the contact point
  54676. */
  54677. force: Vector3;
  54678. /**
  54679. * The contact point
  54680. */
  54681. contactPoint: Vector3;
  54682. /**
  54683. * The distance from the origin to the contact point
  54684. */
  54685. distanceFromOrigin: number;
  54686. }
  54687. /**
  54688. * Interface for radial explosion event data
  54689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54690. */
  54691. export interface PhysicsRadialExplosionEventData {
  54692. /**
  54693. * A sphere used for the radial explosion event
  54694. */
  54695. sphere: Mesh;
  54696. }
  54697. /**
  54698. * Interface for gravitational field event data
  54699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54700. */
  54701. export interface PhysicsGravitationalFieldEventData {
  54702. /**
  54703. * A sphere mesh used for the gravitational field event
  54704. */
  54705. sphere: Mesh;
  54706. }
  54707. /**
  54708. * Interface for updraft event data
  54709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54710. */
  54711. export interface PhysicsUpdraftEventData {
  54712. /**
  54713. * A cylinder used for the updraft event
  54714. */
  54715. cylinder: Mesh;
  54716. }
  54717. /**
  54718. * Interface for vortex event data
  54719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54720. */
  54721. export interface PhysicsVortexEventData {
  54722. /**
  54723. * A cylinder used for the vortex event
  54724. */
  54725. cylinder: Mesh;
  54726. }
  54727. /**
  54728. * Interface for an affected physics impostor
  54729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54730. */
  54731. export interface PhysicsAffectedImpostorWithData {
  54732. /**
  54733. * The impostor affected by the effect
  54734. */
  54735. impostor: PhysicsImpostor;
  54736. /**
  54737. * The data about the hit/horce from the explosion
  54738. */
  54739. hitData: PhysicsHitData;
  54740. }
  54741. }
  54742. declare module "babylonjs/Physics/Plugins/index" {
  54743. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54744. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54745. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54746. }
  54747. declare module "babylonjs/Physics/index" {
  54748. export * from "babylonjs/Physics/IPhysicsEngine";
  54749. export * from "babylonjs/Physics/physicsEngine";
  54750. export * from "babylonjs/Physics/physicsEngineComponent";
  54751. export * from "babylonjs/Physics/physicsHelper";
  54752. export * from "babylonjs/Physics/physicsImpostor";
  54753. export * from "babylonjs/Physics/physicsJoint";
  54754. export * from "babylonjs/Physics/Plugins/index";
  54755. }
  54756. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54757. /** @hidden */
  54758. export var blackAndWhitePixelShader: {
  54759. name: string;
  54760. shader: string;
  54761. };
  54762. }
  54763. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54764. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54765. import { Camera } from "babylonjs/Cameras/camera";
  54766. import { Engine } from "babylonjs/Engines/engine";
  54767. import "babylonjs/Shaders/blackAndWhite.fragment";
  54768. /**
  54769. * Post process used to render in black and white
  54770. */
  54771. export class BlackAndWhitePostProcess extends PostProcess {
  54772. /**
  54773. * Linear about to convert he result to black and white (default: 1)
  54774. */
  54775. degree: number;
  54776. /**
  54777. * Creates a black and white post process
  54778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54779. * @param name The name of the effect.
  54780. * @param options The required width/height ratio to downsize to before computing the render pass.
  54781. * @param camera The camera to apply the render pass to.
  54782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54783. * @param engine The engine which the post process will be applied. (default: current engine)
  54784. * @param reusable If the post process can be reused on the same frame. (default: false)
  54785. */
  54786. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54787. }
  54788. }
  54789. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54790. import { Nullable } from "babylonjs/types";
  54791. import { Camera } from "babylonjs/Cameras/camera";
  54792. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54793. import { Engine } from "babylonjs/Engines/engine";
  54794. /**
  54795. * This represents a set of one or more post processes in Babylon.
  54796. * A post process can be used to apply a shader to a texture after it is rendered.
  54797. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54798. */
  54799. export class PostProcessRenderEffect {
  54800. private _postProcesses;
  54801. private _getPostProcesses;
  54802. private _singleInstance;
  54803. private _cameras;
  54804. private _indicesForCamera;
  54805. /**
  54806. * Name of the effect
  54807. * @hidden
  54808. */
  54809. _name: string;
  54810. /**
  54811. * Instantiates a post process render effect.
  54812. * A post process can be used to apply a shader to a texture after it is rendered.
  54813. * @param engine The engine the effect is tied to
  54814. * @param name The name of the effect
  54815. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54816. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54817. */
  54818. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54819. /**
  54820. * Checks if all the post processes in the effect are supported.
  54821. */
  54822. readonly isSupported: boolean;
  54823. /**
  54824. * Updates the current state of the effect
  54825. * @hidden
  54826. */
  54827. _update(): void;
  54828. /**
  54829. * Attaches the effect on cameras
  54830. * @param cameras The camera to attach to.
  54831. * @hidden
  54832. */
  54833. _attachCameras(cameras: Camera): void;
  54834. /**
  54835. * Attaches the effect on cameras
  54836. * @param cameras The camera to attach to.
  54837. * @hidden
  54838. */
  54839. _attachCameras(cameras: Camera[]): void;
  54840. /**
  54841. * Detaches the effect on cameras
  54842. * @param cameras The camera to detatch from.
  54843. * @hidden
  54844. */
  54845. _detachCameras(cameras: Camera): void;
  54846. /**
  54847. * Detatches the effect on cameras
  54848. * @param cameras The camera to detatch from.
  54849. * @hidden
  54850. */
  54851. _detachCameras(cameras: Camera[]): void;
  54852. /**
  54853. * Enables the effect on given cameras
  54854. * @param cameras The camera to enable.
  54855. * @hidden
  54856. */
  54857. _enable(cameras: Camera): void;
  54858. /**
  54859. * Enables the effect on given cameras
  54860. * @param cameras The camera to enable.
  54861. * @hidden
  54862. */
  54863. _enable(cameras: Nullable<Camera[]>): void;
  54864. /**
  54865. * Disables the effect on the given cameras
  54866. * @param cameras The camera to disable.
  54867. * @hidden
  54868. */
  54869. _disable(cameras: Camera): void;
  54870. /**
  54871. * Disables the effect on the given cameras
  54872. * @param cameras The camera to disable.
  54873. * @hidden
  54874. */
  54875. _disable(cameras: Nullable<Camera[]>): void;
  54876. /**
  54877. * Gets a list of the post processes contained in the effect.
  54878. * @param camera The camera to get the post processes on.
  54879. * @returns The list of the post processes in the effect.
  54880. */
  54881. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54882. }
  54883. }
  54884. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54885. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54886. /** @hidden */
  54887. export var extractHighlightsPixelShader: {
  54888. name: string;
  54889. shader: string;
  54890. };
  54891. }
  54892. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54893. import { Nullable } from "babylonjs/types";
  54894. import { Camera } from "babylonjs/Cameras/camera";
  54895. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54896. import { Engine } from "babylonjs/Engines/engine";
  54897. import "babylonjs/Shaders/extractHighlights.fragment";
  54898. /**
  54899. * 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.
  54900. */
  54901. export class ExtractHighlightsPostProcess extends PostProcess {
  54902. /**
  54903. * The luminance threshold, pixels below this value will be set to black.
  54904. */
  54905. threshold: number;
  54906. /** @hidden */
  54907. _exposure: number;
  54908. /**
  54909. * Post process which has the input texture to be used when performing highlight extraction
  54910. * @hidden
  54911. */
  54912. _inputPostProcess: Nullable<PostProcess>;
  54913. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54914. }
  54915. }
  54916. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54917. /** @hidden */
  54918. export var bloomMergePixelShader: {
  54919. name: string;
  54920. shader: string;
  54921. };
  54922. }
  54923. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54924. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54925. import { Nullable } from "babylonjs/types";
  54926. import { Engine } from "babylonjs/Engines/engine";
  54927. import { Camera } from "babylonjs/Cameras/camera";
  54928. import "babylonjs/Shaders/bloomMerge.fragment";
  54929. /**
  54930. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54931. */
  54932. export class BloomMergePostProcess extends PostProcess {
  54933. /** Weight of the bloom to be added to the original input. */
  54934. weight: number;
  54935. /**
  54936. * Creates a new instance of @see BloomMergePostProcess
  54937. * @param name The name of the effect.
  54938. * @param originalFromInput Post process which's input will be used for the merge.
  54939. * @param blurred Blurred highlights post process which's output will be used.
  54940. * @param weight Weight of the bloom to be added to the original input.
  54941. * @param options The required width/height ratio to downsize to before computing the render pass.
  54942. * @param camera The camera to apply the render pass to.
  54943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54944. * @param engine The engine which the post process will be applied. (default: current engine)
  54945. * @param reusable If the post process can be reused on the same frame. (default: false)
  54946. * @param textureType Type of textures used when performing the post process. (default: 0)
  54947. * @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)
  54948. */
  54949. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54950. /** Weight of the bloom to be added to the original input. */
  54951. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54952. }
  54953. }
  54954. declare module "babylonjs/PostProcesses/bloomEffect" {
  54955. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54956. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54957. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54958. import { Camera } from "babylonjs/Cameras/camera";
  54959. import { Scene } from "babylonjs/scene";
  54960. /**
  54961. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54962. */
  54963. export class BloomEffect extends PostProcessRenderEffect {
  54964. private bloomScale;
  54965. /**
  54966. * @hidden Internal
  54967. */
  54968. _effects: Array<PostProcess>;
  54969. /**
  54970. * @hidden Internal
  54971. */
  54972. _downscale: ExtractHighlightsPostProcess;
  54973. private _blurX;
  54974. private _blurY;
  54975. private _merge;
  54976. /**
  54977. * The luminance threshold to find bright areas of the image to bloom.
  54978. */
  54979. threshold: number;
  54980. /**
  54981. * The strength of the bloom.
  54982. */
  54983. weight: number;
  54984. /**
  54985. * Specifies the size of the bloom blur kernel, relative to the final output size
  54986. */
  54987. kernel: number;
  54988. /**
  54989. * Creates a new instance of @see BloomEffect
  54990. * @param scene The scene the effect belongs to.
  54991. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54992. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54993. * @param bloomWeight The the strength of bloom.
  54994. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54995. * @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)
  54996. */
  54997. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54998. /**
  54999. * Disposes each of the internal effects for a given camera.
  55000. * @param camera The camera to dispose the effect on.
  55001. */
  55002. disposeEffects(camera: Camera): void;
  55003. /**
  55004. * @hidden Internal
  55005. */
  55006. _updateEffects(): void;
  55007. /**
  55008. * Internal
  55009. * @returns if all the contained post processes are ready.
  55010. * @hidden
  55011. */
  55012. _isReady(): boolean;
  55013. }
  55014. }
  55015. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  55016. /** @hidden */
  55017. export var chromaticAberrationPixelShader: {
  55018. name: string;
  55019. shader: string;
  55020. };
  55021. }
  55022. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  55023. import { Vector2 } from "babylonjs/Maths/math";
  55024. import { Nullable } from "babylonjs/types";
  55025. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55026. import { Camera } from "babylonjs/Cameras/camera";
  55027. import { Engine } from "babylonjs/Engines/engine";
  55028. import "babylonjs/Shaders/chromaticAberration.fragment";
  55029. /**
  55030. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55031. */
  55032. export class ChromaticAberrationPostProcess extends PostProcess {
  55033. /**
  55034. * The amount of seperation of rgb channels (default: 30)
  55035. */
  55036. aberrationAmount: number;
  55037. /**
  55038. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55039. */
  55040. radialIntensity: number;
  55041. /**
  55042. * 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))
  55043. */
  55044. direction: Vector2;
  55045. /**
  55046. * 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))
  55047. */
  55048. centerPosition: Vector2;
  55049. /**
  55050. * Creates a new instance ChromaticAberrationPostProcess
  55051. * @param name The name of the effect.
  55052. * @param screenWidth The width of the screen to apply the effect on.
  55053. * @param screenHeight The height of the screen to apply the effect on.
  55054. * @param options The required width/height ratio to downsize to before computing the render pass.
  55055. * @param camera The camera to apply the render pass to.
  55056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55057. * @param engine The engine which the post process will be applied. (default: current engine)
  55058. * @param reusable If the post process can be reused on the same frame. (default: false)
  55059. * @param textureType Type of textures used when performing the post process. (default: 0)
  55060. * @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)
  55061. */
  55062. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55063. }
  55064. }
  55065. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  55066. /** @hidden */
  55067. export var circleOfConfusionPixelShader: {
  55068. name: string;
  55069. shader: string;
  55070. };
  55071. }
  55072. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  55073. import { Nullable } from "babylonjs/types";
  55074. import { Engine } from "babylonjs/Engines/engine";
  55075. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55076. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55077. import { Camera } from "babylonjs/Cameras/camera";
  55078. import "babylonjs/Shaders/circleOfConfusion.fragment";
  55079. /**
  55080. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55081. */
  55082. export class CircleOfConfusionPostProcess extends PostProcess {
  55083. /**
  55084. * 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.
  55085. */
  55086. lensSize: number;
  55087. /**
  55088. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55089. */
  55090. fStop: number;
  55091. /**
  55092. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55093. */
  55094. focusDistance: number;
  55095. /**
  55096. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55097. */
  55098. focalLength: number;
  55099. private _depthTexture;
  55100. /**
  55101. * Creates a new instance CircleOfConfusionPostProcess
  55102. * @param name The name of the effect.
  55103. * @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.
  55104. * @param options The required width/height ratio to downsize to before computing the render pass.
  55105. * @param camera The camera to apply the render pass to.
  55106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55107. * @param engine The engine which the post process will be applied. (default: current engine)
  55108. * @param reusable If the post process can be reused on the same frame. (default: false)
  55109. * @param textureType Type of textures used when performing the post process. (default: 0)
  55110. * @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)
  55111. */
  55112. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55113. /**
  55114. * 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.
  55115. */
  55116. depthTexture: RenderTargetTexture;
  55117. }
  55118. }
  55119. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55120. /** @hidden */
  55121. export var colorCorrectionPixelShader: {
  55122. name: string;
  55123. shader: string;
  55124. };
  55125. }
  55126. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55127. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55128. import { Engine } from "babylonjs/Engines/engine";
  55129. import { Camera } from "babylonjs/Cameras/camera";
  55130. import "babylonjs/Shaders/colorCorrection.fragment";
  55131. /**
  55132. *
  55133. * This post-process allows the modification of rendered colors by using
  55134. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55135. *
  55136. * The object needs to be provided an url to a texture containing the color
  55137. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55138. * Use an image editing software to tweak the LUT to match your needs.
  55139. *
  55140. * For an example of a color LUT, see here:
  55141. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55142. * For explanations on color grading, see here:
  55143. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55144. *
  55145. */
  55146. export class ColorCorrectionPostProcess extends PostProcess {
  55147. private _colorTableTexture;
  55148. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55149. }
  55150. }
  55151. declare module "babylonjs/Shaders/convolution.fragment" {
  55152. /** @hidden */
  55153. export var convolutionPixelShader: {
  55154. name: string;
  55155. shader: string;
  55156. };
  55157. }
  55158. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55160. import { Nullable } from "babylonjs/types";
  55161. import { Camera } from "babylonjs/Cameras/camera";
  55162. import { Engine } from "babylonjs/Engines/engine";
  55163. import "babylonjs/Shaders/convolution.fragment";
  55164. /**
  55165. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55166. * input texture to perform effects such as edge detection or sharpening
  55167. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55168. */
  55169. export class ConvolutionPostProcess extends PostProcess {
  55170. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55171. kernel: number[];
  55172. /**
  55173. * Creates a new instance ConvolutionPostProcess
  55174. * @param name The name of the effect.
  55175. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55176. * @param options The required width/height ratio to downsize to before computing the render pass.
  55177. * @param camera The camera to apply the render pass to.
  55178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55179. * @param engine The engine which the post process will be applied. (default: current engine)
  55180. * @param reusable If the post process can be reused on the same frame. (default: false)
  55181. * @param textureType Type of textures used when performing the post process. (default: 0)
  55182. */
  55183. constructor(name: string,
  55184. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55185. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55186. /**
  55187. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55188. */
  55189. static EdgeDetect0Kernel: number[];
  55190. /**
  55191. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55192. */
  55193. static EdgeDetect1Kernel: number[];
  55194. /**
  55195. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55196. */
  55197. static EdgeDetect2Kernel: number[];
  55198. /**
  55199. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55200. */
  55201. static SharpenKernel: number[];
  55202. /**
  55203. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55204. */
  55205. static EmbossKernel: number[];
  55206. /**
  55207. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55208. */
  55209. static GaussianKernel: number[];
  55210. }
  55211. }
  55212. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55213. import { Nullable } from "babylonjs/types";
  55214. import { Vector2 } from "babylonjs/Maths/math";
  55215. import { Camera } from "babylonjs/Cameras/camera";
  55216. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55217. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55218. import { Engine } from "babylonjs/Engines/engine";
  55219. import { Scene } from "babylonjs/scene";
  55220. /**
  55221. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55222. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55223. * based on samples that have a large difference in distance than the center pixel.
  55224. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55225. */
  55226. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55227. direction: Vector2;
  55228. /**
  55229. * Creates a new instance CircleOfConfusionPostProcess
  55230. * @param name The name of the effect.
  55231. * @param scene The scene the effect belongs to.
  55232. * @param direction The direction the blur should be applied.
  55233. * @param kernel The size of the kernel used to blur.
  55234. * @param options The required width/height ratio to downsize to before computing the render pass.
  55235. * @param camera The camera to apply the render pass to.
  55236. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55237. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55239. * @param engine The engine which the post process will be applied. (default: current engine)
  55240. * @param reusable If the post process can be reused on the same frame. (default: false)
  55241. * @param textureType Type of textures used when performing the post process. (default: 0)
  55242. * @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)
  55243. */
  55244. 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);
  55245. }
  55246. }
  55247. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55248. /** @hidden */
  55249. export var depthOfFieldMergePixelShader: {
  55250. name: string;
  55251. shader: string;
  55252. };
  55253. }
  55254. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55255. import { Nullable } from "babylonjs/types";
  55256. import { Camera } from "babylonjs/Cameras/camera";
  55257. import { Effect } from "babylonjs/Materials/effect";
  55258. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55259. import { Engine } from "babylonjs/Engines/engine";
  55260. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55261. /**
  55262. * Options to be set when merging outputs from the default pipeline.
  55263. */
  55264. export class DepthOfFieldMergePostProcessOptions {
  55265. /**
  55266. * The original image to merge on top of
  55267. */
  55268. originalFromInput: PostProcess;
  55269. /**
  55270. * Parameters to perform the merge of the depth of field effect
  55271. */
  55272. depthOfField?: {
  55273. circleOfConfusion: PostProcess;
  55274. blurSteps: Array<PostProcess>;
  55275. };
  55276. /**
  55277. * Parameters to perform the merge of bloom effect
  55278. */
  55279. bloom?: {
  55280. blurred: PostProcess;
  55281. weight: number;
  55282. };
  55283. }
  55284. /**
  55285. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55286. */
  55287. export class DepthOfFieldMergePostProcess extends PostProcess {
  55288. private blurSteps;
  55289. /**
  55290. * Creates a new instance of DepthOfFieldMergePostProcess
  55291. * @param name The name of the effect.
  55292. * @param originalFromInput Post process which's input will be used for the merge.
  55293. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55294. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55295. * @param options The required width/height ratio to downsize to before computing the render pass.
  55296. * @param camera The camera to apply the render pass to.
  55297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55298. * @param engine The engine which the post process will be applied. (default: current engine)
  55299. * @param reusable If the post process can be reused on the same frame. (default: false)
  55300. * @param textureType Type of textures used when performing the post process. (default: 0)
  55301. * @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)
  55302. */
  55303. 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);
  55304. /**
  55305. * Updates the effect with the current post process compile time values and recompiles the shader.
  55306. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55307. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55308. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55309. * @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
  55310. * @param onCompiled Called when the shader has been compiled.
  55311. * @param onError Called if there is an error when compiling a shader.
  55312. */
  55313. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55314. }
  55315. }
  55316. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55317. import { Nullable } from "babylonjs/types";
  55318. import { Camera } from "babylonjs/Cameras/camera";
  55319. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55320. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55321. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55322. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55323. import { Scene } from "babylonjs/scene";
  55324. /**
  55325. * Specifies the level of max blur that should be applied when using the depth of field effect
  55326. */
  55327. export enum DepthOfFieldEffectBlurLevel {
  55328. /**
  55329. * Subtle blur
  55330. */
  55331. Low = 0,
  55332. /**
  55333. * Medium blur
  55334. */
  55335. Medium = 1,
  55336. /**
  55337. * Large blur
  55338. */
  55339. High = 2
  55340. }
  55341. /**
  55342. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55343. */
  55344. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55345. private _circleOfConfusion;
  55346. /**
  55347. * @hidden Internal, blurs from high to low
  55348. */
  55349. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55350. private _depthOfFieldBlurY;
  55351. private _dofMerge;
  55352. /**
  55353. * @hidden Internal post processes in depth of field effect
  55354. */
  55355. _effects: Array<PostProcess>;
  55356. /**
  55357. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55358. */
  55359. focalLength: number;
  55360. /**
  55361. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55362. */
  55363. fStop: number;
  55364. /**
  55365. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55366. */
  55367. focusDistance: number;
  55368. /**
  55369. * 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.
  55370. */
  55371. lensSize: number;
  55372. /**
  55373. * Creates a new instance DepthOfFieldEffect
  55374. * @param scene The scene the effect belongs to.
  55375. * @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.
  55376. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55377. * @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)
  55378. */
  55379. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55380. /**
  55381. * Get the current class name of the current effet
  55382. * @returns "DepthOfFieldEffect"
  55383. */
  55384. getClassName(): string;
  55385. /**
  55386. * 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.
  55387. */
  55388. depthTexture: RenderTargetTexture;
  55389. /**
  55390. * Disposes each of the internal effects for a given camera.
  55391. * @param camera The camera to dispose the effect on.
  55392. */
  55393. disposeEffects(camera: Camera): void;
  55394. /**
  55395. * @hidden Internal
  55396. */
  55397. _updateEffects(): void;
  55398. /**
  55399. * Internal
  55400. * @returns if all the contained post processes are ready.
  55401. * @hidden
  55402. */
  55403. _isReady(): boolean;
  55404. }
  55405. }
  55406. declare module "babylonjs/Shaders/displayPass.fragment" {
  55407. /** @hidden */
  55408. export var displayPassPixelShader: {
  55409. name: string;
  55410. shader: string;
  55411. };
  55412. }
  55413. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55414. import { Nullable } from "babylonjs/types";
  55415. import { Camera } from "babylonjs/Cameras/camera";
  55416. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55417. import { Engine } from "babylonjs/Engines/engine";
  55418. import "babylonjs/Shaders/displayPass.fragment";
  55419. /**
  55420. * DisplayPassPostProcess which produces an output the same as it's input
  55421. */
  55422. export class DisplayPassPostProcess extends PostProcess {
  55423. /**
  55424. * Creates the DisplayPassPostProcess
  55425. * @param name The name of the effect.
  55426. * @param options The required width/height ratio to downsize to before computing the render pass.
  55427. * @param camera The camera to apply the render pass to.
  55428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55429. * @param engine The engine which the post process will be applied. (default: current engine)
  55430. * @param reusable If the post process can be reused on the same frame. (default: false)
  55431. */
  55432. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55433. }
  55434. }
  55435. declare module "babylonjs/Shaders/filter.fragment" {
  55436. /** @hidden */
  55437. export var filterPixelShader: {
  55438. name: string;
  55439. shader: string;
  55440. };
  55441. }
  55442. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55443. import { Nullable } from "babylonjs/types";
  55444. import { Matrix } from "babylonjs/Maths/math";
  55445. import { Camera } from "babylonjs/Cameras/camera";
  55446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55447. import { Engine } from "babylonjs/Engines/engine";
  55448. import "babylonjs/Shaders/filter.fragment";
  55449. /**
  55450. * Applies a kernel filter to the image
  55451. */
  55452. export class FilterPostProcess extends PostProcess {
  55453. /** The matrix to be applied to the image */
  55454. kernelMatrix: Matrix;
  55455. /**
  55456. *
  55457. * @param name The name of the effect.
  55458. * @param kernelMatrix The matrix to be applied to the image
  55459. * @param options The required width/height ratio to downsize to before computing the render pass.
  55460. * @param camera The camera to apply the render pass to.
  55461. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55462. * @param engine The engine which the post process will be applied. (default: current engine)
  55463. * @param reusable If the post process can be reused on the same frame. (default: false)
  55464. */
  55465. constructor(name: string,
  55466. /** The matrix to be applied to the image */
  55467. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55468. }
  55469. }
  55470. declare module "babylonjs/Shaders/fxaa.fragment" {
  55471. /** @hidden */
  55472. export var fxaaPixelShader: {
  55473. name: string;
  55474. shader: string;
  55475. };
  55476. }
  55477. declare module "babylonjs/Shaders/fxaa.vertex" {
  55478. /** @hidden */
  55479. export var fxaaVertexShader: {
  55480. name: string;
  55481. shader: string;
  55482. };
  55483. }
  55484. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55485. import { Nullable } from "babylonjs/types";
  55486. import { Camera } from "babylonjs/Cameras/camera";
  55487. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55488. import { Engine } from "babylonjs/Engines/engine";
  55489. import "babylonjs/Shaders/fxaa.fragment";
  55490. import "babylonjs/Shaders/fxaa.vertex";
  55491. /**
  55492. * Fxaa post process
  55493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55494. */
  55495. export class FxaaPostProcess extends PostProcess {
  55496. /** @hidden */
  55497. texelWidth: number;
  55498. /** @hidden */
  55499. texelHeight: number;
  55500. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55501. private _getDefines;
  55502. }
  55503. }
  55504. declare module "babylonjs/Shaders/grain.fragment" {
  55505. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55506. /** @hidden */
  55507. export var grainPixelShader: {
  55508. name: string;
  55509. shader: string;
  55510. };
  55511. }
  55512. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55513. import { Nullable } from "babylonjs/types";
  55514. import { Camera } from "babylonjs/Cameras/camera";
  55515. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55516. import { Engine } from "babylonjs/Engines/engine";
  55517. import "babylonjs/Shaders/grain.fragment";
  55518. /**
  55519. * The GrainPostProcess adds noise to the image at mid luminance levels
  55520. */
  55521. export class GrainPostProcess extends PostProcess {
  55522. /**
  55523. * The intensity of the grain added (default: 30)
  55524. */
  55525. intensity: number;
  55526. /**
  55527. * If the grain should be randomized on every frame
  55528. */
  55529. animated: boolean;
  55530. /**
  55531. * Creates a new instance of @see GrainPostProcess
  55532. * @param name The name of the effect.
  55533. * @param options The required width/height ratio to downsize to before computing the render pass.
  55534. * @param camera The camera to apply the render pass to.
  55535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55536. * @param engine The engine which the post process will be applied. (default: current engine)
  55537. * @param reusable If the post process can be reused on the same frame. (default: false)
  55538. * @param textureType Type of textures used when performing the post process. (default: 0)
  55539. * @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)
  55540. */
  55541. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55542. }
  55543. }
  55544. declare module "babylonjs/Shaders/highlights.fragment" {
  55545. /** @hidden */
  55546. export var highlightsPixelShader: {
  55547. name: string;
  55548. shader: string;
  55549. };
  55550. }
  55551. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55552. import { Nullable } from "babylonjs/types";
  55553. import { Camera } from "babylonjs/Cameras/camera";
  55554. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55555. import { Engine } from "babylonjs/Engines/engine";
  55556. import "babylonjs/Shaders/highlights.fragment";
  55557. /**
  55558. * Extracts highlights from the image
  55559. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55560. */
  55561. export class HighlightsPostProcess extends PostProcess {
  55562. /**
  55563. * Extracts highlights from the image
  55564. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55565. * @param name The name of the effect.
  55566. * @param options The required width/height ratio to downsize to before computing the render pass.
  55567. * @param camera The camera to apply the render pass to.
  55568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55569. * @param engine The engine which the post process will be applied. (default: current engine)
  55570. * @param reusable If the post process can be reused on the same frame. (default: false)
  55571. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55572. */
  55573. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55574. }
  55575. }
  55576. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55577. /** @hidden */
  55578. export var mrtFragmentDeclaration: {
  55579. name: string;
  55580. shader: string;
  55581. };
  55582. }
  55583. declare module "babylonjs/Shaders/geometry.fragment" {
  55584. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55585. /** @hidden */
  55586. export var geometryPixelShader: {
  55587. name: string;
  55588. shader: string;
  55589. };
  55590. }
  55591. declare module "babylonjs/Shaders/geometry.vertex" {
  55592. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55593. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55594. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55595. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55596. /** @hidden */
  55597. export var geometryVertexShader: {
  55598. name: string;
  55599. shader: string;
  55600. };
  55601. }
  55602. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55603. import { Matrix } from "babylonjs/Maths/math";
  55604. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55605. import { Mesh } from "babylonjs/Meshes/mesh";
  55606. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55607. import { Effect } from "babylonjs/Materials/effect";
  55608. import { Scene } from "babylonjs/scene";
  55609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55610. import "babylonjs/Shaders/geometry.fragment";
  55611. import "babylonjs/Shaders/geometry.vertex";
  55612. /** @hidden */
  55613. interface ISavedTransformationMatrix {
  55614. world: Matrix;
  55615. viewProjection: Matrix;
  55616. }
  55617. /**
  55618. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55619. */
  55620. export class GeometryBufferRenderer {
  55621. /**
  55622. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55623. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55624. */
  55625. static readonly POSITION_TEXTURE_TYPE: number;
  55626. /**
  55627. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55628. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55629. */
  55630. static readonly VELOCITY_TEXTURE_TYPE: number;
  55631. /**
  55632. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55633. * in order to compute objects velocities when enableVelocity is set to "true"
  55634. * @hidden
  55635. */
  55636. _previousTransformationMatrices: {
  55637. [index: number]: ISavedTransformationMatrix;
  55638. };
  55639. /**
  55640. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55641. * in order to compute objects velocities when enableVelocity is set to "true"
  55642. * @hidden
  55643. */
  55644. _previousBonesTransformationMatrices: {
  55645. [index: number]: Float32Array;
  55646. };
  55647. /**
  55648. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55649. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55650. */
  55651. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55652. private _scene;
  55653. private _multiRenderTarget;
  55654. private _ratio;
  55655. private _enablePosition;
  55656. private _enableVelocity;
  55657. private _positionIndex;
  55658. private _velocityIndex;
  55659. protected _effect: Effect;
  55660. protected _cachedDefines: string;
  55661. /**
  55662. * Set the render list (meshes to be rendered) used in the G buffer.
  55663. */
  55664. renderList: Mesh[];
  55665. /**
  55666. * Gets wether or not G buffer are supported by the running hardware.
  55667. * This requires draw buffer supports
  55668. */
  55669. readonly isSupported: boolean;
  55670. /**
  55671. * Returns the index of the given texture type in the G-Buffer textures array
  55672. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55673. * @returns the index of the given texture type in the G-Buffer textures array
  55674. */
  55675. getTextureIndex(textureType: number): number;
  55676. /**
  55677. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55678. */
  55679. /**
  55680. * Sets whether or not objects positions are enabled for the G buffer.
  55681. */
  55682. enablePosition: boolean;
  55683. /**
  55684. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55685. */
  55686. /**
  55687. * Sets wether or not objects velocities are enabled for the G buffer.
  55688. */
  55689. enableVelocity: boolean;
  55690. /**
  55691. * Gets the scene associated with the buffer.
  55692. */
  55693. readonly scene: Scene;
  55694. /**
  55695. * Gets the ratio used by the buffer during its creation.
  55696. * How big is the buffer related to the main canvas.
  55697. */
  55698. readonly ratio: number;
  55699. /** @hidden */
  55700. static _SceneComponentInitialization: (scene: Scene) => void;
  55701. /**
  55702. * Creates a new G Buffer for the scene
  55703. * @param scene The scene the buffer belongs to
  55704. * @param ratio How big is the buffer related to the main canvas.
  55705. */
  55706. constructor(scene: Scene, ratio?: number);
  55707. /**
  55708. * Checks wether everything is ready to render a submesh to the G buffer.
  55709. * @param subMesh the submesh to check readiness for
  55710. * @param useInstances is the mesh drawn using instance or not
  55711. * @returns true if ready otherwise false
  55712. */
  55713. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55714. /**
  55715. * Gets the current underlying G Buffer.
  55716. * @returns the buffer
  55717. */
  55718. getGBuffer(): MultiRenderTarget;
  55719. /**
  55720. * Gets the number of samples used to render the buffer (anti aliasing).
  55721. */
  55722. /**
  55723. * Sets the number of samples used to render the buffer (anti aliasing).
  55724. */
  55725. samples: number;
  55726. /**
  55727. * Disposes the renderer and frees up associated resources.
  55728. */
  55729. dispose(): void;
  55730. protected _createRenderTargets(): void;
  55731. private _copyBonesTransformationMatrices;
  55732. }
  55733. }
  55734. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55735. import { Nullable } from "babylonjs/types";
  55736. import { Scene } from "babylonjs/scene";
  55737. import { ISceneComponent } from "babylonjs/sceneComponent";
  55738. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55739. module "babylonjs/scene" {
  55740. interface Scene {
  55741. /** @hidden (Backing field) */
  55742. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55743. /**
  55744. * Gets or Sets the current geometry buffer associated to the scene.
  55745. */
  55746. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55747. /**
  55748. * Enables a GeometryBufferRender and associates it with the scene
  55749. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55750. * @returns the GeometryBufferRenderer
  55751. */
  55752. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55753. /**
  55754. * Disables the GeometryBufferRender associated with the scene
  55755. */
  55756. disableGeometryBufferRenderer(): void;
  55757. }
  55758. }
  55759. /**
  55760. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55761. * in several rendering techniques.
  55762. */
  55763. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55764. /**
  55765. * The component name helpful to identify the component in the list of scene components.
  55766. */
  55767. readonly name: string;
  55768. /**
  55769. * The scene the component belongs to.
  55770. */
  55771. scene: Scene;
  55772. /**
  55773. * Creates a new instance of the component for the given scene
  55774. * @param scene Defines the scene to register the component in
  55775. */
  55776. constructor(scene: Scene);
  55777. /**
  55778. * Registers the component in a given scene
  55779. */
  55780. register(): void;
  55781. /**
  55782. * Rebuilds the elements related to this component in case of
  55783. * context lost for instance.
  55784. */
  55785. rebuild(): void;
  55786. /**
  55787. * Disposes the component and the associated ressources
  55788. */
  55789. dispose(): void;
  55790. private _gatherRenderTargets;
  55791. }
  55792. }
  55793. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55794. /** @hidden */
  55795. export var motionBlurPixelShader: {
  55796. name: string;
  55797. shader: string;
  55798. };
  55799. }
  55800. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55801. import { Nullable } from "babylonjs/types";
  55802. import { Camera } from "babylonjs/Cameras/camera";
  55803. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55804. import { Scene } from "babylonjs/scene";
  55805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55806. import "babylonjs/Animations/animatable";
  55807. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55808. import "babylonjs/Shaders/motionBlur.fragment";
  55809. import { Engine } from "babylonjs/Engines/engine";
  55810. /**
  55811. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55812. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55813. * As an example, all you have to do is to create the post-process:
  55814. * var mb = new BABYLON.MotionBlurPostProcess(
  55815. * 'mb', // The name of the effect.
  55816. * scene, // The scene containing the objects to blur according to their velocity.
  55817. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55818. * camera // The camera to apply the render pass to.
  55819. * );
  55820. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55821. */
  55822. export class MotionBlurPostProcess extends PostProcess {
  55823. /**
  55824. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55825. */
  55826. motionStrength: number;
  55827. /**
  55828. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55829. */
  55830. /**
  55831. * Sets the number of iterations to be used for motion blur quality
  55832. */
  55833. motionBlurSamples: number;
  55834. private _motionBlurSamples;
  55835. private _geometryBufferRenderer;
  55836. /**
  55837. * Creates a new instance MotionBlurPostProcess
  55838. * @param name The name of the effect.
  55839. * @param scene The scene containing the objects to blur according to their velocity.
  55840. * @param options The required width/height ratio to downsize to before computing the render pass.
  55841. * @param camera The camera to apply the render pass to.
  55842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55843. * @param engine The engine which the post process will be applied. (default: current engine)
  55844. * @param reusable If the post process can be reused on the same frame. (default: false)
  55845. * @param textureType Type of textures used when performing the post process. (default: 0)
  55846. * @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)
  55847. */
  55848. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55849. /**
  55850. * Excludes the given skinned mesh from computing bones velocities.
  55851. * 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.
  55852. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55853. */
  55854. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55855. /**
  55856. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55857. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55858. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55859. */
  55860. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55861. /**
  55862. * Disposes the post process.
  55863. * @param camera The camera to dispose the post process on.
  55864. */
  55865. dispose(camera?: Camera): void;
  55866. }
  55867. }
  55868. declare module "babylonjs/Shaders/refraction.fragment" {
  55869. /** @hidden */
  55870. export var refractionPixelShader: {
  55871. name: string;
  55872. shader: string;
  55873. };
  55874. }
  55875. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55876. import { Color3 } from "babylonjs/Maths/math";
  55877. import { Camera } from "babylonjs/Cameras/camera";
  55878. import { Texture } from "babylonjs/Materials/Textures/texture";
  55879. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55880. import { Engine } from "babylonjs/Engines/engine";
  55881. import "babylonjs/Shaders/refraction.fragment";
  55882. /**
  55883. * Post process which applies a refractin texture
  55884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55885. */
  55886. export class RefractionPostProcess extends PostProcess {
  55887. /** the base color of the refraction (used to taint the rendering) */
  55888. color: Color3;
  55889. /** simulated refraction depth */
  55890. depth: number;
  55891. /** the coefficient of the base color (0 to remove base color tainting) */
  55892. colorLevel: number;
  55893. private _refTexture;
  55894. private _ownRefractionTexture;
  55895. /**
  55896. * Gets or sets the refraction texture
  55897. * Please note that you are responsible for disposing the texture if you set it manually
  55898. */
  55899. refractionTexture: Texture;
  55900. /**
  55901. * Initializes the RefractionPostProcess
  55902. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55903. * @param name The name of the effect.
  55904. * @param refractionTextureUrl Url of the refraction texture to use
  55905. * @param color the base color of the refraction (used to taint the rendering)
  55906. * @param depth simulated refraction depth
  55907. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55908. * @param camera The camera to apply the render pass to.
  55909. * @param options The required width/height ratio to downsize to before computing the render pass.
  55910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55911. * @param engine The engine which the post process will be applied. (default: current engine)
  55912. * @param reusable If the post process can be reused on the same frame. (default: false)
  55913. */
  55914. constructor(name: string, refractionTextureUrl: string,
  55915. /** the base color of the refraction (used to taint the rendering) */
  55916. color: Color3,
  55917. /** simulated refraction depth */
  55918. depth: number,
  55919. /** the coefficient of the base color (0 to remove base color tainting) */
  55920. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55921. /**
  55922. * Disposes of the post process
  55923. * @param camera Camera to dispose post process on
  55924. */
  55925. dispose(camera: Camera): void;
  55926. }
  55927. }
  55928. declare module "babylonjs/Shaders/sharpen.fragment" {
  55929. /** @hidden */
  55930. export var sharpenPixelShader: {
  55931. name: string;
  55932. shader: string;
  55933. };
  55934. }
  55935. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55936. import { Nullable } from "babylonjs/types";
  55937. import { Camera } from "babylonjs/Cameras/camera";
  55938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55939. import "babylonjs/Shaders/sharpen.fragment";
  55940. import { Engine } from "babylonjs/Engines/engine";
  55941. /**
  55942. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55943. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55944. */
  55945. export class SharpenPostProcess extends PostProcess {
  55946. /**
  55947. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55948. */
  55949. colorAmount: number;
  55950. /**
  55951. * How much sharpness should be applied (default: 0.3)
  55952. */
  55953. edgeAmount: number;
  55954. /**
  55955. * Creates a new instance ConvolutionPostProcess
  55956. * @param name The name of the effect.
  55957. * @param options The required width/height ratio to downsize to before computing the render pass.
  55958. * @param camera The camera to apply the render pass to.
  55959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55960. * @param engine The engine which the post process will be applied. (default: current engine)
  55961. * @param reusable If the post process can be reused on the same frame. (default: false)
  55962. * @param textureType Type of textures used when performing the post process. (default: 0)
  55963. * @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)
  55964. */
  55965. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55966. }
  55967. }
  55968. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55969. import { Nullable } from "babylonjs/types";
  55970. import { Camera } from "babylonjs/Cameras/camera";
  55971. import { Engine } from "babylonjs/Engines/engine";
  55972. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55973. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55974. /**
  55975. * PostProcessRenderPipeline
  55976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55977. */
  55978. export class PostProcessRenderPipeline {
  55979. private engine;
  55980. private _renderEffects;
  55981. private _renderEffectsForIsolatedPass;
  55982. /**
  55983. * List of inspectable custom properties (used by the Inspector)
  55984. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55985. */
  55986. inspectableCustomProperties: IInspectable[];
  55987. /**
  55988. * @hidden
  55989. */
  55990. protected _cameras: Camera[];
  55991. /** @hidden */
  55992. _name: string;
  55993. /**
  55994. * Gets pipeline name
  55995. */
  55996. readonly name: string;
  55997. /**
  55998. * Initializes a PostProcessRenderPipeline
  55999. * @param engine engine to add the pipeline to
  56000. * @param name name of the pipeline
  56001. */
  56002. constructor(engine: Engine, name: string);
  56003. /**
  56004. * Gets the class name
  56005. * @returns "PostProcessRenderPipeline"
  56006. */
  56007. getClassName(): string;
  56008. /**
  56009. * If all the render effects in the pipeline are supported
  56010. */
  56011. readonly isSupported: boolean;
  56012. /**
  56013. * Adds an effect to the pipeline
  56014. * @param renderEffect the effect to add
  56015. */
  56016. addEffect(renderEffect: PostProcessRenderEffect): void;
  56017. /** @hidden */
  56018. _rebuild(): void;
  56019. /** @hidden */
  56020. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56021. /** @hidden */
  56022. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56023. /** @hidden */
  56024. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56025. /** @hidden */
  56026. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56027. /** @hidden */
  56028. _attachCameras(cameras: Camera, unique: boolean): void;
  56029. /** @hidden */
  56030. _attachCameras(cameras: Camera[], unique: boolean): void;
  56031. /** @hidden */
  56032. _detachCameras(cameras: Camera): void;
  56033. /** @hidden */
  56034. _detachCameras(cameras: Nullable<Camera[]>): void;
  56035. /** @hidden */
  56036. _update(): void;
  56037. /** @hidden */
  56038. _reset(): void;
  56039. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56040. /**
  56041. * Disposes of the pipeline
  56042. */
  56043. dispose(): void;
  56044. }
  56045. }
  56046. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  56047. import { Camera } from "babylonjs/Cameras/camera";
  56048. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56049. /**
  56050. * PostProcessRenderPipelineManager class
  56051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56052. */
  56053. export class PostProcessRenderPipelineManager {
  56054. private _renderPipelines;
  56055. /**
  56056. * Initializes a PostProcessRenderPipelineManager
  56057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56058. */
  56059. constructor();
  56060. /**
  56061. * Gets the list of supported render pipelines
  56062. */
  56063. readonly supportedPipelines: PostProcessRenderPipeline[];
  56064. /**
  56065. * Adds a pipeline to the manager
  56066. * @param renderPipeline The pipeline to add
  56067. */
  56068. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56069. /**
  56070. * Attaches a camera to the pipeline
  56071. * @param renderPipelineName The name of the pipeline to attach to
  56072. * @param cameras the camera to attach
  56073. * @param unique if the camera can be attached multiple times to the pipeline
  56074. */
  56075. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56076. /**
  56077. * Detaches a camera from the pipeline
  56078. * @param renderPipelineName The name of the pipeline to detach from
  56079. * @param cameras the camera to detach
  56080. */
  56081. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56082. /**
  56083. * Enables an effect by name on a pipeline
  56084. * @param renderPipelineName the name of the pipeline to enable the effect in
  56085. * @param renderEffectName the name of the effect to enable
  56086. * @param cameras the cameras that the effect should be enabled on
  56087. */
  56088. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56089. /**
  56090. * Disables an effect by name on a pipeline
  56091. * @param renderPipelineName the name of the pipeline to disable the effect in
  56092. * @param renderEffectName the name of the effect to disable
  56093. * @param cameras the cameras that the effect should be disabled on
  56094. */
  56095. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56096. /**
  56097. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56098. */
  56099. update(): void;
  56100. /** @hidden */
  56101. _rebuild(): void;
  56102. /**
  56103. * Disposes of the manager and pipelines
  56104. */
  56105. dispose(): void;
  56106. }
  56107. }
  56108. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  56109. import { ISceneComponent } from "babylonjs/sceneComponent";
  56110. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56111. import { Scene } from "babylonjs/scene";
  56112. module "babylonjs/scene" {
  56113. interface Scene {
  56114. /** @hidden (Backing field) */
  56115. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56116. /**
  56117. * Gets the postprocess render pipeline manager
  56118. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56119. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56120. */
  56121. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56122. }
  56123. }
  56124. /**
  56125. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56126. */
  56127. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56128. /**
  56129. * The component name helpfull to identify the component in the list of scene components.
  56130. */
  56131. readonly name: string;
  56132. /**
  56133. * The scene the component belongs to.
  56134. */
  56135. scene: Scene;
  56136. /**
  56137. * Creates a new instance of the component for the given scene
  56138. * @param scene Defines the scene to register the component in
  56139. */
  56140. constructor(scene: Scene);
  56141. /**
  56142. * Registers the component in a given scene
  56143. */
  56144. register(): void;
  56145. /**
  56146. * Rebuilds the elements related to this component in case of
  56147. * context lost for instance.
  56148. */
  56149. rebuild(): void;
  56150. /**
  56151. * Disposes the component and the associated ressources
  56152. */
  56153. dispose(): void;
  56154. private _gatherRenderTargets;
  56155. }
  56156. }
  56157. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56158. import { Nullable } from "babylonjs/types";
  56159. import { IAnimatable } from "babylonjs/Misc/tools";
  56160. import { Camera } from "babylonjs/Cameras/camera";
  56161. import { IDisposable } from "babylonjs/scene";
  56162. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  56163. import { Scene } from "babylonjs/scene";
  56164. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56165. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56166. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56167. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56168. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56169. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56170. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56171. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56172. import { Animation } from "babylonjs/Animations/animation";
  56173. /**
  56174. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56175. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56176. */
  56177. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56178. private _scene;
  56179. private _camerasToBeAttached;
  56180. /**
  56181. * ID of the sharpen post process,
  56182. */
  56183. private readonly SharpenPostProcessId;
  56184. /**
  56185. * @ignore
  56186. * ID of the image processing post process;
  56187. */
  56188. readonly ImageProcessingPostProcessId: string;
  56189. /**
  56190. * @ignore
  56191. * ID of the Fast Approximate Anti-Aliasing post process;
  56192. */
  56193. readonly FxaaPostProcessId: string;
  56194. /**
  56195. * ID of the chromatic aberration post process,
  56196. */
  56197. private readonly ChromaticAberrationPostProcessId;
  56198. /**
  56199. * ID of the grain post process
  56200. */
  56201. private readonly GrainPostProcessId;
  56202. /**
  56203. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56204. */
  56205. sharpen: SharpenPostProcess;
  56206. private _sharpenEffect;
  56207. private bloom;
  56208. /**
  56209. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56210. */
  56211. depthOfField: DepthOfFieldEffect;
  56212. /**
  56213. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56214. */
  56215. fxaa: FxaaPostProcess;
  56216. /**
  56217. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56218. */
  56219. imageProcessing: ImageProcessingPostProcess;
  56220. /**
  56221. * Chromatic aberration post process which will shift rgb colors in the image
  56222. */
  56223. chromaticAberration: ChromaticAberrationPostProcess;
  56224. private _chromaticAberrationEffect;
  56225. /**
  56226. * Grain post process which add noise to the image
  56227. */
  56228. grain: GrainPostProcess;
  56229. private _grainEffect;
  56230. /**
  56231. * Glow post process which adds a glow to emissive areas of the image
  56232. */
  56233. private _glowLayer;
  56234. /**
  56235. * Animations which can be used to tweak settings over a period of time
  56236. */
  56237. animations: Animation[];
  56238. private _imageProcessingConfigurationObserver;
  56239. private _sharpenEnabled;
  56240. private _bloomEnabled;
  56241. private _depthOfFieldEnabled;
  56242. private _depthOfFieldBlurLevel;
  56243. private _fxaaEnabled;
  56244. private _imageProcessingEnabled;
  56245. private _defaultPipelineTextureType;
  56246. private _bloomScale;
  56247. private _chromaticAberrationEnabled;
  56248. private _grainEnabled;
  56249. private _buildAllowed;
  56250. /**
  56251. * Gets active scene
  56252. */
  56253. readonly scene: Scene;
  56254. /**
  56255. * Enable or disable the sharpen process from the pipeline
  56256. */
  56257. sharpenEnabled: boolean;
  56258. private _resizeObserver;
  56259. private _hardwareScaleLevel;
  56260. private _bloomKernel;
  56261. /**
  56262. * Specifies the size of the bloom blur kernel, relative to the final output size
  56263. */
  56264. bloomKernel: number;
  56265. /**
  56266. * Specifies the weight of the bloom in the final rendering
  56267. */
  56268. private _bloomWeight;
  56269. /**
  56270. * Specifies the luma threshold for the area that will be blurred by the bloom
  56271. */
  56272. private _bloomThreshold;
  56273. private _hdr;
  56274. /**
  56275. * The strength of the bloom.
  56276. */
  56277. bloomWeight: number;
  56278. /**
  56279. * The strength of the bloom.
  56280. */
  56281. bloomThreshold: number;
  56282. /**
  56283. * The scale of the bloom, lower value will provide better performance.
  56284. */
  56285. bloomScale: number;
  56286. /**
  56287. * Enable or disable the bloom from the pipeline
  56288. */
  56289. bloomEnabled: boolean;
  56290. private _rebuildBloom;
  56291. /**
  56292. * If the depth of field is enabled.
  56293. */
  56294. depthOfFieldEnabled: boolean;
  56295. /**
  56296. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56297. */
  56298. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56299. /**
  56300. * If the anti aliasing is enabled.
  56301. */
  56302. fxaaEnabled: boolean;
  56303. private _samples;
  56304. /**
  56305. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56306. */
  56307. samples: number;
  56308. /**
  56309. * If image processing is enabled.
  56310. */
  56311. imageProcessingEnabled: boolean;
  56312. /**
  56313. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56314. */
  56315. glowLayerEnabled: boolean;
  56316. /**
  56317. * Gets the glow layer (or null if not defined)
  56318. */
  56319. readonly glowLayer: Nullable<GlowLayer>;
  56320. /**
  56321. * Enable or disable the chromaticAberration process from the pipeline
  56322. */
  56323. chromaticAberrationEnabled: boolean;
  56324. /**
  56325. * Enable or disable the grain process from the pipeline
  56326. */
  56327. grainEnabled: boolean;
  56328. /**
  56329. * @constructor
  56330. * @param name - The rendering pipeline name (default: "")
  56331. * @param hdr - If high dynamic range textures should be used (default: true)
  56332. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56333. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56334. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56335. */
  56336. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56337. /**
  56338. * Get the class name
  56339. * @returns "DefaultRenderingPipeline"
  56340. */
  56341. getClassName(): string;
  56342. /**
  56343. * Force the compilation of the entire pipeline.
  56344. */
  56345. prepare(): void;
  56346. private _hasCleared;
  56347. private _prevPostProcess;
  56348. private _prevPrevPostProcess;
  56349. private _setAutoClearAndTextureSharing;
  56350. private _depthOfFieldSceneObserver;
  56351. private _buildPipeline;
  56352. private _disposePostProcesses;
  56353. /**
  56354. * Adds a camera to the pipeline
  56355. * @param camera the camera to be added
  56356. */
  56357. addCamera(camera: Camera): void;
  56358. /**
  56359. * Removes a camera from the pipeline
  56360. * @param camera the camera to remove
  56361. */
  56362. removeCamera(camera: Camera): void;
  56363. /**
  56364. * Dispose of the pipeline and stop all post processes
  56365. */
  56366. dispose(): void;
  56367. /**
  56368. * Serialize the rendering pipeline (Used when exporting)
  56369. * @returns the serialized object
  56370. */
  56371. serialize(): any;
  56372. /**
  56373. * Parse the serialized pipeline
  56374. * @param source Source pipeline.
  56375. * @param scene The scene to load the pipeline to.
  56376. * @param rootUrl The URL of the serialized pipeline.
  56377. * @returns An instantiated pipeline from the serialized object.
  56378. */
  56379. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56380. }
  56381. }
  56382. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56383. /** @hidden */
  56384. export var lensHighlightsPixelShader: {
  56385. name: string;
  56386. shader: string;
  56387. };
  56388. }
  56389. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56390. /** @hidden */
  56391. export var depthOfFieldPixelShader: {
  56392. name: string;
  56393. shader: string;
  56394. };
  56395. }
  56396. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56397. import { Camera } from "babylonjs/Cameras/camera";
  56398. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56399. import { Scene } from "babylonjs/scene";
  56400. import "babylonjs/Shaders/chromaticAberration.fragment";
  56401. import "babylonjs/Shaders/lensHighlights.fragment";
  56402. import "babylonjs/Shaders/depthOfField.fragment";
  56403. /**
  56404. * BABYLON.JS Chromatic Aberration GLSL Shader
  56405. * Author: Olivier Guyot
  56406. * Separates very slightly R, G and B colors on the edges of the screen
  56407. * Inspired by Francois Tarlier & Martins Upitis
  56408. */
  56409. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56410. /**
  56411. * @ignore
  56412. * The chromatic aberration PostProcess id in the pipeline
  56413. */
  56414. LensChromaticAberrationEffect: string;
  56415. /**
  56416. * @ignore
  56417. * The highlights enhancing PostProcess id in the pipeline
  56418. */
  56419. HighlightsEnhancingEffect: string;
  56420. /**
  56421. * @ignore
  56422. * The depth-of-field PostProcess id in the pipeline
  56423. */
  56424. LensDepthOfFieldEffect: string;
  56425. private _scene;
  56426. private _depthTexture;
  56427. private _grainTexture;
  56428. private _chromaticAberrationPostProcess;
  56429. private _highlightsPostProcess;
  56430. private _depthOfFieldPostProcess;
  56431. private _edgeBlur;
  56432. private _grainAmount;
  56433. private _chromaticAberration;
  56434. private _distortion;
  56435. private _highlightsGain;
  56436. private _highlightsThreshold;
  56437. private _dofDistance;
  56438. private _dofAperture;
  56439. private _dofDarken;
  56440. private _dofPentagon;
  56441. private _blurNoise;
  56442. /**
  56443. * @constructor
  56444. *
  56445. * Effect parameters are as follow:
  56446. * {
  56447. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56448. * edge_blur: number; // from 0 to x (1 for realism)
  56449. * distortion: number; // from 0 to x (1 for realism)
  56450. * grain_amount: number; // from 0 to 1
  56451. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56452. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56453. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56454. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56455. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56456. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56457. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56458. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56459. * }
  56460. * Note: if an effect parameter is unset, effect is disabled
  56461. *
  56462. * @param name The rendering pipeline name
  56463. * @param parameters - An object containing all parameters (see above)
  56464. * @param scene The scene linked to this pipeline
  56465. * @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)
  56466. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56467. */
  56468. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56469. /**
  56470. * Get the class name
  56471. * @returns "LensRenderingPipeline"
  56472. */
  56473. getClassName(): string;
  56474. /**
  56475. * Gets associated scene
  56476. */
  56477. readonly scene: Scene;
  56478. /**
  56479. * Gets or sets the edge blur
  56480. */
  56481. edgeBlur: number;
  56482. /**
  56483. * Gets or sets the grain amount
  56484. */
  56485. grainAmount: number;
  56486. /**
  56487. * Gets or sets the chromatic aberration amount
  56488. */
  56489. chromaticAberration: number;
  56490. /**
  56491. * Gets or sets the depth of field aperture
  56492. */
  56493. dofAperture: number;
  56494. /**
  56495. * Gets or sets the edge distortion
  56496. */
  56497. edgeDistortion: number;
  56498. /**
  56499. * Gets or sets the depth of field distortion
  56500. */
  56501. dofDistortion: number;
  56502. /**
  56503. * Gets or sets the darken out of focus amount
  56504. */
  56505. darkenOutOfFocus: number;
  56506. /**
  56507. * Gets or sets a boolean indicating if blur noise is enabled
  56508. */
  56509. blurNoise: boolean;
  56510. /**
  56511. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56512. */
  56513. pentagonBokeh: boolean;
  56514. /**
  56515. * Gets or sets the highlight grain amount
  56516. */
  56517. highlightsGain: number;
  56518. /**
  56519. * Gets or sets the highlight threshold
  56520. */
  56521. highlightsThreshold: number;
  56522. /**
  56523. * Sets the amount of blur at the edges
  56524. * @param amount blur amount
  56525. */
  56526. setEdgeBlur(amount: number): void;
  56527. /**
  56528. * Sets edge blur to 0
  56529. */
  56530. disableEdgeBlur(): void;
  56531. /**
  56532. * Sets the amout of grain
  56533. * @param amount Amount of grain
  56534. */
  56535. setGrainAmount(amount: number): void;
  56536. /**
  56537. * Set grain amount to 0
  56538. */
  56539. disableGrain(): void;
  56540. /**
  56541. * Sets the chromatic aberration amount
  56542. * @param amount amount of chromatic aberration
  56543. */
  56544. setChromaticAberration(amount: number): void;
  56545. /**
  56546. * Sets chromatic aberration amount to 0
  56547. */
  56548. disableChromaticAberration(): void;
  56549. /**
  56550. * Sets the EdgeDistortion amount
  56551. * @param amount amount of EdgeDistortion
  56552. */
  56553. setEdgeDistortion(amount: number): void;
  56554. /**
  56555. * Sets edge distortion to 0
  56556. */
  56557. disableEdgeDistortion(): void;
  56558. /**
  56559. * Sets the FocusDistance amount
  56560. * @param amount amount of FocusDistance
  56561. */
  56562. setFocusDistance(amount: number): void;
  56563. /**
  56564. * Disables depth of field
  56565. */
  56566. disableDepthOfField(): void;
  56567. /**
  56568. * Sets the Aperture amount
  56569. * @param amount amount of Aperture
  56570. */
  56571. setAperture(amount: number): void;
  56572. /**
  56573. * Sets the DarkenOutOfFocus amount
  56574. * @param amount amount of DarkenOutOfFocus
  56575. */
  56576. setDarkenOutOfFocus(amount: number): void;
  56577. private _pentagonBokehIsEnabled;
  56578. /**
  56579. * Creates a pentagon bokeh effect
  56580. */
  56581. enablePentagonBokeh(): void;
  56582. /**
  56583. * Disables the pentagon bokeh effect
  56584. */
  56585. disablePentagonBokeh(): void;
  56586. /**
  56587. * Enables noise blur
  56588. */
  56589. enableNoiseBlur(): void;
  56590. /**
  56591. * Disables noise blur
  56592. */
  56593. disableNoiseBlur(): void;
  56594. /**
  56595. * Sets the HighlightsGain amount
  56596. * @param amount amount of HighlightsGain
  56597. */
  56598. setHighlightsGain(amount: number): void;
  56599. /**
  56600. * Sets the HighlightsThreshold amount
  56601. * @param amount amount of HighlightsThreshold
  56602. */
  56603. setHighlightsThreshold(amount: number): void;
  56604. /**
  56605. * Disables highlights
  56606. */
  56607. disableHighlights(): void;
  56608. /**
  56609. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56610. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56611. */
  56612. dispose(disableDepthRender?: boolean): void;
  56613. private _createChromaticAberrationPostProcess;
  56614. private _createHighlightsPostProcess;
  56615. private _createDepthOfFieldPostProcess;
  56616. private _createGrainTexture;
  56617. }
  56618. }
  56619. declare module "babylonjs/Shaders/ssao2.fragment" {
  56620. /** @hidden */
  56621. export var ssao2PixelShader: {
  56622. name: string;
  56623. shader: string;
  56624. };
  56625. }
  56626. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56627. /** @hidden */
  56628. export var ssaoCombinePixelShader: {
  56629. name: string;
  56630. shader: string;
  56631. };
  56632. }
  56633. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56634. import { Camera } from "babylonjs/Cameras/camera";
  56635. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56636. import { Scene } from "babylonjs/scene";
  56637. import "babylonjs/Shaders/ssao2.fragment";
  56638. import "babylonjs/Shaders/ssaoCombine.fragment";
  56639. /**
  56640. * Render pipeline to produce ssao effect
  56641. */
  56642. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56643. /**
  56644. * @ignore
  56645. * The PassPostProcess id in the pipeline that contains the original scene color
  56646. */
  56647. SSAOOriginalSceneColorEffect: string;
  56648. /**
  56649. * @ignore
  56650. * The SSAO PostProcess id in the pipeline
  56651. */
  56652. SSAORenderEffect: string;
  56653. /**
  56654. * @ignore
  56655. * The horizontal blur PostProcess id in the pipeline
  56656. */
  56657. SSAOBlurHRenderEffect: string;
  56658. /**
  56659. * @ignore
  56660. * The vertical blur PostProcess id in the pipeline
  56661. */
  56662. SSAOBlurVRenderEffect: string;
  56663. /**
  56664. * @ignore
  56665. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56666. */
  56667. SSAOCombineRenderEffect: string;
  56668. /**
  56669. * The output strength of the SSAO post-process. Default value is 1.0.
  56670. */
  56671. totalStrength: number;
  56672. /**
  56673. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56674. */
  56675. maxZ: number;
  56676. /**
  56677. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56678. */
  56679. minZAspect: number;
  56680. private _samples;
  56681. /**
  56682. * Number of samples used for the SSAO calculations. Default value is 8
  56683. */
  56684. samples: number;
  56685. private _textureSamples;
  56686. /**
  56687. * Number of samples to use for antialiasing
  56688. */
  56689. textureSamples: number;
  56690. /**
  56691. * Ratio object used for SSAO ratio and blur ratio
  56692. */
  56693. private _ratio;
  56694. /**
  56695. * Dynamically generated sphere sampler.
  56696. */
  56697. private _sampleSphere;
  56698. /**
  56699. * Blur filter offsets
  56700. */
  56701. private _samplerOffsets;
  56702. private _expensiveBlur;
  56703. /**
  56704. * If bilateral blur should be used
  56705. */
  56706. expensiveBlur: boolean;
  56707. /**
  56708. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56709. */
  56710. radius: number;
  56711. /**
  56712. * The base color of the SSAO post-process
  56713. * The final result is "base + ssao" between [0, 1]
  56714. */
  56715. base: number;
  56716. /**
  56717. * Support test.
  56718. */
  56719. static readonly IsSupported: boolean;
  56720. private _scene;
  56721. private _depthTexture;
  56722. private _normalTexture;
  56723. private _randomTexture;
  56724. private _originalColorPostProcess;
  56725. private _ssaoPostProcess;
  56726. private _blurHPostProcess;
  56727. private _blurVPostProcess;
  56728. private _ssaoCombinePostProcess;
  56729. private _firstUpdate;
  56730. /**
  56731. * Gets active scene
  56732. */
  56733. readonly scene: Scene;
  56734. /**
  56735. * @constructor
  56736. * @param name The rendering pipeline name
  56737. * @param scene The scene linked to this pipeline
  56738. * @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 }
  56739. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56740. */
  56741. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56742. /**
  56743. * Get the class name
  56744. * @returns "SSAO2RenderingPipeline"
  56745. */
  56746. getClassName(): string;
  56747. /**
  56748. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56749. */
  56750. dispose(disableGeometryBufferRenderer?: boolean): void;
  56751. private _createBlurPostProcess;
  56752. /** @hidden */
  56753. _rebuild(): void;
  56754. private _bits;
  56755. private _radicalInverse_VdC;
  56756. private _hammersley;
  56757. private _hemisphereSample_uniform;
  56758. private _generateHemisphere;
  56759. private _createSSAOPostProcess;
  56760. private _createSSAOCombinePostProcess;
  56761. private _createRandomTexture;
  56762. /**
  56763. * Serialize the rendering pipeline (Used when exporting)
  56764. * @returns the serialized object
  56765. */
  56766. serialize(): any;
  56767. /**
  56768. * Parse the serialized pipeline
  56769. * @param source Source pipeline.
  56770. * @param scene The scene to load the pipeline to.
  56771. * @param rootUrl The URL of the serialized pipeline.
  56772. * @returns An instantiated pipeline from the serialized object.
  56773. */
  56774. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56775. }
  56776. }
  56777. declare module "babylonjs/Shaders/ssao.fragment" {
  56778. /** @hidden */
  56779. export var ssaoPixelShader: {
  56780. name: string;
  56781. shader: string;
  56782. };
  56783. }
  56784. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56785. import { Camera } from "babylonjs/Cameras/camera";
  56786. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56787. import { Scene } from "babylonjs/scene";
  56788. import "babylonjs/Shaders/ssao.fragment";
  56789. import "babylonjs/Shaders/ssaoCombine.fragment";
  56790. /**
  56791. * Render pipeline to produce ssao effect
  56792. */
  56793. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56794. /**
  56795. * @ignore
  56796. * The PassPostProcess id in the pipeline that contains the original scene color
  56797. */
  56798. SSAOOriginalSceneColorEffect: string;
  56799. /**
  56800. * @ignore
  56801. * The SSAO PostProcess id in the pipeline
  56802. */
  56803. SSAORenderEffect: string;
  56804. /**
  56805. * @ignore
  56806. * The horizontal blur PostProcess id in the pipeline
  56807. */
  56808. SSAOBlurHRenderEffect: string;
  56809. /**
  56810. * @ignore
  56811. * The vertical blur PostProcess id in the pipeline
  56812. */
  56813. SSAOBlurVRenderEffect: string;
  56814. /**
  56815. * @ignore
  56816. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56817. */
  56818. SSAOCombineRenderEffect: string;
  56819. /**
  56820. * The output strength of the SSAO post-process. Default value is 1.0.
  56821. */
  56822. totalStrength: number;
  56823. /**
  56824. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56825. */
  56826. radius: number;
  56827. /**
  56828. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56829. * Must not be equal to fallOff and superior to fallOff.
  56830. * Default value is 0.0075
  56831. */
  56832. area: number;
  56833. /**
  56834. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56835. * Must not be equal to area and inferior to area.
  56836. * Default value is 0.000001
  56837. */
  56838. fallOff: number;
  56839. /**
  56840. * The base color of the SSAO post-process
  56841. * The final result is "base + ssao" between [0, 1]
  56842. */
  56843. base: number;
  56844. private _scene;
  56845. private _depthTexture;
  56846. private _randomTexture;
  56847. private _originalColorPostProcess;
  56848. private _ssaoPostProcess;
  56849. private _blurHPostProcess;
  56850. private _blurVPostProcess;
  56851. private _ssaoCombinePostProcess;
  56852. private _firstUpdate;
  56853. /**
  56854. * Gets active scene
  56855. */
  56856. readonly scene: Scene;
  56857. /**
  56858. * @constructor
  56859. * @param name - The rendering pipeline name
  56860. * @param scene - The scene linked to this pipeline
  56861. * @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 }
  56862. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56863. */
  56864. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56865. /**
  56866. * Get the class name
  56867. * @returns "SSAORenderingPipeline"
  56868. */
  56869. getClassName(): string;
  56870. /**
  56871. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56872. */
  56873. dispose(disableDepthRender?: boolean): void;
  56874. private _createBlurPostProcess;
  56875. /** @hidden */
  56876. _rebuild(): void;
  56877. private _createSSAOPostProcess;
  56878. private _createSSAOCombinePostProcess;
  56879. private _createRandomTexture;
  56880. }
  56881. }
  56882. declare module "babylonjs/Shaders/standard.fragment" {
  56883. /** @hidden */
  56884. export var standardPixelShader: {
  56885. name: string;
  56886. shader: string;
  56887. };
  56888. }
  56889. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56890. import { Nullable } from "babylonjs/types";
  56891. import { IAnimatable } from "babylonjs/Misc/tools";
  56892. import { Camera } from "babylonjs/Cameras/camera";
  56893. import { Texture } from "babylonjs/Materials/Textures/texture";
  56894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56895. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56896. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56897. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56898. import { IDisposable } from "babylonjs/scene";
  56899. import { SpotLight } from "babylonjs/Lights/spotLight";
  56900. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56901. import { Scene } from "babylonjs/scene";
  56902. import { Animation } from "babylonjs/Animations/animation";
  56903. import "babylonjs/Shaders/standard.fragment";
  56904. /**
  56905. * Standard rendering pipeline
  56906. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56907. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56908. */
  56909. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56910. /**
  56911. * Public members
  56912. */
  56913. /**
  56914. * Post-process which contains the original scene color before the pipeline applies all the effects
  56915. */
  56916. originalPostProcess: Nullable<PostProcess>;
  56917. /**
  56918. * Post-process used to down scale an image x4
  56919. */
  56920. downSampleX4PostProcess: Nullable<PostProcess>;
  56921. /**
  56922. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56923. */
  56924. brightPassPostProcess: Nullable<PostProcess>;
  56925. /**
  56926. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56927. */
  56928. blurHPostProcesses: PostProcess[];
  56929. /**
  56930. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56931. */
  56932. blurVPostProcesses: PostProcess[];
  56933. /**
  56934. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56935. */
  56936. textureAdderPostProcess: Nullable<PostProcess>;
  56937. /**
  56938. * Post-process used to create volumetric lighting effect
  56939. */
  56940. volumetricLightPostProcess: Nullable<PostProcess>;
  56941. /**
  56942. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56943. */
  56944. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56945. /**
  56946. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56947. */
  56948. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56949. /**
  56950. * Post-process used to merge the volumetric light effect and the real scene color
  56951. */
  56952. volumetricLightMergePostProces: Nullable<PostProcess>;
  56953. /**
  56954. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56955. */
  56956. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56957. /**
  56958. * Base post-process used to calculate the average luminance of the final image for HDR
  56959. */
  56960. luminancePostProcess: Nullable<PostProcess>;
  56961. /**
  56962. * Post-processes used to create down sample post-processes in order to get
  56963. * the average luminance of the final image for HDR
  56964. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56965. */
  56966. luminanceDownSamplePostProcesses: PostProcess[];
  56967. /**
  56968. * Post-process used to create a HDR effect (light adaptation)
  56969. */
  56970. hdrPostProcess: Nullable<PostProcess>;
  56971. /**
  56972. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56973. */
  56974. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56975. /**
  56976. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56977. */
  56978. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56979. /**
  56980. * Post-process used to merge the final HDR post-process and the real scene color
  56981. */
  56982. hdrFinalPostProcess: Nullable<PostProcess>;
  56983. /**
  56984. * Post-process used to create a lens flare effect
  56985. */
  56986. lensFlarePostProcess: Nullable<PostProcess>;
  56987. /**
  56988. * Post-process that merges the result of the lens flare post-process and the real scene color
  56989. */
  56990. lensFlareComposePostProcess: Nullable<PostProcess>;
  56991. /**
  56992. * Post-process used to create a motion blur effect
  56993. */
  56994. motionBlurPostProcess: Nullable<PostProcess>;
  56995. /**
  56996. * Post-process used to create a depth of field effect
  56997. */
  56998. depthOfFieldPostProcess: Nullable<PostProcess>;
  56999. /**
  57000. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57001. */
  57002. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57003. /**
  57004. * Represents the brightness threshold in order to configure the illuminated surfaces
  57005. */
  57006. brightThreshold: number;
  57007. /**
  57008. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57009. */
  57010. blurWidth: number;
  57011. /**
  57012. * Sets if the blur for highlighted surfaces must be only horizontal
  57013. */
  57014. horizontalBlur: boolean;
  57015. /**
  57016. * Gets the overall exposure used by the pipeline
  57017. */
  57018. /**
  57019. * Sets the overall exposure used by the pipeline
  57020. */
  57021. exposure: number;
  57022. /**
  57023. * Texture used typically to simulate "dirty" on camera lens
  57024. */
  57025. lensTexture: Nullable<Texture>;
  57026. /**
  57027. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57028. */
  57029. volumetricLightCoefficient: number;
  57030. /**
  57031. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57032. */
  57033. volumetricLightPower: number;
  57034. /**
  57035. * Used the set the blur intensity to smooth the volumetric lights
  57036. */
  57037. volumetricLightBlurScale: number;
  57038. /**
  57039. * Light (spot or directional) used to generate the volumetric lights rays
  57040. * The source light must have a shadow generate so the pipeline can get its
  57041. * depth map
  57042. */
  57043. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57044. /**
  57045. * For eye adaptation, represents the minimum luminance the eye can see
  57046. */
  57047. hdrMinimumLuminance: number;
  57048. /**
  57049. * For eye adaptation, represents the decrease luminance speed
  57050. */
  57051. hdrDecreaseRate: number;
  57052. /**
  57053. * For eye adaptation, represents the increase luminance speed
  57054. */
  57055. hdrIncreaseRate: number;
  57056. /**
  57057. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57058. */
  57059. /**
  57060. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57061. */
  57062. hdrAutoExposure: boolean;
  57063. /**
  57064. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57065. */
  57066. lensColorTexture: Nullable<Texture>;
  57067. /**
  57068. * The overall strengh for the lens flare effect
  57069. */
  57070. lensFlareStrength: number;
  57071. /**
  57072. * Dispersion coefficient for lens flare ghosts
  57073. */
  57074. lensFlareGhostDispersal: number;
  57075. /**
  57076. * Main lens flare halo width
  57077. */
  57078. lensFlareHaloWidth: number;
  57079. /**
  57080. * Based on the lens distortion effect, defines how much the lens flare result
  57081. * is distorted
  57082. */
  57083. lensFlareDistortionStrength: number;
  57084. /**
  57085. * Lens star texture must be used to simulate rays on the flares and is available
  57086. * in the documentation
  57087. */
  57088. lensStarTexture: Nullable<Texture>;
  57089. /**
  57090. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57091. * flare effect by taking account of the dirt texture
  57092. */
  57093. lensFlareDirtTexture: Nullable<Texture>;
  57094. /**
  57095. * Represents the focal length for the depth of field effect
  57096. */
  57097. depthOfFieldDistance: number;
  57098. /**
  57099. * Represents the blur intensity for the blurred part of the depth of field effect
  57100. */
  57101. depthOfFieldBlurWidth: number;
  57102. /**
  57103. * For motion blur, defines how much the image is blurred by the movement
  57104. */
  57105. motionStrength: number;
  57106. /**
  57107. * List of animations for the pipeline (IAnimatable implementation)
  57108. */
  57109. animations: Animation[];
  57110. /**
  57111. * Private members
  57112. */
  57113. private _scene;
  57114. private _currentDepthOfFieldSource;
  57115. private _basePostProcess;
  57116. private _fixedExposure;
  57117. private _currentExposure;
  57118. private _hdrAutoExposure;
  57119. private _hdrCurrentLuminance;
  57120. private _floatTextureType;
  57121. private _ratio;
  57122. private _bloomEnabled;
  57123. private _depthOfFieldEnabled;
  57124. private _vlsEnabled;
  57125. private _lensFlareEnabled;
  57126. private _hdrEnabled;
  57127. private _motionBlurEnabled;
  57128. private _fxaaEnabled;
  57129. private _motionBlurSamples;
  57130. private _volumetricLightStepsCount;
  57131. private _samples;
  57132. /**
  57133. * @ignore
  57134. * Specifies if the bloom pipeline is enabled
  57135. */
  57136. BloomEnabled: boolean;
  57137. /**
  57138. * @ignore
  57139. * Specifies if the depth of field pipeline is enabed
  57140. */
  57141. DepthOfFieldEnabled: boolean;
  57142. /**
  57143. * @ignore
  57144. * Specifies if the lens flare pipeline is enabed
  57145. */
  57146. LensFlareEnabled: boolean;
  57147. /**
  57148. * @ignore
  57149. * Specifies if the HDR pipeline is enabled
  57150. */
  57151. HDREnabled: boolean;
  57152. /**
  57153. * @ignore
  57154. * Specifies if the volumetric lights scattering effect is enabled
  57155. */
  57156. VLSEnabled: boolean;
  57157. /**
  57158. * @ignore
  57159. * Specifies if the motion blur effect is enabled
  57160. */
  57161. MotionBlurEnabled: boolean;
  57162. /**
  57163. * Specifies if anti-aliasing is enabled
  57164. */
  57165. fxaaEnabled: boolean;
  57166. /**
  57167. * Specifies the number of steps used to calculate the volumetric lights
  57168. * Typically in interval [50, 200]
  57169. */
  57170. volumetricLightStepsCount: number;
  57171. /**
  57172. * Specifies the number of samples used for the motion blur effect
  57173. * Typically in interval [16, 64]
  57174. */
  57175. motionBlurSamples: number;
  57176. /**
  57177. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57178. */
  57179. samples: number;
  57180. /**
  57181. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57182. * @constructor
  57183. * @param name The rendering pipeline name
  57184. * @param scene The scene linked to this pipeline
  57185. * @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)
  57186. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57187. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57188. */
  57189. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57190. private _buildPipeline;
  57191. private _createDownSampleX4PostProcess;
  57192. private _createBrightPassPostProcess;
  57193. private _createBlurPostProcesses;
  57194. private _createTextureAdderPostProcess;
  57195. private _createVolumetricLightPostProcess;
  57196. private _createLuminancePostProcesses;
  57197. private _createHdrPostProcess;
  57198. private _createLensFlarePostProcess;
  57199. private _createDepthOfFieldPostProcess;
  57200. private _createMotionBlurPostProcess;
  57201. private _getDepthTexture;
  57202. private _disposePostProcesses;
  57203. /**
  57204. * Dispose of the pipeline and stop all post processes
  57205. */
  57206. dispose(): void;
  57207. /**
  57208. * Serialize the rendering pipeline (Used when exporting)
  57209. * @returns the serialized object
  57210. */
  57211. serialize(): any;
  57212. /**
  57213. * Parse the serialized pipeline
  57214. * @param source Source pipeline.
  57215. * @param scene The scene to load the pipeline to.
  57216. * @param rootUrl The URL of the serialized pipeline.
  57217. * @returns An instantiated pipeline from the serialized object.
  57218. */
  57219. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57220. /**
  57221. * Luminance steps
  57222. */
  57223. static LuminanceSteps: number;
  57224. }
  57225. }
  57226. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57227. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57228. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57229. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57230. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57231. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57232. }
  57233. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57234. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57235. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57236. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57237. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57238. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57239. }
  57240. declare module "babylonjs/Shaders/tonemap.fragment" {
  57241. /** @hidden */
  57242. export var tonemapPixelShader: {
  57243. name: string;
  57244. shader: string;
  57245. };
  57246. }
  57247. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57248. import { Camera } from "babylonjs/Cameras/camera";
  57249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57250. import "babylonjs/Shaders/tonemap.fragment";
  57251. import { Engine } from "babylonjs/Engines/engine";
  57252. /** Defines operator used for tonemapping */
  57253. export enum TonemappingOperator {
  57254. /** Hable */
  57255. Hable = 0,
  57256. /** Reinhard */
  57257. Reinhard = 1,
  57258. /** HejiDawson */
  57259. HejiDawson = 2,
  57260. /** Photographic */
  57261. Photographic = 3
  57262. }
  57263. /**
  57264. * Defines a post process to apply tone mapping
  57265. */
  57266. export class TonemapPostProcess extends PostProcess {
  57267. private _operator;
  57268. /** Defines the required exposure adjustement */
  57269. exposureAdjustment: number;
  57270. /**
  57271. * Creates a new TonemapPostProcess
  57272. * @param name defines the name of the postprocess
  57273. * @param _operator defines the operator to use
  57274. * @param exposureAdjustment defines the required exposure adjustement
  57275. * @param camera defines the camera to use (can be null)
  57276. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57277. * @param engine defines the hosting engine (can be ignore if camera is set)
  57278. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57279. */
  57280. constructor(name: string, _operator: TonemappingOperator,
  57281. /** Defines the required exposure adjustement */
  57282. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57283. }
  57284. }
  57285. declare module "babylonjs/Shaders/depth.vertex" {
  57286. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57287. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57288. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57289. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57290. /** @hidden */
  57291. export var depthVertexShader: {
  57292. name: string;
  57293. shader: string;
  57294. };
  57295. }
  57296. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57297. /** @hidden */
  57298. export var volumetricLightScatteringPixelShader: {
  57299. name: string;
  57300. shader: string;
  57301. };
  57302. }
  57303. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57304. /** @hidden */
  57305. export var volumetricLightScatteringPassPixelShader: {
  57306. name: string;
  57307. shader: string;
  57308. };
  57309. }
  57310. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57311. import { Vector3 } from "babylonjs/Maths/math";
  57312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57313. import { Mesh } from "babylonjs/Meshes/mesh";
  57314. import { Camera } from "babylonjs/Cameras/camera";
  57315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57316. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57317. import { Scene } from "babylonjs/scene";
  57318. import "babylonjs/Meshes/Builders/planeBuilder";
  57319. import "babylonjs/Shaders/depth.vertex";
  57320. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57321. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57322. import { Engine } from "babylonjs/Engines/engine";
  57323. /**
  57324. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57325. */
  57326. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57327. private _volumetricLightScatteringPass;
  57328. private _volumetricLightScatteringRTT;
  57329. private _viewPort;
  57330. private _screenCoordinates;
  57331. private _cachedDefines;
  57332. /**
  57333. * If not undefined, the mesh position is computed from the attached node position
  57334. */
  57335. attachedNode: {
  57336. position: Vector3;
  57337. };
  57338. /**
  57339. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57340. */
  57341. customMeshPosition: Vector3;
  57342. /**
  57343. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57344. */
  57345. useCustomMeshPosition: boolean;
  57346. /**
  57347. * If the post-process should inverse the light scattering direction
  57348. */
  57349. invert: boolean;
  57350. /**
  57351. * The internal mesh used by the post-process
  57352. */
  57353. mesh: Mesh;
  57354. /**
  57355. * @hidden
  57356. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57357. */
  57358. useDiffuseColor: boolean;
  57359. /**
  57360. * Array containing the excluded meshes not rendered in the internal pass
  57361. */
  57362. excludedMeshes: AbstractMesh[];
  57363. /**
  57364. * Controls the overall intensity of the post-process
  57365. */
  57366. exposure: number;
  57367. /**
  57368. * Dissipates each sample's contribution in range [0, 1]
  57369. */
  57370. decay: number;
  57371. /**
  57372. * Controls the overall intensity of each sample
  57373. */
  57374. weight: number;
  57375. /**
  57376. * Controls the density of each sample
  57377. */
  57378. density: number;
  57379. /**
  57380. * @constructor
  57381. * @param name The post-process name
  57382. * @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)
  57383. * @param camera The camera that the post-process will be attached to
  57384. * @param mesh The mesh used to create the light scattering
  57385. * @param samples The post-process quality, default 100
  57386. * @param samplingModeThe post-process filtering mode
  57387. * @param engine The babylon engine
  57388. * @param reusable If the post-process is reusable
  57389. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57390. */
  57391. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57392. /**
  57393. * Returns the string "VolumetricLightScatteringPostProcess"
  57394. * @returns "VolumetricLightScatteringPostProcess"
  57395. */
  57396. getClassName(): string;
  57397. private _isReady;
  57398. /**
  57399. * Sets the new light position for light scattering effect
  57400. * @param position The new custom light position
  57401. */
  57402. setCustomMeshPosition(position: Vector3): void;
  57403. /**
  57404. * Returns the light position for light scattering effect
  57405. * @return Vector3 The custom light position
  57406. */
  57407. getCustomMeshPosition(): Vector3;
  57408. /**
  57409. * Disposes the internal assets and detaches the post-process from the camera
  57410. */
  57411. dispose(camera: Camera): void;
  57412. /**
  57413. * Returns the render target texture used by the post-process
  57414. * @return the render target texture used by the post-process
  57415. */
  57416. getPass(): RenderTargetTexture;
  57417. private _meshExcluded;
  57418. private _createPass;
  57419. private _updateMeshScreenCoordinates;
  57420. /**
  57421. * Creates a default mesh for the Volumeric Light Scattering post-process
  57422. * @param name The mesh name
  57423. * @param scene The scene where to create the mesh
  57424. * @return the default mesh
  57425. */
  57426. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57427. }
  57428. }
  57429. declare module "babylonjs/PostProcesses/index" {
  57430. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57431. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57432. export * from "babylonjs/PostProcesses/bloomEffect";
  57433. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57434. export * from "babylonjs/PostProcesses/blurPostProcess";
  57435. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57436. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57437. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57438. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57439. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57440. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57441. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57442. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57443. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57444. export * from "babylonjs/PostProcesses/filterPostProcess";
  57445. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57446. export * from "babylonjs/PostProcesses/grainPostProcess";
  57447. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57448. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57449. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57450. export * from "babylonjs/PostProcesses/passPostProcess";
  57451. export * from "babylonjs/PostProcesses/postProcess";
  57452. export * from "babylonjs/PostProcesses/postProcessManager";
  57453. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57454. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57455. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57456. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57457. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57458. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57459. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57460. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57461. }
  57462. declare module "babylonjs/Probes/index" {
  57463. export * from "babylonjs/Probes/reflectionProbe";
  57464. }
  57465. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57466. import { Scene } from "babylonjs/scene";
  57467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57468. import { Color3 } from "babylonjs/Maths/math";
  57469. import { SmartArray } from "babylonjs/Misc/smartArray";
  57470. import { ISceneComponent } from "babylonjs/sceneComponent";
  57471. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57472. import "babylonjs/Meshes/Builders/boxBuilder";
  57473. import "babylonjs/Shaders/color.fragment";
  57474. import "babylonjs/Shaders/color.vertex";
  57475. module "babylonjs/scene" {
  57476. interface Scene {
  57477. /** @hidden (Backing field) */
  57478. _boundingBoxRenderer: BoundingBoxRenderer;
  57479. /** @hidden (Backing field) */
  57480. _forceShowBoundingBoxes: boolean;
  57481. /**
  57482. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57483. */
  57484. forceShowBoundingBoxes: boolean;
  57485. /**
  57486. * Gets the bounding box renderer associated with the scene
  57487. * @returns a BoundingBoxRenderer
  57488. */
  57489. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57490. }
  57491. }
  57492. module "babylonjs/Meshes/abstractMesh" {
  57493. interface AbstractMesh {
  57494. /** @hidden (Backing field) */
  57495. _showBoundingBox: boolean;
  57496. /**
  57497. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57498. */
  57499. showBoundingBox: boolean;
  57500. }
  57501. }
  57502. /**
  57503. * Component responsible of rendering the bounding box of the meshes in a scene.
  57504. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57505. */
  57506. export class BoundingBoxRenderer implements ISceneComponent {
  57507. /**
  57508. * The component name helpfull to identify the component in the list of scene components.
  57509. */
  57510. readonly name: string;
  57511. /**
  57512. * The scene the component belongs to.
  57513. */
  57514. scene: Scene;
  57515. /**
  57516. * Color of the bounding box lines placed in front of an object
  57517. */
  57518. frontColor: Color3;
  57519. /**
  57520. * Color of the bounding box lines placed behind an object
  57521. */
  57522. backColor: Color3;
  57523. /**
  57524. * Defines if the renderer should show the back lines or not
  57525. */
  57526. showBackLines: boolean;
  57527. /**
  57528. * @hidden
  57529. */
  57530. renderList: SmartArray<BoundingBox>;
  57531. private _colorShader;
  57532. private _vertexBuffers;
  57533. private _indexBuffer;
  57534. /**
  57535. * Instantiates a new bounding box renderer in a scene.
  57536. * @param scene the scene the renderer renders in
  57537. */
  57538. constructor(scene: Scene);
  57539. /**
  57540. * Registers the component in a given scene
  57541. */
  57542. register(): void;
  57543. private _evaluateSubMesh;
  57544. private _activeMesh;
  57545. private _prepareRessources;
  57546. private _createIndexBuffer;
  57547. /**
  57548. * Rebuilds the elements related to this component in case of
  57549. * context lost for instance.
  57550. */
  57551. rebuild(): void;
  57552. /**
  57553. * @hidden
  57554. */
  57555. reset(): void;
  57556. /**
  57557. * Render the bounding boxes of a specific rendering group
  57558. * @param renderingGroupId defines the rendering group to render
  57559. */
  57560. render(renderingGroupId: number): void;
  57561. /**
  57562. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57563. * @param mesh Define the mesh to render the occlusion bounding box for
  57564. */
  57565. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57566. /**
  57567. * Dispose and release the resources attached to this renderer.
  57568. */
  57569. dispose(): void;
  57570. }
  57571. }
  57572. declare module "babylonjs/Shaders/depth.fragment" {
  57573. /** @hidden */
  57574. export var depthPixelShader: {
  57575. name: string;
  57576. shader: string;
  57577. };
  57578. }
  57579. declare module "babylonjs/Rendering/depthRenderer" {
  57580. import { Nullable } from "babylonjs/types";
  57581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57582. import { Scene } from "babylonjs/scene";
  57583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57584. import { Camera } from "babylonjs/Cameras/camera";
  57585. import "babylonjs/Shaders/depth.fragment";
  57586. import "babylonjs/Shaders/depth.vertex";
  57587. /**
  57588. * This represents a depth renderer in Babylon.
  57589. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57590. */
  57591. export class DepthRenderer {
  57592. private _scene;
  57593. private _depthMap;
  57594. private _effect;
  57595. private _cachedDefines;
  57596. private _camera;
  57597. /**
  57598. * Specifiess that the depth renderer will only be used within
  57599. * the camera it is created for.
  57600. * This can help forcing its rendering during the camera processing.
  57601. */
  57602. useOnlyInActiveCamera: boolean;
  57603. /** @hidden */
  57604. static _SceneComponentInitialization: (scene: Scene) => void;
  57605. /**
  57606. * Instantiates a depth renderer
  57607. * @param scene The scene the renderer belongs to
  57608. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57609. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57610. */
  57611. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57612. /**
  57613. * Creates the depth rendering effect and checks if the effect is ready.
  57614. * @param subMesh The submesh to be used to render the depth map of
  57615. * @param useInstances If multiple world instances should be used
  57616. * @returns if the depth renderer is ready to render the depth map
  57617. */
  57618. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57619. /**
  57620. * Gets the texture which the depth map will be written to.
  57621. * @returns The depth map texture
  57622. */
  57623. getDepthMap(): RenderTargetTexture;
  57624. /**
  57625. * Disposes of the depth renderer.
  57626. */
  57627. dispose(): void;
  57628. }
  57629. }
  57630. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57631. import { Nullable } from "babylonjs/types";
  57632. import { Scene } from "babylonjs/scene";
  57633. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57634. import { Camera } from "babylonjs/Cameras/camera";
  57635. import { ISceneComponent } from "babylonjs/sceneComponent";
  57636. module "babylonjs/scene" {
  57637. interface Scene {
  57638. /** @hidden (Backing field) */
  57639. _depthRenderer: {
  57640. [id: string]: DepthRenderer;
  57641. };
  57642. /**
  57643. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57644. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57645. * @returns the created depth renderer
  57646. */
  57647. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57648. /**
  57649. * Disables a depth renderer for a given camera
  57650. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57651. */
  57652. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57653. }
  57654. }
  57655. /**
  57656. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57657. * in several rendering techniques.
  57658. */
  57659. export class DepthRendererSceneComponent implements ISceneComponent {
  57660. /**
  57661. * The component name helpfull to identify the component in the list of scene components.
  57662. */
  57663. readonly name: string;
  57664. /**
  57665. * The scene the component belongs to.
  57666. */
  57667. scene: Scene;
  57668. /**
  57669. * Creates a new instance of the component for the given scene
  57670. * @param scene Defines the scene to register the component in
  57671. */
  57672. constructor(scene: Scene);
  57673. /**
  57674. * Registers the component in a given scene
  57675. */
  57676. register(): void;
  57677. /**
  57678. * Rebuilds the elements related to this component in case of
  57679. * context lost for instance.
  57680. */
  57681. rebuild(): void;
  57682. /**
  57683. * Disposes the component and the associated ressources
  57684. */
  57685. dispose(): void;
  57686. private _gatherRenderTargets;
  57687. private _gatherActiveCameraRenderTargets;
  57688. }
  57689. }
  57690. declare module "babylonjs/Shaders/outline.fragment" {
  57691. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57692. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57693. /** @hidden */
  57694. export var outlinePixelShader: {
  57695. name: string;
  57696. shader: string;
  57697. };
  57698. }
  57699. declare module "babylonjs/Shaders/outline.vertex" {
  57700. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57701. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57702. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57703. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57704. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57705. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57706. /** @hidden */
  57707. export var outlineVertexShader: {
  57708. name: string;
  57709. shader: string;
  57710. };
  57711. }
  57712. declare module "babylonjs/Rendering/outlineRenderer" {
  57713. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57714. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57715. import { Scene } from "babylonjs/scene";
  57716. import { ISceneComponent } from "babylonjs/sceneComponent";
  57717. import "babylonjs/Shaders/outline.fragment";
  57718. import "babylonjs/Shaders/outline.vertex";
  57719. module "babylonjs/scene" {
  57720. interface Scene {
  57721. /** @hidden */
  57722. _outlineRenderer: OutlineRenderer;
  57723. /**
  57724. * Gets the outline renderer associated with the scene
  57725. * @returns a OutlineRenderer
  57726. */
  57727. getOutlineRenderer(): OutlineRenderer;
  57728. }
  57729. }
  57730. module "babylonjs/Meshes/abstractMesh" {
  57731. interface AbstractMesh {
  57732. /** @hidden (Backing field) */
  57733. _renderOutline: boolean;
  57734. /**
  57735. * Gets or sets a boolean indicating if the outline must be rendered as well
  57736. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57737. */
  57738. renderOutline: boolean;
  57739. /** @hidden (Backing field) */
  57740. _renderOverlay: boolean;
  57741. /**
  57742. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57743. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57744. */
  57745. renderOverlay: boolean;
  57746. }
  57747. }
  57748. /**
  57749. * This class is responsible to draw bothe outline/overlay of meshes.
  57750. * It should not be used directly but through the available method on mesh.
  57751. */
  57752. export class OutlineRenderer implements ISceneComponent {
  57753. /**
  57754. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57755. */
  57756. private static _StencilReference;
  57757. /**
  57758. * The name of the component. Each component must have a unique name.
  57759. */
  57760. name: string;
  57761. /**
  57762. * The scene the component belongs to.
  57763. */
  57764. scene: Scene;
  57765. /**
  57766. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57767. */
  57768. zOffset: number;
  57769. private _engine;
  57770. private _effect;
  57771. private _cachedDefines;
  57772. private _savedDepthWrite;
  57773. /**
  57774. * Instantiates a new outline renderer. (There could be only one per scene).
  57775. * @param scene Defines the scene it belongs to
  57776. */
  57777. constructor(scene: Scene);
  57778. /**
  57779. * Register the component to one instance of a scene.
  57780. */
  57781. register(): void;
  57782. /**
  57783. * Rebuilds the elements related to this component in case of
  57784. * context lost for instance.
  57785. */
  57786. rebuild(): void;
  57787. /**
  57788. * Disposes the component and the associated ressources.
  57789. */
  57790. dispose(): void;
  57791. /**
  57792. * Renders the outline in the canvas.
  57793. * @param subMesh Defines the sumesh to render
  57794. * @param batch Defines the batch of meshes in case of instances
  57795. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57796. */
  57797. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57798. /**
  57799. * Returns whether or not the outline renderer is ready for a given submesh.
  57800. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57801. * @param subMesh Defines the submesh to check readyness for
  57802. * @param useInstances Defines wheter wee are trying to render instances or not
  57803. * @returns true if ready otherwise false
  57804. */
  57805. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57806. private _beforeRenderingMesh;
  57807. private _afterRenderingMesh;
  57808. }
  57809. }
  57810. declare module "babylonjs/Rendering/index" {
  57811. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57812. export * from "babylonjs/Rendering/depthRenderer";
  57813. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57814. export * from "babylonjs/Rendering/edgesRenderer";
  57815. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57816. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57817. export * from "babylonjs/Rendering/outlineRenderer";
  57818. export * from "babylonjs/Rendering/renderingGroup";
  57819. export * from "babylonjs/Rendering/renderingManager";
  57820. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57821. }
  57822. declare module "babylonjs/Sprites/index" {
  57823. export * from "babylonjs/Sprites/sprite";
  57824. export * from "babylonjs/Sprites/spriteManager";
  57825. export * from "babylonjs/Sprites/spriteSceneComponent";
  57826. }
  57827. declare module "babylonjs/Misc/assetsManager" {
  57828. import { Scene } from "babylonjs/scene";
  57829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57831. import { Skeleton } from "babylonjs/Bones/skeleton";
  57832. import { Observable } from "babylonjs/Misc/observable";
  57833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57834. import { Texture } from "babylonjs/Materials/Textures/texture";
  57835. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57836. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57837. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57838. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57839. /**
  57840. * Defines the list of states available for a task inside a AssetsManager
  57841. */
  57842. export enum AssetTaskState {
  57843. /**
  57844. * Initialization
  57845. */
  57846. INIT = 0,
  57847. /**
  57848. * Running
  57849. */
  57850. RUNNING = 1,
  57851. /**
  57852. * Done
  57853. */
  57854. DONE = 2,
  57855. /**
  57856. * Error
  57857. */
  57858. ERROR = 3
  57859. }
  57860. /**
  57861. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57862. */
  57863. export abstract class AbstractAssetTask {
  57864. /**
  57865. * Task name
  57866. */ name: string;
  57867. /**
  57868. * Callback called when the task is successful
  57869. */
  57870. onSuccess: (task: any) => void;
  57871. /**
  57872. * Callback called when the task is not successful
  57873. */
  57874. onError: (task: any, message?: string, exception?: any) => void;
  57875. /**
  57876. * Creates a new AssetsManager
  57877. * @param name defines the name of the task
  57878. */
  57879. constructor(
  57880. /**
  57881. * Task name
  57882. */ name: string);
  57883. private _isCompleted;
  57884. private _taskState;
  57885. private _errorObject;
  57886. /**
  57887. * Get if the task is completed
  57888. */
  57889. readonly isCompleted: boolean;
  57890. /**
  57891. * Gets the current state of the task
  57892. */
  57893. readonly taskState: AssetTaskState;
  57894. /**
  57895. * Gets the current error object (if task is in error)
  57896. */
  57897. readonly errorObject: {
  57898. message?: string;
  57899. exception?: any;
  57900. };
  57901. /**
  57902. * Internal only
  57903. * @hidden
  57904. */
  57905. _setErrorObject(message?: string, exception?: any): void;
  57906. /**
  57907. * Execute the current task
  57908. * @param scene defines the scene where you want your assets to be loaded
  57909. * @param onSuccess is a callback called when the task is successfully executed
  57910. * @param onError is a callback called if an error occurs
  57911. */
  57912. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57913. /**
  57914. * Execute the current task
  57915. * @param scene defines the scene where you want your assets to be loaded
  57916. * @param onSuccess is a callback called when the task is successfully executed
  57917. * @param onError is a callback called if an error occurs
  57918. */
  57919. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57920. /**
  57921. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57922. * This can be used with failed tasks that have the reason for failure fixed.
  57923. */
  57924. reset(): void;
  57925. private onErrorCallback;
  57926. private onDoneCallback;
  57927. }
  57928. /**
  57929. * Define the interface used by progress events raised during assets loading
  57930. */
  57931. export interface IAssetsProgressEvent {
  57932. /**
  57933. * Defines the number of remaining tasks to process
  57934. */
  57935. remainingCount: number;
  57936. /**
  57937. * Defines the total number of tasks
  57938. */
  57939. totalCount: number;
  57940. /**
  57941. * Defines the task that was just processed
  57942. */
  57943. task: AbstractAssetTask;
  57944. }
  57945. /**
  57946. * Class used to share progress information about assets loading
  57947. */
  57948. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57949. /**
  57950. * Defines the number of remaining tasks to process
  57951. */
  57952. remainingCount: number;
  57953. /**
  57954. * Defines the total number of tasks
  57955. */
  57956. totalCount: number;
  57957. /**
  57958. * Defines the task that was just processed
  57959. */
  57960. task: AbstractAssetTask;
  57961. /**
  57962. * Creates a AssetsProgressEvent
  57963. * @param remainingCount defines the number of remaining tasks to process
  57964. * @param totalCount defines the total number of tasks
  57965. * @param task defines the task that was just processed
  57966. */
  57967. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57968. }
  57969. /**
  57970. * Define a task used by AssetsManager to load meshes
  57971. */
  57972. export class MeshAssetTask extends AbstractAssetTask {
  57973. /**
  57974. * Defines the name of the task
  57975. */
  57976. name: string;
  57977. /**
  57978. * Defines the list of mesh's names you want to load
  57979. */
  57980. meshesNames: any;
  57981. /**
  57982. * Defines the root url to use as a base to load your meshes and associated resources
  57983. */
  57984. rootUrl: string;
  57985. /**
  57986. * Defines the filename of the scene to load from
  57987. */
  57988. sceneFilename: string;
  57989. /**
  57990. * Gets the list of loaded meshes
  57991. */
  57992. loadedMeshes: Array<AbstractMesh>;
  57993. /**
  57994. * Gets the list of loaded particle systems
  57995. */
  57996. loadedParticleSystems: Array<IParticleSystem>;
  57997. /**
  57998. * Gets the list of loaded skeletons
  57999. */
  58000. loadedSkeletons: Array<Skeleton>;
  58001. /**
  58002. * Gets the list of loaded animation groups
  58003. */
  58004. loadedAnimationGroups: Array<AnimationGroup>;
  58005. /**
  58006. * Callback called when the task is successful
  58007. */
  58008. onSuccess: (task: MeshAssetTask) => void;
  58009. /**
  58010. * Callback called when the task is successful
  58011. */
  58012. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58013. /**
  58014. * Creates a new MeshAssetTask
  58015. * @param name defines the name of the task
  58016. * @param meshesNames defines the list of mesh's names you want to load
  58017. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  58018. * @param sceneFilename defines the filename of the scene to load from
  58019. */
  58020. constructor(
  58021. /**
  58022. * Defines the name of the task
  58023. */
  58024. name: string,
  58025. /**
  58026. * Defines the list of mesh's names you want to load
  58027. */
  58028. meshesNames: any,
  58029. /**
  58030. * Defines the root url to use as a base to load your meshes and associated resources
  58031. */
  58032. rootUrl: string,
  58033. /**
  58034. * Defines the filename of the scene to load from
  58035. */
  58036. sceneFilename: string);
  58037. /**
  58038. * Execute the current task
  58039. * @param scene defines the scene where you want your assets to be loaded
  58040. * @param onSuccess is a callback called when the task is successfully executed
  58041. * @param onError is a callback called if an error occurs
  58042. */
  58043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58044. }
  58045. /**
  58046. * Define a task used by AssetsManager to load text content
  58047. */
  58048. export class TextFileAssetTask extends AbstractAssetTask {
  58049. /**
  58050. * Defines the name of the task
  58051. */
  58052. name: string;
  58053. /**
  58054. * Defines the location of the file to load
  58055. */
  58056. url: string;
  58057. /**
  58058. * Gets the loaded text string
  58059. */
  58060. text: string;
  58061. /**
  58062. * Callback called when the task is successful
  58063. */
  58064. onSuccess: (task: TextFileAssetTask) => void;
  58065. /**
  58066. * Callback called when the task is successful
  58067. */
  58068. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58069. /**
  58070. * Creates a new TextFileAssetTask object
  58071. * @param name defines the name of the task
  58072. * @param url defines the location of the file to load
  58073. */
  58074. constructor(
  58075. /**
  58076. * Defines the name of the task
  58077. */
  58078. name: string,
  58079. /**
  58080. * Defines the location of the file to load
  58081. */
  58082. url: string);
  58083. /**
  58084. * Execute the current task
  58085. * @param scene defines the scene where you want your assets to be loaded
  58086. * @param onSuccess is a callback called when the task is successfully executed
  58087. * @param onError is a callback called if an error occurs
  58088. */
  58089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58090. }
  58091. /**
  58092. * Define a task used by AssetsManager to load binary data
  58093. */
  58094. export class BinaryFileAssetTask extends AbstractAssetTask {
  58095. /**
  58096. * Defines the name of the task
  58097. */
  58098. name: string;
  58099. /**
  58100. * Defines the location of the file to load
  58101. */
  58102. url: string;
  58103. /**
  58104. * Gets the lodaded data (as an array buffer)
  58105. */
  58106. data: ArrayBuffer;
  58107. /**
  58108. * Callback called when the task is successful
  58109. */
  58110. onSuccess: (task: BinaryFileAssetTask) => void;
  58111. /**
  58112. * Callback called when the task is successful
  58113. */
  58114. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58115. /**
  58116. * Creates a new BinaryFileAssetTask object
  58117. * @param name defines the name of the new task
  58118. * @param url defines the location of the file to load
  58119. */
  58120. constructor(
  58121. /**
  58122. * Defines the name of the task
  58123. */
  58124. name: string,
  58125. /**
  58126. * Defines the location of the file to load
  58127. */
  58128. url: string);
  58129. /**
  58130. * Execute the current task
  58131. * @param scene defines the scene where you want your assets to be loaded
  58132. * @param onSuccess is a callback called when the task is successfully executed
  58133. * @param onError is a callback called if an error occurs
  58134. */
  58135. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58136. }
  58137. /**
  58138. * Define a task used by AssetsManager to load images
  58139. */
  58140. export class ImageAssetTask extends AbstractAssetTask {
  58141. /**
  58142. * Defines the name of the task
  58143. */
  58144. name: string;
  58145. /**
  58146. * Defines the location of the image to load
  58147. */
  58148. url: string;
  58149. /**
  58150. * Gets the loaded images
  58151. */
  58152. image: HTMLImageElement;
  58153. /**
  58154. * Callback called when the task is successful
  58155. */
  58156. onSuccess: (task: ImageAssetTask) => void;
  58157. /**
  58158. * Callback called when the task is successful
  58159. */
  58160. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58161. /**
  58162. * Creates a new ImageAssetTask
  58163. * @param name defines the name of the task
  58164. * @param url defines the location of the image to load
  58165. */
  58166. constructor(
  58167. /**
  58168. * Defines the name of the task
  58169. */
  58170. name: string,
  58171. /**
  58172. * Defines the location of the image to load
  58173. */
  58174. url: string);
  58175. /**
  58176. * Execute the current task
  58177. * @param scene defines the scene where you want your assets to be loaded
  58178. * @param onSuccess is a callback called when the task is successfully executed
  58179. * @param onError is a callback called if an error occurs
  58180. */
  58181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58182. }
  58183. /**
  58184. * Defines the interface used by texture loading tasks
  58185. */
  58186. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58187. /**
  58188. * Gets the loaded texture
  58189. */
  58190. texture: TEX;
  58191. }
  58192. /**
  58193. * Define a task used by AssetsManager to load 2D textures
  58194. */
  58195. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58196. /**
  58197. * Defines the name of the task
  58198. */
  58199. name: string;
  58200. /**
  58201. * Defines the location of the file to load
  58202. */
  58203. url: string;
  58204. /**
  58205. * Defines if mipmap should not be generated (default is false)
  58206. */
  58207. noMipmap?: boolean | undefined;
  58208. /**
  58209. * Defines if texture must be inverted on Y axis (default is false)
  58210. */
  58211. invertY?: boolean | undefined;
  58212. /**
  58213. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58214. */
  58215. samplingMode: number;
  58216. /**
  58217. * Gets the loaded texture
  58218. */
  58219. texture: Texture;
  58220. /**
  58221. * Callback called when the task is successful
  58222. */
  58223. onSuccess: (task: TextureAssetTask) => void;
  58224. /**
  58225. * Callback called when the task is successful
  58226. */
  58227. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58228. /**
  58229. * Creates a new TextureAssetTask object
  58230. * @param name defines the name of the task
  58231. * @param url defines the location of the file to load
  58232. * @param noMipmap defines if mipmap should not be generated (default is false)
  58233. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58234. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58235. */
  58236. constructor(
  58237. /**
  58238. * Defines the name of the task
  58239. */
  58240. name: string,
  58241. /**
  58242. * Defines the location of the file to load
  58243. */
  58244. url: string,
  58245. /**
  58246. * Defines if mipmap should not be generated (default is false)
  58247. */
  58248. noMipmap?: boolean | undefined,
  58249. /**
  58250. * Defines if texture must be inverted on Y axis (default is false)
  58251. */
  58252. invertY?: boolean | undefined,
  58253. /**
  58254. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58255. */
  58256. samplingMode?: number);
  58257. /**
  58258. * Execute the current task
  58259. * @param scene defines the scene where you want your assets to be loaded
  58260. * @param onSuccess is a callback called when the task is successfully executed
  58261. * @param onError is a callback called if an error occurs
  58262. */
  58263. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58264. }
  58265. /**
  58266. * Define a task used by AssetsManager to load cube textures
  58267. */
  58268. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58269. /**
  58270. * Defines the name of the task
  58271. */
  58272. name: string;
  58273. /**
  58274. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58275. */
  58276. url: string;
  58277. /**
  58278. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58279. */
  58280. extensions?: string[] | undefined;
  58281. /**
  58282. * Defines if mipmaps should not be generated (default is false)
  58283. */
  58284. noMipmap?: boolean | undefined;
  58285. /**
  58286. * Defines the explicit list of files (undefined by default)
  58287. */
  58288. files?: string[] | undefined;
  58289. /**
  58290. * Gets the loaded texture
  58291. */
  58292. texture: CubeTexture;
  58293. /**
  58294. * Callback called when the task is successful
  58295. */
  58296. onSuccess: (task: CubeTextureAssetTask) => void;
  58297. /**
  58298. * Callback called when the task is successful
  58299. */
  58300. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58301. /**
  58302. * Creates a new CubeTextureAssetTask
  58303. * @param name defines the name of the task
  58304. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58305. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58306. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58307. * @param files defines the explicit list of files (undefined by default)
  58308. */
  58309. constructor(
  58310. /**
  58311. * Defines the name of the task
  58312. */
  58313. name: string,
  58314. /**
  58315. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58316. */
  58317. url: string,
  58318. /**
  58319. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58320. */
  58321. extensions?: string[] | undefined,
  58322. /**
  58323. * Defines if mipmaps should not be generated (default is false)
  58324. */
  58325. noMipmap?: boolean | undefined,
  58326. /**
  58327. * Defines the explicit list of files (undefined by default)
  58328. */
  58329. files?: string[] | undefined);
  58330. /**
  58331. * Execute the current task
  58332. * @param scene defines the scene where you want your assets to be loaded
  58333. * @param onSuccess is a callback called when the task is successfully executed
  58334. * @param onError is a callback called if an error occurs
  58335. */
  58336. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58337. }
  58338. /**
  58339. * Define a task used by AssetsManager to load HDR cube textures
  58340. */
  58341. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58342. /**
  58343. * Defines the name of the task
  58344. */
  58345. name: string;
  58346. /**
  58347. * Defines the location of the file to load
  58348. */
  58349. url: string;
  58350. /**
  58351. * Defines the desired size (the more it increases the longer the generation will be)
  58352. */
  58353. size: number;
  58354. /**
  58355. * Defines if mipmaps should not be generated (default is false)
  58356. */
  58357. noMipmap: boolean;
  58358. /**
  58359. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58360. */
  58361. generateHarmonics: boolean;
  58362. /**
  58363. * 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)
  58364. */
  58365. gammaSpace: boolean;
  58366. /**
  58367. * Internal Use Only
  58368. */
  58369. reserved: boolean;
  58370. /**
  58371. * Gets the loaded texture
  58372. */
  58373. texture: HDRCubeTexture;
  58374. /**
  58375. * Callback called when the task is successful
  58376. */
  58377. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58378. /**
  58379. * Callback called when the task is successful
  58380. */
  58381. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58382. /**
  58383. * Creates a new HDRCubeTextureAssetTask object
  58384. * @param name defines the name of the task
  58385. * @param url defines the location of the file to load
  58386. * @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.
  58387. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58388. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58389. * @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)
  58390. * @param reserved Internal use only
  58391. */
  58392. constructor(
  58393. /**
  58394. * Defines the name of the task
  58395. */
  58396. name: string,
  58397. /**
  58398. * Defines the location of the file to load
  58399. */
  58400. url: string,
  58401. /**
  58402. * Defines the desired size (the more it increases the longer the generation will be)
  58403. */
  58404. size: number,
  58405. /**
  58406. * Defines if mipmaps should not be generated (default is false)
  58407. */
  58408. noMipmap?: boolean,
  58409. /**
  58410. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58411. */
  58412. generateHarmonics?: boolean,
  58413. /**
  58414. * 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)
  58415. */
  58416. gammaSpace?: boolean,
  58417. /**
  58418. * Internal Use Only
  58419. */
  58420. reserved?: boolean);
  58421. /**
  58422. * Execute the current task
  58423. * @param scene defines the scene where you want your assets to be loaded
  58424. * @param onSuccess is a callback called when the task is successfully executed
  58425. * @param onError is a callback called if an error occurs
  58426. */
  58427. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58428. }
  58429. /**
  58430. * Define a task used by AssetsManager to load Equirectangular cube textures
  58431. */
  58432. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58433. /**
  58434. * Defines the name of the task
  58435. */
  58436. name: string;
  58437. /**
  58438. * Defines the location of the file to load
  58439. */
  58440. url: string;
  58441. /**
  58442. * Defines the desired size (the more it increases the longer the generation will be)
  58443. */
  58444. size: number;
  58445. /**
  58446. * Defines if mipmaps should not be generated (default is false)
  58447. */
  58448. noMipmap: boolean;
  58449. /**
  58450. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58451. * but the standard material would require them in Gamma space) (default is true)
  58452. */
  58453. gammaSpace: boolean;
  58454. /**
  58455. * Gets the loaded texture
  58456. */
  58457. texture: EquiRectangularCubeTexture;
  58458. /**
  58459. * Callback called when the task is successful
  58460. */
  58461. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58462. /**
  58463. * Callback called when the task is successful
  58464. */
  58465. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58466. /**
  58467. * Creates a new EquiRectangularCubeTextureAssetTask object
  58468. * @param name defines the name of the task
  58469. * @param url defines the location of the file to load
  58470. * @param size defines the desired size (the more it increases the longer the generation will be)
  58471. * If the size is omitted this implies you are using a preprocessed cubemap.
  58472. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58473. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58474. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58475. * (default is true)
  58476. */
  58477. constructor(
  58478. /**
  58479. * Defines the name of the task
  58480. */
  58481. name: string,
  58482. /**
  58483. * Defines the location of the file to load
  58484. */
  58485. url: string,
  58486. /**
  58487. * Defines the desired size (the more it increases the longer the generation will be)
  58488. */
  58489. size: number,
  58490. /**
  58491. * Defines if mipmaps should not be generated (default is false)
  58492. */
  58493. noMipmap?: boolean,
  58494. /**
  58495. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58496. * but the standard material would require them in Gamma space) (default is true)
  58497. */
  58498. gammaSpace?: boolean);
  58499. /**
  58500. * Execute the current task
  58501. * @param scene defines the scene where you want your assets to be loaded
  58502. * @param onSuccess is a callback called when the task is successfully executed
  58503. * @param onError is a callback called if an error occurs
  58504. */
  58505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58506. }
  58507. /**
  58508. * This class can be used to easily import assets into a scene
  58509. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58510. */
  58511. export class AssetsManager {
  58512. private _scene;
  58513. private _isLoading;
  58514. protected _tasks: AbstractAssetTask[];
  58515. protected _waitingTasksCount: number;
  58516. protected _totalTasksCount: number;
  58517. /**
  58518. * Callback called when all tasks are processed
  58519. */
  58520. onFinish: (tasks: AbstractAssetTask[]) => void;
  58521. /**
  58522. * Callback called when a task is successful
  58523. */
  58524. onTaskSuccess: (task: AbstractAssetTask) => void;
  58525. /**
  58526. * Callback called when a task had an error
  58527. */
  58528. onTaskError: (task: AbstractAssetTask) => void;
  58529. /**
  58530. * Callback called when a task is done (whatever the result is)
  58531. */
  58532. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58533. /**
  58534. * Observable called when all tasks are processed
  58535. */
  58536. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58537. /**
  58538. * Observable called when a task had an error
  58539. */
  58540. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58541. /**
  58542. * Observable called when all tasks were executed
  58543. */
  58544. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58545. /**
  58546. * Observable called when a task is done (whatever the result is)
  58547. */
  58548. onProgressObservable: Observable<IAssetsProgressEvent>;
  58549. /**
  58550. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58551. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58552. */
  58553. useDefaultLoadingScreen: boolean;
  58554. /**
  58555. * Creates a new AssetsManager
  58556. * @param scene defines the scene to work on
  58557. */
  58558. constructor(scene: Scene);
  58559. /**
  58560. * Add a MeshAssetTask to the list of active tasks
  58561. * @param taskName defines the name of the new task
  58562. * @param meshesNames defines the name of meshes to load
  58563. * @param rootUrl defines the root url to use to locate files
  58564. * @param sceneFilename defines the filename of the scene file
  58565. * @returns a new MeshAssetTask object
  58566. */
  58567. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58568. /**
  58569. * Add a TextFileAssetTask to the list of active tasks
  58570. * @param taskName defines the name of the new task
  58571. * @param url defines the url of the file to load
  58572. * @returns a new TextFileAssetTask object
  58573. */
  58574. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58575. /**
  58576. * Add a BinaryFileAssetTask to the list of active tasks
  58577. * @param taskName defines the name of the new task
  58578. * @param url defines the url of the file to load
  58579. * @returns a new BinaryFileAssetTask object
  58580. */
  58581. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58582. /**
  58583. * Add a ImageAssetTask to the list of active tasks
  58584. * @param taskName defines the name of the new task
  58585. * @param url defines the url of the file to load
  58586. * @returns a new ImageAssetTask object
  58587. */
  58588. addImageTask(taskName: string, url: string): ImageAssetTask;
  58589. /**
  58590. * Add a TextureAssetTask to the list of active tasks
  58591. * @param taskName defines the name of the new task
  58592. * @param url defines the url of the file to load
  58593. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58594. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58595. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58596. * @returns a new TextureAssetTask object
  58597. */
  58598. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58599. /**
  58600. * Add a CubeTextureAssetTask to the list of active tasks
  58601. * @param taskName defines the name of the new task
  58602. * @param url defines the url of the file to load
  58603. * @param extensions defines the extension to use to load the cube map (can be null)
  58604. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58605. * @param files defines the list of files to load (can be null)
  58606. * @returns a new CubeTextureAssetTask object
  58607. */
  58608. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58609. /**
  58610. *
  58611. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58612. * @param taskName defines the name of the new task
  58613. * @param url defines the url of the file to load
  58614. * @param size defines the size you want for the cubemap (can be null)
  58615. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58616. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58617. * @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)
  58618. * @param reserved Internal use only
  58619. * @returns a new HDRCubeTextureAssetTask object
  58620. */
  58621. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58622. /**
  58623. *
  58624. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58625. * @param taskName defines the name of the new task
  58626. * @param url defines the url of the file to load
  58627. * @param size defines the size you want for the cubemap (can be null)
  58628. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58629. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58630. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58631. * @returns a new EquiRectangularCubeTextureAssetTask object
  58632. */
  58633. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58634. /**
  58635. * Remove a task from the assets manager.
  58636. * @param task the task to remove
  58637. */
  58638. removeTask(task: AbstractAssetTask): void;
  58639. private _decreaseWaitingTasksCount;
  58640. private _runTask;
  58641. /**
  58642. * Reset the AssetsManager and remove all tasks
  58643. * @return the current instance of the AssetsManager
  58644. */
  58645. reset(): AssetsManager;
  58646. /**
  58647. * Start the loading process
  58648. * @return the current instance of the AssetsManager
  58649. */
  58650. load(): AssetsManager;
  58651. /**
  58652. * Start the loading process as an async operation
  58653. * @return a promise returning the list of failed tasks
  58654. */
  58655. loadAsync(): Promise<void>;
  58656. }
  58657. }
  58658. declare module "babylonjs/Misc/deferred" {
  58659. /**
  58660. * Wrapper class for promise with external resolve and reject.
  58661. */
  58662. export class Deferred<T> {
  58663. /**
  58664. * The promise associated with this deferred object.
  58665. */
  58666. readonly promise: Promise<T>;
  58667. private _resolve;
  58668. private _reject;
  58669. /**
  58670. * The resolve method of the promise associated with this deferred object.
  58671. */
  58672. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58673. /**
  58674. * The reject method of the promise associated with this deferred object.
  58675. */
  58676. readonly reject: (reason?: any) => void;
  58677. /**
  58678. * Constructor for this deferred object.
  58679. */
  58680. constructor();
  58681. }
  58682. }
  58683. declare module "babylonjs/Misc/meshExploder" {
  58684. import { Mesh } from "babylonjs/Meshes/mesh";
  58685. /**
  58686. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58687. */
  58688. export class MeshExploder {
  58689. private _centerMesh;
  58690. private _meshes;
  58691. private _meshesOrigins;
  58692. private _toCenterVectors;
  58693. private _scaledDirection;
  58694. private _newPosition;
  58695. private _centerPosition;
  58696. /**
  58697. * Explodes meshes from a center mesh.
  58698. * @param meshes The meshes to explode.
  58699. * @param centerMesh The mesh to be center of explosion.
  58700. */
  58701. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58702. private _setCenterMesh;
  58703. /**
  58704. * Get class name
  58705. * @returns "MeshExploder"
  58706. */
  58707. getClassName(): string;
  58708. /**
  58709. * "Exploded meshes"
  58710. * @returns Array of meshes with the centerMesh at index 0.
  58711. */
  58712. getMeshes(): Array<Mesh>;
  58713. /**
  58714. * Explodes meshes giving a specific direction
  58715. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58716. */
  58717. explode(direction?: number): void;
  58718. }
  58719. }
  58720. declare module "babylonjs/Misc/filesInput" {
  58721. import { Engine } from "babylonjs/Engines/engine";
  58722. import { Scene } from "babylonjs/scene";
  58723. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58724. /**
  58725. * Class used to help managing file picking and drag'n'drop
  58726. */
  58727. export class FilesInput {
  58728. /**
  58729. * List of files ready to be loaded
  58730. */
  58731. static readonly FilesToLoad: {
  58732. [key: string]: File;
  58733. };
  58734. /**
  58735. * Callback called when a file is processed
  58736. */
  58737. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58738. private _engine;
  58739. private _currentScene;
  58740. private _sceneLoadedCallback;
  58741. private _progressCallback;
  58742. private _additionalRenderLoopLogicCallback;
  58743. private _textureLoadingCallback;
  58744. private _startingProcessingFilesCallback;
  58745. private _onReloadCallback;
  58746. private _errorCallback;
  58747. private _elementToMonitor;
  58748. private _sceneFileToLoad;
  58749. private _filesToLoad;
  58750. /**
  58751. * Creates a new FilesInput
  58752. * @param engine defines the rendering engine
  58753. * @param scene defines the hosting scene
  58754. * @param sceneLoadedCallback callback called when scene is loaded
  58755. * @param progressCallback callback called to track progress
  58756. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58757. * @param textureLoadingCallback callback called when a texture is loading
  58758. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58759. * @param onReloadCallback callback called when a reload is requested
  58760. * @param errorCallback callback call if an error occurs
  58761. */
  58762. 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);
  58763. private _dragEnterHandler;
  58764. private _dragOverHandler;
  58765. private _dropHandler;
  58766. /**
  58767. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58768. * @param elementToMonitor defines the DOM element to track
  58769. */
  58770. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58771. /**
  58772. * Release all associated resources
  58773. */
  58774. dispose(): void;
  58775. private renderFunction;
  58776. private drag;
  58777. private drop;
  58778. private _traverseFolder;
  58779. private _processFiles;
  58780. /**
  58781. * Load files from a drop event
  58782. * @param event defines the drop event to use as source
  58783. */
  58784. loadFiles(event: any): void;
  58785. private _processReload;
  58786. /**
  58787. * Reload the current scene from the loaded files
  58788. */
  58789. reload(): void;
  58790. }
  58791. }
  58792. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58793. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58794. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58795. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58796. }
  58797. declare module "babylonjs/Misc/sceneOptimizer" {
  58798. import { Scene, IDisposable } from "babylonjs/scene";
  58799. import { Observable } from "babylonjs/Misc/observable";
  58800. /**
  58801. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58802. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58803. */
  58804. export class SceneOptimization {
  58805. /**
  58806. * Defines the priority of this optimization (0 by default which means first in the list)
  58807. */
  58808. priority: number;
  58809. /**
  58810. * Gets a string describing the action executed by the current optimization
  58811. * @returns description string
  58812. */
  58813. getDescription(): string;
  58814. /**
  58815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58816. * @param scene defines the current scene where to apply this optimization
  58817. * @param optimizer defines the current optimizer
  58818. * @returns true if everything that can be done was applied
  58819. */
  58820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58821. /**
  58822. * Creates the SceneOptimization object
  58823. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58824. * @param desc defines the description associated with the optimization
  58825. */
  58826. constructor(
  58827. /**
  58828. * Defines the priority of this optimization (0 by default which means first in the list)
  58829. */
  58830. priority?: number);
  58831. }
  58832. /**
  58833. * Defines an optimization used to reduce the size of render target textures
  58834. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58835. */
  58836. export class TextureOptimization extends SceneOptimization {
  58837. /**
  58838. * Defines the priority of this optimization (0 by default which means first in the list)
  58839. */
  58840. priority: number;
  58841. /**
  58842. * 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
  58843. */
  58844. maximumSize: number;
  58845. /**
  58846. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58847. */
  58848. step: number;
  58849. /**
  58850. * Gets a string describing the action executed by the current optimization
  58851. * @returns description string
  58852. */
  58853. getDescription(): string;
  58854. /**
  58855. * Creates the TextureOptimization object
  58856. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58857. * @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
  58858. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58859. */
  58860. constructor(
  58861. /**
  58862. * Defines the priority of this optimization (0 by default which means first in the list)
  58863. */
  58864. priority?: number,
  58865. /**
  58866. * 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
  58867. */
  58868. maximumSize?: number,
  58869. /**
  58870. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58871. */
  58872. step?: number);
  58873. /**
  58874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58875. * @param scene defines the current scene where to apply this optimization
  58876. * @param optimizer defines the current optimizer
  58877. * @returns true if everything that can be done was applied
  58878. */
  58879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58880. }
  58881. /**
  58882. * Defines an optimization used to increase or decrease the rendering resolution
  58883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58884. */
  58885. export class HardwareScalingOptimization extends SceneOptimization {
  58886. /**
  58887. * Defines the priority of this optimization (0 by default which means first in the list)
  58888. */
  58889. priority: number;
  58890. /**
  58891. * Defines the maximum scale to use (2 by default)
  58892. */
  58893. maximumScale: number;
  58894. /**
  58895. * Defines the step to use between two passes (0.5 by default)
  58896. */
  58897. step: number;
  58898. private _currentScale;
  58899. private _directionOffset;
  58900. /**
  58901. * Gets a string describing the action executed by the current optimization
  58902. * @return description string
  58903. */
  58904. getDescription(): string;
  58905. /**
  58906. * Creates the HardwareScalingOptimization object
  58907. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58908. * @param maximumScale defines the maximum scale to use (2 by default)
  58909. * @param step defines the step to use between two passes (0.5 by default)
  58910. */
  58911. constructor(
  58912. /**
  58913. * Defines the priority of this optimization (0 by default which means first in the list)
  58914. */
  58915. priority?: number,
  58916. /**
  58917. * Defines the maximum scale to use (2 by default)
  58918. */
  58919. maximumScale?: number,
  58920. /**
  58921. * Defines the step to use between two passes (0.5 by default)
  58922. */
  58923. step?: number);
  58924. /**
  58925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58926. * @param scene defines the current scene where to apply this optimization
  58927. * @param optimizer defines the current optimizer
  58928. * @returns true if everything that can be done was applied
  58929. */
  58930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58931. }
  58932. /**
  58933. * Defines an optimization used to remove shadows
  58934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58935. */
  58936. export class ShadowsOptimization extends SceneOptimization {
  58937. /**
  58938. * Gets a string describing the action executed by the current optimization
  58939. * @return description string
  58940. */
  58941. getDescription(): string;
  58942. /**
  58943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58944. * @param scene defines the current scene where to apply this optimization
  58945. * @param optimizer defines the current optimizer
  58946. * @returns true if everything that can be done was applied
  58947. */
  58948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58949. }
  58950. /**
  58951. * Defines an optimization used to turn post-processes off
  58952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58953. */
  58954. export class PostProcessesOptimization extends SceneOptimization {
  58955. /**
  58956. * Gets a string describing the action executed by the current optimization
  58957. * @return description string
  58958. */
  58959. getDescription(): string;
  58960. /**
  58961. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58962. * @param scene defines the current scene where to apply this optimization
  58963. * @param optimizer defines the current optimizer
  58964. * @returns true if everything that can be done was applied
  58965. */
  58966. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58967. }
  58968. /**
  58969. * Defines an optimization used to turn lens flares off
  58970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58971. */
  58972. export class LensFlaresOptimization extends SceneOptimization {
  58973. /**
  58974. * Gets a string describing the action executed by the current optimization
  58975. * @return description string
  58976. */
  58977. getDescription(): string;
  58978. /**
  58979. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58980. * @param scene defines the current scene where to apply this optimization
  58981. * @param optimizer defines the current optimizer
  58982. * @returns true if everything that can be done was applied
  58983. */
  58984. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58985. }
  58986. /**
  58987. * Defines an optimization based on user defined callback.
  58988. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58989. */
  58990. export class CustomOptimization extends SceneOptimization {
  58991. /**
  58992. * Callback called to apply the custom optimization.
  58993. */
  58994. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58995. /**
  58996. * Callback called to get custom description
  58997. */
  58998. onGetDescription: () => string;
  58999. /**
  59000. * Gets a string describing the action executed by the current optimization
  59001. * @returns description string
  59002. */
  59003. getDescription(): string;
  59004. /**
  59005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59006. * @param scene defines the current scene where to apply this optimization
  59007. * @param optimizer defines the current optimizer
  59008. * @returns true if everything that can be done was applied
  59009. */
  59010. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59011. }
  59012. /**
  59013. * Defines an optimization used to turn particles off
  59014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59015. */
  59016. export class ParticlesOptimization extends SceneOptimization {
  59017. /**
  59018. * Gets a string describing the action executed by the current optimization
  59019. * @return description string
  59020. */
  59021. getDescription(): string;
  59022. /**
  59023. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59024. * @param scene defines the current scene where to apply this optimization
  59025. * @param optimizer defines the current optimizer
  59026. * @returns true if everything that can be done was applied
  59027. */
  59028. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59029. }
  59030. /**
  59031. * Defines an optimization used to turn render targets off
  59032. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59033. */
  59034. export class RenderTargetsOptimization extends SceneOptimization {
  59035. /**
  59036. * Gets a string describing the action executed by the current optimization
  59037. * @return description string
  59038. */
  59039. getDescription(): string;
  59040. /**
  59041. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59042. * @param scene defines the current scene where to apply this optimization
  59043. * @param optimizer defines the current optimizer
  59044. * @returns true if everything that can be done was applied
  59045. */
  59046. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59047. }
  59048. /**
  59049. * Defines an optimization used to merge meshes with compatible materials
  59050. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59051. */
  59052. export class MergeMeshesOptimization extends SceneOptimization {
  59053. private static _UpdateSelectionTree;
  59054. /**
  59055. * Gets or sets a boolean which defines if optimization octree has to be updated
  59056. */
  59057. /**
  59058. * Gets or sets a boolean which defines if optimization octree has to be updated
  59059. */
  59060. static UpdateSelectionTree: boolean;
  59061. /**
  59062. * Gets a string describing the action executed by the current optimization
  59063. * @return description string
  59064. */
  59065. getDescription(): string;
  59066. private _canBeMerged;
  59067. /**
  59068. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59069. * @param scene defines the current scene where to apply this optimization
  59070. * @param optimizer defines the current optimizer
  59071. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59072. * @returns true if everything that can be done was applied
  59073. */
  59074. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59075. }
  59076. /**
  59077. * Defines a list of options used by SceneOptimizer
  59078. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59079. */
  59080. export class SceneOptimizerOptions {
  59081. /**
  59082. * Defines the target frame rate to reach (60 by default)
  59083. */
  59084. targetFrameRate: number;
  59085. /**
  59086. * Defines the interval between two checkes (2000ms by default)
  59087. */
  59088. trackerDuration: number;
  59089. /**
  59090. * Gets the list of optimizations to apply
  59091. */
  59092. optimizations: SceneOptimization[];
  59093. /**
  59094. * Creates a new list of options used by SceneOptimizer
  59095. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59096. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  59097. */
  59098. constructor(
  59099. /**
  59100. * Defines the target frame rate to reach (60 by default)
  59101. */
  59102. targetFrameRate?: number,
  59103. /**
  59104. * Defines the interval between two checkes (2000ms by default)
  59105. */
  59106. trackerDuration?: number);
  59107. /**
  59108. * Add a new optimization
  59109. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59110. * @returns the current SceneOptimizerOptions
  59111. */
  59112. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59113. /**
  59114. * Add a new custom optimization
  59115. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59116. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59117. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59118. * @returns the current SceneOptimizerOptions
  59119. */
  59120. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59121. /**
  59122. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59123. * @param targetFrameRate defines the target frame rate (60 by default)
  59124. * @returns a SceneOptimizerOptions object
  59125. */
  59126. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59127. /**
  59128. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59129. * @param targetFrameRate defines the target frame rate (60 by default)
  59130. * @returns a SceneOptimizerOptions object
  59131. */
  59132. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59133. /**
  59134. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59135. * @param targetFrameRate defines the target frame rate (60 by default)
  59136. * @returns a SceneOptimizerOptions object
  59137. */
  59138. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59139. }
  59140. /**
  59141. * Class used to run optimizations in order to reach a target frame rate
  59142. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59143. */
  59144. export class SceneOptimizer implements IDisposable {
  59145. private _isRunning;
  59146. private _options;
  59147. private _scene;
  59148. private _currentPriorityLevel;
  59149. private _targetFrameRate;
  59150. private _trackerDuration;
  59151. private _currentFrameRate;
  59152. private _sceneDisposeObserver;
  59153. private _improvementMode;
  59154. /**
  59155. * Defines an observable called when the optimizer reaches the target frame rate
  59156. */
  59157. onSuccessObservable: Observable<SceneOptimizer>;
  59158. /**
  59159. * Defines an observable called when the optimizer enables an optimization
  59160. */
  59161. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59162. /**
  59163. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59164. */
  59165. onFailureObservable: Observable<SceneOptimizer>;
  59166. /**
  59167. * Gets a boolean indicating if the optimizer is in improvement mode
  59168. */
  59169. readonly isInImprovementMode: boolean;
  59170. /**
  59171. * Gets the current priority level (0 at start)
  59172. */
  59173. readonly currentPriorityLevel: number;
  59174. /**
  59175. * Gets the current frame rate checked by the SceneOptimizer
  59176. */
  59177. readonly currentFrameRate: number;
  59178. /**
  59179. * Gets or sets the current target frame rate (60 by default)
  59180. */
  59181. /**
  59182. * Gets or sets the current target frame rate (60 by default)
  59183. */
  59184. targetFrameRate: number;
  59185. /**
  59186. * Gets or sets the current interval between two checks (every 2000ms by default)
  59187. */
  59188. /**
  59189. * Gets or sets the current interval between two checks (every 2000ms by default)
  59190. */
  59191. trackerDuration: number;
  59192. /**
  59193. * Gets the list of active optimizations
  59194. */
  59195. readonly optimizations: SceneOptimization[];
  59196. /**
  59197. * Creates a new SceneOptimizer
  59198. * @param scene defines the scene to work on
  59199. * @param options defines the options to use with the SceneOptimizer
  59200. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59201. * @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)
  59202. */
  59203. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59204. /**
  59205. * Stops the current optimizer
  59206. */
  59207. stop(): void;
  59208. /**
  59209. * Reset the optimizer to initial step (current priority level = 0)
  59210. */
  59211. reset(): void;
  59212. /**
  59213. * Start the optimizer. By default it will try to reach a specific framerate
  59214. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59215. */
  59216. start(): void;
  59217. private _checkCurrentState;
  59218. /**
  59219. * Release all resources
  59220. */
  59221. dispose(): void;
  59222. /**
  59223. * Helper function to create a SceneOptimizer with one single line of code
  59224. * @param scene defines the scene to work on
  59225. * @param options defines the options to use with the SceneOptimizer
  59226. * @param onSuccess defines a callback to call on success
  59227. * @param onFailure defines a callback to call on failure
  59228. * @returns the new SceneOptimizer object
  59229. */
  59230. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59231. }
  59232. }
  59233. declare module "babylonjs/Misc/sceneSerializer" {
  59234. import { Scene } from "babylonjs/scene";
  59235. /**
  59236. * Class used to serialize a scene into a string
  59237. */
  59238. export class SceneSerializer {
  59239. /**
  59240. * Clear cache used by a previous serialization
  59241. */
  59242. static ClearCache(): void;
  59243. /**
  59244. * Serialize a scene into a JSON compatible object
  59245. * @param scene defines the scene to serialize
  59246. * @returns a JSON compatible object
  59247. */
  59248. static Serialize(scene: Scene): any;
  59249. /**
  59250. * Serialize a mesh into a JSON compatible object
  59251. * @param toSerialize defines the mesh to serialize
  59252. * @param withParents defines if parents must be serialized as well
  59253. * @param withChildren defines if children must be serialized as well
  59254. * @returns a JSON compatible object
  59255. */
  59256. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59257. }
  59258. }
  59259. declare module "babylonjs/Misc/textureTools" {
  59260. import { Texture } from "babylonjs/Materials/Textures/texture";
  59261. /**
  59262. * Class used to host texture specific utilities
  59263. */
  59264. export class TextureTools {
  59265. /**
  59266. * Uses the GPU to create a copy texture rescaled at a given size
  59267. * @param texture Texture to copy from
  59268. * @param width defines the desired width
  59269. * @param height defines the desired height
  59270. * @param useBilinearMode defines if bilinear mode has to be used
  59271. * @return the generated texture
  59272. */
  59273. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59274. }
  59275. }
  59276. declare module "babylonjs/Misc/videoRecorder" {
  59277. import { Nullable } from "babylonjs/types";
  59278. import { Engine } from "babylonjs/Engines/engine";
  59279. /**
  59280. * This represents the different options avilable for the video capture.
  59281. */
  59282. export interface VideoRecorderOptions {
  59283. /** Defines the mime type of the video */
  59284. mimeType: string;
  59285. /** Defines the video the video should be recorded at */
  59286. fps: number;
  59287. /** Defines the chunk size for the recording data */
  59288. recordChunckSize: number;
  59289. /** The audio tracks to attach to the record */
  59290. audioTracks?: MediaStreamTrack[];
  59291. }
  59292. /**
  59293. * This can helps recording videos from BabylonJS.
  59294. * This is based on the available WebRTC functionalities of the browser.
  59295. *
  59296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59297. */
  59298. export class VideoRecorder {
  59299. private static readonly _defaultOptions;
  59300. /**
  59301. * Returns wehther or not the VideoRecorder is available in your browser.
  59302. * @param engine Defines the Babylon Engine to check the support for
  59303. * @returns true if supported otherwise false
  59304. */
  59305. static IsSupported(engine: Engine): boolean;
  59306. private readonly _options;
  59307. private _canvas;
  59308. private _mediaRecorder;
  59309. private _recordedChunks;
  59310. private _fileName;
  59311. private _resolve;
  59312. private _reject;
  59313. /**
  59314. * True wether a recording is already in progress.
  59315. */
  59316. readonly isRecording: boolean;
  59317. /**
  59318. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59319. * a video file.
  59320. * @param engine Defines the BabylonJS Engine you wish to record
  59321. * @param options Defines options that can be used to customized the capture
  59322. */
  59323. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59324. /**
  59325. * Stops the current recording before the default capture timeout passed in the startRecording
  59326. * functions.
  59327. */
  59328. stopRecording(): void;
  59329. /**
  59330. * Starts recording the canvas for a max duration specified in parameters.
  59331. * @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.
  59332. * @param maxDuration Defines the maximum recording time in seconds.
  59333. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59334. * @return a promise callback at the end of the recording with the video data in Blob.
  59335. */
  59336. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59337. /**
  59338. * Releases internal resources used during the recording.
  59339. */
  59340. dispose(): void;
  59341. private _handleDataAvailable;
  59342. private _handleError;
  59343. private _handleStop;
  59344. }
  59345. }
  59346. declare module "babylonjs/Misc/screenshotTools" {
  59347. import { Camera } from "babylonjs/Cameras/camera";
  59348. import { Engine } from "babylonjs/Engines/engine";
  59349. /**
  59350. * Class containing a set of static utilities functions for screenshots
  59351. */
  59352. export class ScreenshotTools {
  59353. /**
  59354. * Captures a screenshot of the current rendering
  59355. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59356. * @param engine defines the rendering engine
  59357. * @param camera defines the source camera
  59358. * @param size This parameter can be set to a single number or to an object with the
  59359. * following (optional) properties: precision, width, height. If a single number is passed,
  59360. * it will be used for both width and height. If an object is passed, the screenshot size
  59361. * will be derived from the parameters. The precision property is a multiplier allowing
  59362. * rendering at a higher or lower resolution
  59363. * @param successCallback defines the callback receives a single parameter which contains the
  59364. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59365. * src parameter of an <img> to display it
  59366. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59367. * Check your browser for supported MIME types
  59368. */
  59369. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59370. /**
  59371. * Generates an image screenshot from the specified camera.
  59372. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59373. * @param engine The engine to use for rendering
  59374. * @param camera The camera to use for rendering
  59375. * @param size This parameter can be set to a single number or to an object with the
  59376. * following (optional) properties: precision, width, height. If a single number is passed,
  59377. * it will be used for both width and height. If an object is passed, the screenshot size
  59378. * will be derived from the parameters. The precision property is a multiplier allowing
  59379. * rendering at a higher or lower resolution
  59380. * @param successCallback The callback receives a single parameter which contains the
  59381. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59382. * src parameter of an <img> to display it
  59383. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59384. * Check your browser for supported MIME types
  59385. * @param samples Texture samples (default: 1)
  59386. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59387. * @param fileName A name for for the downloaded file.
  59388. */
  59389. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59390. }
  59391. }
  59392. declare module "babylonjs/Misc/index" {
  59393. export * from "babylonjs/Misc/andOrNotEvaluator";
  59394. export * from "babylonjs/Misc/assetsManager";
  59395. export * from "babylonjs/Misc/dds";
  59396. export * from "babylonjs/Misc/decorators";
  59397. export * from "babylonjs/Misc/deferred";
  59398. export * from "babylonjs/Misc/environmentTextureTools";
  59399. export * from "babylonjs/Misc/meshExploder";
  59400. export * from "babylonjs/Misc/filesInput";
  59401. export * from "babylonjs/Misc/HighDynamicRange/index";
  59402. export * from "babylonjs/Misc/khronosTextureContainer";
  59403. export * from "babylonjs/Misc/observable";
  59404. export * from "babylonjs/Misc/performanceMonitor";
  59405. export * from "babylonjs/Misc/promise";
  59406. export * from "babylonjs/Misc/sceneOptimizer";
  59407. export * from "babylonjs/Misc/sceneSerializer";
  59408. export * from "babylonjs/Misc/smartArray";
  59409. export * from "babylonjs/Misc/stringDictionary";
  59410. export * from "babylonjs/Misc/tags";
  59411. export * from "babylonjs/Misc/textureTools";
  59412. export * from "babylonjs/Misc/tga";
  59413. export * from "babylonjs/Misc/tools";
  59414. export * from "babylonjs/Misc/videoRecorder";
  59415. export * from "babylonjs/Misc/virtualJoystick";
  59416. export * from "babylonjs/Misc/workerPool";
  59417. export * from "babylonjs/Misc/logger";
  59418. export * from "babylonjs/Misc/typeStore";
  59419. export * from "babylonjs/Misc/filesInputStore";
  59420. export * from "babylonjs/Misc/deepCopier";
  59421. export * from "babylonjs/Misc/pivotTools";
  59422. export * from "babylonjs/Misc/precisionDate";
  59423. export * from "babylonjs/Misc/screenshotTools";
  59424. export * from "babylonjs/Misc/typeStore";
  59425. export * from "babylonjs/Misc/webRequest";
  59426. export * from "babylonjs/Misc/iInspectable";
  59427. }
  59428. declare module "babylonjs/index" {
  59429. export * from "babylonjs/abstractScene";
  59430. export * from "babylonjs/Actions/index";
  59431. export * from "babylonjs/Animations/index";
  59432. export * from "babylonjs/assetContainer";
  59433. export * from "babylonjs/Audio/index";
  59434. export * from "babylonjs/Behaviors/index";
  59435. export * from "babylonjs/Bones/index";
  59436. export * from "babylonjs/Cameras/index";
  59437. export * from "babylonjs/Collisions/index";
  59438. export * from "babylonjs/Culling/index";
  59439. export * from "babylonjs/Debug/index";
  59440. export * from "babylonjs/Engines/index";
  59441. export * from "babylonjs/Events/index";
  59442. export * from "babylonjs/Gamepads/index";
  59443. export * from "babylonjs/Gizmos/index";
  59444. export * from "babylonjs/Helpers/index";
  59445. export * from "babylonjs/Instrumentation/index";
  59446. export * from "babylonjs/Layers/index";
  59447. export * from "babylonjs/LensFlares/index";
  59448. export * from "babylonjs/Lights/index";
  59449. export * from "babylonjs/Loading/index";
  59450. export * from "babylonjs/Materials/index";
  59451. export * from "babylonjs/Maths/index";
  59452. export * from "babylonjs/Meshes/index";
  59453. export * from "babylonjs/Morph/index";
  59454. export * from "babylonjs/node";
  59455. export * from "babylonjs/Offline/index";
  59456. export * from "babylonjs/Particles/index";
  59457. export * from "babylonjs/Physics/index";
  59458. export * from "babylonjs/PostProcesses/index";
  59459. export * from "babylonjs/Probes/index";
  59460. export * from "babylonjs/Rendering/index";
  59461. export * from "babylonjs/scene";
  59462. export * from "babylonjs/sceneComponent";
  59463. export * from "babylonjs/Sprites/index";
  59464. export * from "babylonjs/States/index";
  59465. export * from "babylonjs/Misc/index";
  59466. export * from "babylonjs/types";
  59467. }
  59468. declare module "babylonjs/Animations/pathCursor" {
  59469. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59470. /**
  59471. * A cursor which tracks a point on a path
  59472. */
  59473. export class PathCursor {
  59474. private path;
  59475. /**
  59476. * Stores path cursor callbacks for when an onchange event is triggered
  59477. */
  59478. private _onchange;
  59479. /**
  59480. * The value of the path cursor
  59481. */
  59482. value: number;
  59483. /**
  59484. * The animation array of the path cursor
  59485. */
  59486. animations: Animation[];
  59487. /**
  59488. * Initializes the path cursor
  59489. * @param path The path to track
  59490. */
  59491. constructor(path: Path2);
  59492. /**
  59493. * Gets the cursor point on the path
  59494. * @returns A point on the path cursor at the cursor location
  59495. */
  59496. getPoint(): Vector3;
  59497. /**
  59498. * Moves the cursor ahead by the step amount
  59499. * @param step The amount to move the cursor forward
  59500. * @returns This path cursor
  59501. */
  59502. moveAhead(step?: number): PathCursor;
  59503. /**
  59504. * Moves the cursor behind by the step amount
  59505. * @param step The amount to move the cursor back
  59506. * @returns This path cursor
  59507. */
  59508. moveBack(step?: number): PathCursor;
  59509. /**
  59510. * Moves the cursor by the step amount
  59511. * If the step amount is greater than one, an exception is thrown
  59512. * @param step The amount to move the cursor
  59513. * @returns This path cursor
  59514. */
  59515. move(step: number): PathCursor;
  59516. /**
  59517. * Ensures that the value is limited between zero and one
  59518. * @returns This path cursor
  59519. */
  59520. private ensureLimits;
  59521. /**
  59522. * Runs onchange callbacks on change (used by the animation engine)
  59523. * @returns This path cursor
  59524. */
  59525. private raiseOnChange;
  59526. /**
  59527. * Executes a function on change
  59528. * @param f A path cursor onchange callback
  59529. * @returns This path cursor
  59530. */
  59531. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59532. }
  59533. }
  59534. declare module "babylonjs/Legacy/legacy" {
  59535. import * as Babylon from "babylonjs/index";
  59536. export * from "babylonjs/index";
  59537. }
  59538. declare module "babylonjs/Shaders/blur.fragment" {
  59539. /** @hidden */
  59540. export var blurPixelShader: {
  59541. name: string;
  59542. shader: string;
  59543. };
  59544. }
  59545. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59546. /** @hidden */
  59547. export var bones300Declaration: {
  59548. name: string;
  59549. shader: string;
  59550. };
  59551. }
  59552. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59553. /** @hidden */
  59554. export var instances300Declaration: {
  59555. name: string;
  59556. shader: string;
  59557. };
  59558. }
  59559. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59560. /** @hidden */
  59561. export var pointCloudVertexDeclaration: {
  59562. name: string;
  59563. shader: string;
  59564. };
  59565. }
  59566. // Mixins
  59567. interface Window {
  59568. mozIndexedDB: IDBFactory;
  59569. webkitIndexedDB: IDBFactory;
  59570. msIndexedDB: IDBFactory;
  59571. webkitURL: typeof URL;
  59572. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59573. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59574. WebGLRenderingContext: WebGLRenderingContext;
  59575. MSGesture: MSGesture;
  59576. CANNON: any;
  59577. AudioContext: AudioContext;
  59578. webkitAudioContext: AudioContext;
  59579. PointerEvent: any;
  59580. Math: Math;
  59581. Uint8Array: Uint8ArrayConstructor;
  59582. Float32Array: Float32ArrayConstructor;
  59583. mozURL: typeof URL;
  59584. msURL: typeof URL;
  59585. VRFrameData: any; // WebVR, from specs 1.1
  59586. DracoDecoderModule: any;
  59587. setImmediate(handler: (...args: any[]) => void): number;
  59588. }
  59589. interface HTMLCanvasElement {
  59590. requestPointerLock(): void;
  59591. msRequestPointerLock?(): void;
  59592. mozRequestPointerLock?(): void;
  59593. webkitRequestPointerLock?(): void;
  59594. /** Track wether a record is in progress */
  59595. isRecording: boolean;
  59596. /** Capture Stream method defined by some browsers */
  59597. captureStream(fps?: number): MediaStream;
  59598. }
  59599. interface CanvasRenderingContext2D {
  59600. msImageSmoothingEnabled: boolean;
  59601. }
  59602. interface MouseEvent {
  59603. mozMovementX: number;
  59604. mozMovementY: number;
  59605. webkitMovementX: number;
  59606. webkitMovementY: number;
  59607. msMovementX: number;
  59608. msMovementY: number;
  59609. }
  59610. interface Navigator {
  59611. mozGetVRDevices: (any: any) => any;
  59612. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59613. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59614. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59615. webkitGetGamepads(): Gamepad[];
  59616. msGetGamepads(): Gamepad[];
  59617. webkitGamepads(): Gamepad[];
  59618. }
  59619. interface HTMLVideoElement {
  59620. mozSrcObject: any;
  59621. }
  59622. interface Math {
  59623. fround(x: number): number;
  59624. imul(a: number, b: number): number;
  59625. }
  59626. interface WebGLRenderingContext {
  59627. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59628. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59629. vertexAttribDivisor(index: number, divisor: number): void;
  59630. createVertexArray(): any;
  59631. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59632. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59633. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59634. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59635. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59636. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59637. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59638. // Queries
  59639. createQuery(): WebGLQuery;
  59640. deleteQuery(query: WebGLQuery): void;
  59641. beginQuery(target: number, query: WebGLQuery): void;
  59642. endQuery(target: number): void;
  59643. getQueryParameter(query: WebGLQuery, pname: number): any;
  59644. getQuery(target: number, pname: number): any;
  59645. MAX_SAMPLES: number;
  59646. RGBA8: number;
  59647. READ_FRAMEBUFFER: number;
  59648. DRAW_FRAMEBUFFER: number;
  59649. UNIFORM_BUFFER: number;
  59650. HALF_FLOAT_OES: number;
  59651. RGBA16F: number;
  59652. RGBA32F: number;
  59653. R32F: number;
  59654. RG32F: number;
  59655. RGB32F: number;
  59656. R16F: number;
  59657. RG16F: number;
  59658. RGB16F: number;
  59659. RED: number;
  59660. RG: number;
  59661. R8: number;
  59662. RG8: number;
  59663. UNSIGNED_INT_24_8: number;
  59664. DEPTH24_STENCIL8: number;
  59665. /* Multiple Render Targets */
  59666. drawBuffers(buffers: number[]): void;
  59667. readBuffer(src: number): void;
  59668. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59669. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59670. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59671. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59672. // Occlusion Query
  59673. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59674. ANY_SAMPLES_PASSED: number;
  59675. QUERY_RESULT_AVAILABLE: number;
  59676. QUERY_RESULT: number;
  59677. }
  59678. interface WebGLProgram {
  59679. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59680. }
  59681. interface EXT_disjoint_timer_query {
  59682. QUERY_COUNTER_BITS_EXT: number;
  59683. TIME_ELAPSED_EXT: number;
  59684. TIMESTAMP_EXT: number;
  59685. GPU_DISJOINT_EXT: number;
  59686. QUERY_RESULT_EXT: number;
  59687. QUERY_RESULT_AVAILABLE_EXT: number;
  59688. queryCounterEXT(query: WebGLQuery, target: number): void;
  59689. createQueryEXT(): WebGLQuery;
  59690. beginQueryEXT(target: number, query: WebGLQuery): void;
  59691. endQueryEXT(target: number): void;
  59692. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59693. deleteQueryEXT(query: WebGLQuery): void;
  59694. }
  59695. interface WebGLUniformLocation {
  59696. _currentState: any;
  59697. }
  59698. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59699. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59700. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59701. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59702. interface WebGLRenderingContext {
  59703. readonly RASTERIZER_DISCARD: number;
  59704. readonly DEPTH_COMPONENT24: number;
  59705. readonly TEXTURE_3D: number;
  59706. readonly TEXTURE_2D_ARRAY: number;
  59707. readonly TEXTURE_COMPARE_FUNC: number;
  59708. readonly TEXTURE_COMPARE_MODE: number;
  59709. readonly COMPARE_REF_TO_TEXTURE: number;
  59710. readonly TEXTURE_WRAP_R: number;
  59711. readonly HALF_FLOAT: number;
  59712. readonly RGB8: number;
  59713. readonly RED_INTEGER: number;
  59714. readonly RG_INTEGER: number;
  59715. readonly RGB_INTEGER: number;
  59716. readonly RGBA_INTEGER: number;
  59717. readonly R8_SNORM: number;
  59718. readonly RG8_SNORM: number;
  59719. readonly RGB8_SNORM: number;
  59720. readonly RGBA8_SNORM: number;
  59721. readonly R8I: number;
  59722. readonly RG8I: number;
  59723. readonly RGB8I: number;
  59724. readonly RGBA8I: number;
  59725. readonly R8UI: number;
  59726. readonly RG8UI: number;
  59727. readonly RGB8UI: number;
  59728. readonly RGBA8UI: number;
  59729. readonly R16I: number;
  59730. readonly RG16I: number;
  59731. readonly RGB16I: number;
  59732. readonly RGBA16I: number;
  59733. readonly R16UI: number;
  59734. readonly RG16UI: number;
  59735. readonly RGB16UI: number;
  59736. readonly RGBA16UI: number;
  59737. readonly R32I: number;
  59738. readonly RG32I: number;
  59739. readonly RGB32I: number;
  59740. readonly RGBA32I: number;
  59741. readonly R32UI: number;
  59742. readonly RG32UI: number;
  59743. readonly RGB32UI: number;
  59744. readonly RGBA32UI: number;
  59745. readonly RGB10_A2UI: number;
  59746. readonly R11F_G11F_B10F: number;
  59747. readonly RGB9_E5: number;
  59748. readonly RGB10_A2: number;
  59749. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59750. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59751. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59752. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59753. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59754. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59755. 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;
  59756. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59757. readonly TRANSFORM_FEEDBACK: number;
  59758. readonly INTERLEAVED_ATTRIBS: number;
  59759. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59760. createTransformFeedback(): WebGLTransformFeedback;
  59761. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59762. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59763. beginTransformFeedback(primitiveMode: number): void;
  59764. endTransformFeedback(): void;
  59765. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59766. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59767. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59768. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59769. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59770. }
  59771. interface ImageBitmap {
  59772. readonly width: number;
  59773. readonly height: number;
  59774. close(): void;
  59775. }
  59776. interface WebGLQuery extends WebGLObject {
  59777. }
  59778. declare var WebGLQuery: {
  59779. prototype: WebGLQuery;
  59780. new(): WebGLQuery;
  59781. };
  59782. interface WebGLSampler extends WebGLObject {
  59783. }
  59784. declare var WebGLSampler: {
  59785. prototype: WebGLSampler;
  59786. new(): WebGLSampler;
  59787. };
  59788. interface WebGLSync extends WebGLObject {
  59789. }
  59790. declare var WebGLSync: {
  59791. prototype: WebGLSync;
  59792. new(): WebGLSync;
  59793. };
  59794. interface WebGLTransformFeedback extends WebGLObject {
  59795. }
  59796. declare var WebGLTransformFeedback: {
  59797. prototype: WebGLTransformFeedback;
  59798. new(): WebGLTransformFeedback;
  59799. };
  59800. interface WebGLVertexArrayObject extends WebGLObject {
  59801. }
  59802. declare var WebGLVertexArrayObject: {
  59803. prototype: WebGLVertexArrayObject;
  59804. new(): WebGLVertexArrayObject;
  59805. };
  59806. // Type definitions for WebVR API
  59807. // Project: https://w3c.github.io/webvr/
  59808. // Definitions by: six a <https://github.com/lostfictions>
  59809. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59810. interface VRDisplay extends EventTarget {
  59811. /**
  59812. * Dictionary of capabilities describing the VRDisplay.
  59813. */
  59814. readonly capabilities: VRDisplayCapabilities;
  59815. /**
  59816. * z-depth defining the far plane of the eye view frustum
  59817. * enables mapping of values in the render target depth
  59818. * attachment to scene coordinates. Initially set to 10000.0.
  59819. */
  59820. depthFar: number;
  59821. /**
  59822. * z-depth defining the near plane of the eye view frustum
  59823. * enables mapping of values in the render target depth
  59824. * attachment to scene coordinates. Initially set to 0.01.
  59825. */
  59826. depthNear: number;
  59827. /**
  59828. * An identifier for this distinct VRDisplay. Used as an
  59829. * association point in the Gamepad API.
  59830. */
  59831. readonly displayId: number;
  59832. /**
  59833. * A display name, a user-readable name identifying it.
  59834. */
  59835. readonly displayName: string;
  59836. readonly isConnected: boolean;
  59837. readonly isPresenting: boolean;
  59838. /**
  59839. * If this VRDisplay supports room-scale experiences, the optional
  59840. * stage attribute contains details on the room-scale parameters.
  59841. */
  59842. readonly stageParameters: VRStageParameters | null;
  59843. /**
  59844. * Passing the value returned by `requestAnimationFrame` to
  59845. * `cancelAnimationFrame` will unregister the callback.
  59846. * @param handle Define the hanle of the request to cancel
  59847. */
  59848. cancelAnimationFrame(handle: number): void;
  59849. /**
  59850. * Stops presenting to the VRDisplay.
  59851. * @returns a promise to know when it stopped
  59852. */
  59853. exitPresent(): Promise<void>;
  59854. /**
  59855. * Return the current VREyeParameters for the given eye.
  59856. * @param whichEye Define the eye we want the parameter for
  59857. * @returns the eye parameters
  59858. */
  59859. getEyeParameters(whichEye: string): VREyeParameters;
  59860. /**
  59861. * Populates the passed VRFrameData with the information required to render
  59862. * the current frame.
  59863. * @param frameData Define the data structure to populate
  59864. * @returns true if ok otherwise false
  59865. */
  59866. getFrameData(frameData: VRFrameData): boolean;
  59867. /**
  59868. * Get the layers currently being presented.
  59869. * @returns the list of VR layers
  59870. */
  59871. getLayers(): VRLayer[];
  59872. /**
  59873. * Return a VRPose containing the future predicted pose of the VRDisplay
  59874. * when the current frame will be presented. The value returned will not
  59875. * change until JavaScript has returned control to the browser.
  59876. *
  59877. * The VRPose will contain the position, orientation, velocity,
  59878. * and acceleration of each of these properties.
  59879. * @returns the pose object
  59880. */
  59881. getPose(): VRPose;
  59882. /**
  59883. * Return the current instantaneous pose of the VRDisplay, with no
  59884. * prediction applied.
  59885. * @returns the current instantaneous pose
  59886. */
  59887. getImmediatePose(): VRPose;
  59888. /**
  59889. * The callback passed to `requestAnimationFrame` will be called
  59890. * any time a new frame should be rendered. When the VRDisplay is
  59891. * presenting the callback will be called at the native refresh
  59892. * rate of the HMD. When not presenting this function acts
  59893. * identically to how window.requestAnimationFrame acts. Content should
  59894. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59895. * asynchronously from other displays and at differing refresh rates.
  59896. * @param callback Define the eaction to run next frame
  59897. * @returns the request handle it
  59898. */
  59899. requestAnimationFrame(callback: FrameRequestCallback): number;
  59900. /**
  59901. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59902. * Repeat calls while already presenting will update the VRLayers being displayed.
  59903. * @param layers Define the list of layer to present
  59904. * @returns a promise to know when the request has been fulfilled
  59905. */
  59906. requestPresent(layers: VRLayer[]): Promise<void>;
  59907. /**
  59908. * Reset the pose for this display, treating its current position and
  59909. * orientation as the "origin/zero" values. VRPose.position,
  59910. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59911. * updated when calling resetPose(). This should be called in only
  59912. * sitting-space experiences.
  59913. */
  59914. resetPose(): void;
  59915. /**
  59916. * The VRLayer provided to the VRDisplay will be captured and presented
  59917. * in the HMD. Calling this function has the same effect on the source
  59918. * canvas as any other operation that uses its source image, and canvases
  59919. * created without preserveDrawingBuffer set to true will be cleared.
  59920. * @param pose Define the pose to submit
  59921. */
  59922. submitFrame(pose?: VRPose): void;
  59923. }
  59924. declare var VRDisplay: {
  59925. prototype: VRDisplay;
  59926. new(): VRDisplay;
  59927. };
  59928. interface VRLayer {
  59929. leftBounds?: number[] | Float32Array | null;
  59930. rightBounds?: number[] | Float32Array | null;
  59931. source?: HTMLCanvasElement | null;
  59932. }
  59933. interface VRDisplayCapabilities {
  59934. readonly canPresent: boolean;
  59935. readonly hasExternalDisplay: boolean;
  59936. readonly hasOrientation: boolean;
  59937. readonly hasPosition: boolean;
  59938. readonly maxLayers: number;
  59939. }
  59940. interface VREyeParameters {
  59941. /** @deprecated */
  59942. readonly fieldOfView: VRFieldOfView;
  59943. readonly offset: Float32Array;
  59944. readonly renderHeight: number;
  59945. readonly renderWidth: number;
  59946. }
  59947. interface VRFieldOfView {
  59948. readonly downDegrees: number;
  59949. readonly leftDegrees: number;
  59950. readonly rightDegrees: number;
  59951. readonly upDegrees: number;
  59952. }
  59953. interface VRFrameData {
  59954. readonly leftProjectionMatrix: Float32Array;
  59955. readonly leftViewMatrix: Float32Array;
  59956. readonly pose: VRPose;
  59957. readonly rightProjectionMatrix: Float32Array;
  59958. readonly rightViewMatrix: Float32Array;
  59959. readonly timestamp: number;
  59960. }
  59961. interface VRPose {
  59962. readonly angularAcceleration: Float32Array | null;
  59963. readonly angularVelocity: Float32Array | null;
  59964. readonly linearAcceleration: Float32Array | null;
  59965. readonly linearVelocity: Float32Array | null;
  59966. readonly orientation: Float32Array | null;
  59967. readonly position: Float32Array | null;
  59968. readonly timestamp: number;
  59969. }
  59970. interface VRStageParameters {
  59971. sittingToStandingTransform?: Float32Array;
  59972. sizeX?: number;
  59973. sizeY?: number;
  59974. }
  59975. interface Navigator {
  59976. getVRDisplays(): Promise<VRDisplay[]>;
  59977. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59978. }
  59979. interface Window {
  59980. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59981. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59982. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59983. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59984. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59985. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59986. }
  59987. interface Gamepad {
  59988. readonly displayId: number;
  59989. }
  59990. interface XRDevice {
  59991. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59992. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59993. }
  59994. interface XRSession {
  59995. getInputSources(): Array<any>;
  59996. baseLayer: XRWebGLLayer;
  59997. requestFrameOfReference(type: string): Promise<void>;
  59998. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59999. end(): Promise<void>;
  60000. requestAnimationFrame: Function;
  60001. addEventListener: Function;
  60002. }
  60003. interface XRSessionCreationOptions {
  60004. outputContext?: WebGLRenderingContext | null;
  60005. immersive?: boolean;
  60006. environmentIntegration?: boolean;
  60007. }
  60008. interface XRLayer {
  60009. getViewport: Function;
  60010. framebufferWidth: number;
  60011. framebufferHeight: number;
  60012. }
  60013. interface XRView {
  60014. projectionMatrix: Float32Array;
  60015. }
  60016. interface XRFrame {
  60017. getDevicePose: Function;
  60018. getInputPose: Function;
  60019. views: Array<XRView>;
  60020. baseLayer: XRLayer;
  60021. }
  60022. interface XRFrameOfReference {
  60023. }
  60024. interface XRWebGLLayer extends XRLayer {
  60025. framebuffer: WebGLFramebuffer;
  60026. }
  60027. declare var XRWebGLLayer: {
  60028. prototype: XRWebGLLayer;
  60029. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  60030. };
  60031. declare module "babylonjs" {
  60032. export * from "babylonjs/Legacy/legacy";
  60033. }
  60034. declare module BABYLON {
  60035. /** Alias type for value that can be null */
  60036. export type Nullable<T> = T | null;
  60037. /**
  60038. * Alias type for number that are floats
  60039. * @ignorenaming
  60040. */
  60041. export type float = number;
  60042. /**
  60043. * Alias type for number that are doubles.
  60044. * @ignorenaming
  60045. */
  60046. export type double = number;
  60047. /**
  60048. * Alias type for number that are integer
  60049. * @ignorenaming
  60050. */
  60051. export type int = number;
  60052. /** Alias type for number array or Float32Array */
  60053. export type FloatArray = number[] | Float32Array;
  60054. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  60055. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  60056. /**
  60057. * Alias for types that can be used by a Buffer or VertexBuffer.
  60058. */
  60059. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  60060. /**
  60061. * Alias type for primitive types
  60062. * @ignorenaming
  60063. */
  60064. type Primitive = undefined | null | boolean | string | number | Function;
  60065. /**
  60066. * Type modifier to make all the properties of an object Readonly
  60067. */
  60068. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  60069. /**
  60070. * Type modifier to make all the properties of an object Readonly recursively
  60071. */
  60072. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  60073. /** @hidden */
  60074. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  60075. }
  60076. /** @hidden */
  60077. /** @hidden */
  60078. type DeepImmutableObject<T> = {
  60079. readonly [K in keyof T]: DeepImmutable<T[K]>;
  60080. };
  60081. }
  60082. declare module BABYLON {
  60083. /**
  60084. * Class containing a set of static utilities functions for arrays.
  60085. */
  60086. export class ArrayTools {
  60087. /**
  60088. * Returns an array of the given size filled with element built from the given constructor and the paramters
  60089. * @param size the number of element to construct and put in the array
  60090. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  60091. * @returns a new array filled with new objects
  60092. */
  60093. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  60094. }
  60095. }
  60096. declare module BABYLON {
  60097. /**
  60098. * Scalar computation library
  60099. */
  60100. export class Scalar {
  60101. /**
  60102. * Two pi constants convenient for computation.
  60103. */
  60104. static TwoPi: number;
  60105. /**
  60106. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60107. * @param a number
  60108. * @param b number
  60109. * @param epsilon (default = 1.401298E-45)
  60110. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60111. */
  60112. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  60113. /**
  60114. * Returns a string : the upper case translation of the number i to hexadecimal.
  60115. * @param i number
  60116. * @returns the upper case translation of the number i to hexadecimal.
  60117. */
  60118. static ToHex(i: number): string;
  60119. /**
  60120. * Returns -1 if value is negative and +1 is value is positive.
  60121. * @param value the value
  60122. * @returns the value itself if it's equal to zero.
  60123. */
  60124. static Sign(value: number): number;
  60125. /**
  60126. * Returns the value itself if it's between min and max.
  60127. * Returns min if the value is lower than min.
  60128. * Returns max if the value is greater than max.
  60129. * @param value the value to clmap
  60130. * @param min the min value to clamp to (default: 0)
  60131. * @param max the max value to clamp to (default: 1)
  60132. * @returns the clamped value
  60133. */
  60134. static Clamp(value: number, min?: number, max?: number): number;
  60135. /**
  60136. * the log2 of value.
  60137. * @param value the value to compute log2 of
  60138. * @returns the log2 of value.
  60139. */
  60140. static Log2(value: number): number;
  60141. /**
  60142. * Loops the value, so that it is never larger than length and never smaller than 0.
  60143. *
  60144. * This is similar to the modulo operator but it works with floating point numbers.
  60145. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60146. * With t = 5 and length = 2.5, the result would be 0.0.
  60147. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60148. * @param value the value
  60149. * @param length the length
  60150. * @returns the looped value
  60151. */
  60152. static Repeat(value: number, length: number): number;
  60153. /**
  60154. * Normalize the value between 0.0 and 1.0 using min and max values
  60155. * @param value value to normalize
  60156. * @param min max to normalize between
  60157. * @param max min to normalize between
  60158. * @returns the normalized value
  60159. */
  60160. static Normalize(value: number, min: number, max: number): number;
  60161. /**
  60162. * Denormalize the value from 0.0 and 1.0 using min and max values
  60163. * @param normalized value to denormalize
  60164. * @param min max to denormalize between
  60165. * @param max min to denormalize between
  60166. * @returns the denormalized value
  60167. */
  60168. static Denormalize(normalized: number, min: number, max: number): number;
  60169. /**
  60170. * Calculates the shortest difference between two given angles given in degrees.
  60171. * @param current current angle in degrees
  60172. * @param target target angle in degrees
  60173. * @returns the delta
  60174. */
  60175. static DeltaAngle(current: number, target: number): number;
  60176. /**
  60177. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60178. * @param tx value
  60179. * @param length length
  60180. * @returns The returned value will move back and forth between 0 and length
  60181. */
  60182. static PingPong(tx: number, length: number): number;
  60183. /**
  60184. * Interpolates between min and max with smoothing at the limits.
  60185. *
  60186. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60187. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60188. * @param from from
  60189. * @param to to
  60190. * @param tx value
  60191. * @returns the smooth stepped value
  60192. */
  60193. static SmoothStep(from: number, to: number, tx: number): number;
  60194. /**
  60195. * Moves a value current towards target.
  60196. *
  60197. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60198. * Negative values of maxDelta pushes the value away from target.
  60199. * @param current current value
  60200. * @param target target value
  60201. * @param maxDelta max distance to move
  60202. * @returns resulting value
  60203. */
  60204. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60205. /**
  60206. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60207. *
  60208. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60209. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60210. * @param current current value
  60211. * @param target target value
  60212. * @param maxDelta max distance to move
  60213. * @returns resulting angle
  60214. */
  60215. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60216. /**
  60217. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60218. * @param start start value
  60219. * @param end target value
  60220. * @param amount amount to lerp between
  60221. * @returns the lerped value
  60222. */
  60223. static Lerp(start: number, end: number, amount: number): number;
  60224. /**
  60225. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60226. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60227. * @param start start value
  60228. * @param end target value
  60229. * @param amount amount to lerp between
  60230. * @returns the lerped value
  60231. */
  60232. static LerpAngle(start: number, end: number, amount: number): number;
  60233. /**
  60234. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60235. * @param a start value
  60236. * @param b target value
  60237. * @param value value between a and b
  60238. * @returns the inverseLerp value
  60239. */
  60240. static InverseLerp(a: number, b: number, value: number): number;
  60241. /**
  60242. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60243. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60244. * @param value1 spline value
  60245. * @param tangent1 spline value
  60246. * @param value2 spline value
  60247. * @param tangent2 spline value
  60248. * @param amount input value
  60249. * @returns hermite result
  60250. */
  60251. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60252. /**
  60253. * Returns a random float number between and min and max values
  60254. * @param min min value of random
  60255. * @param max max value of random
  60256. * @returns random value
  60257. */
  60258. static RandomRange(min: number, max: number): number;
  60259. /**
  60260. * This function returns percentage of a number in a given range.
  60261. *
  60262. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60263. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60264. * @param number to convert to percentage
  60265. * @param min min range
  60266. * @param max max range
  60267. * @returns the percentage
  60268. */
  60269. static RangeToPercent(number: number, min: number, max: number): number;
  60270. /**
  60271. * This function returns number that corresponds to the percentage in a given range.
  60272. *
  60273. * PercentToRange(0.34,0,100) will return 34.
  60274. * @param percent to convert to number
  60275. * @param min min range
  60276. * @param max max range
  60277. * @returns the number
  60278. */
  60279. static PercentToRange(percent: number, min: number, max: number): number;
  60280. /**
  60281. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60282. * @param angle The angle to normalize in radian.
  60283. * @return The converted angle.
  60284. */
  60285. static NormalizeRadians(angle: number): number;
  60286. }
  60287. }
  60288. declare module BABYLON {
  60289. /**
  60290. * Constant used to convert a value to gamma space
  60291. * @ignorenaming
  60292. */
  60293. export const ToGammaSpace: number;
  60294. /**
  60295. * Constant used to convert a value to linear space
  60296. * @ignorenaming
  60297. */
  60298. export const ToLinearSpace = 2.2;
  60299. /**
  60300. * Constant used to define the minimal number value in Babylon.js
  60301. * @ignorenaming
  60302. */
  60303. let Epsilon: number;
  60304. /**
  60305. * Class used to hold a RBG color
  60306. */
  60307. export class Color3 {
  60308. /**
  60309. * Defines the red component (between 0 and 1, default is 0)
  60310. */
  60311. r: number;
  60312. /**
  60313. * Defines the green component (between 0 and 1, default is 0)
  60314. */
  60315. g: number;
  60316. /**
  60317. * Defines the blue component (between 0 and 1, default is 0)
  60318. */
  60319. b: number;
  60320. /**
  60321. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60322. * @param r defines the red component (between 0 and 1, default is 0)
  60323. * @param g defines the green component (between 0 and 1, default is 0)
  60324. * @param b defines the blue component (between 0 and 1, default is 0)
  60325. */
  60326. constructor(
  60327. /**
  60328. * Defines the red component (between 0 and 1, default is 0)
  60329. */
  60330. r?: number,
  60331. /**
  60332. * Defines the green component (between 0 and 1, default is 0)
  60333. */
  60334. g?: number,
  60335. /**
  60336. * Defines the blue component (between 0 and 1, default is 0)
  60337. */
  60338. b?: number);
  60339. /**
  60340. * Creates a string with the Color3 current values
  60341. * @returns the string representation of the Color3 object
  60342. */
  60343. toString(): string;
  60344. /**
  60345. * Returns the string "Color3"
  60346. * @returns "Color3"
  60347. */
  60348. getClassName(): string;
  60349. /**
  60350. * Compute the Color3 hash code
  60351. * @returns an unique number that can be used to hash Color3 objects
  60352. */
  60353. getHashCode(): number;
  60354. /**
  60355. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60356. * @param array defines the array where to store the r,g,b components
  60357. * @param index defines an optional index in the target array to define where to start storing values
  60358. * @returns the current Color3 object
  60359. */
  60360. toArray(array: FloatArray, index?: number): Color3;
  60361. /**
  60362. * Returns a new Color4 object from the current Color3 and the given alpha
  60363. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60364. * @returns a new Color4 object
  60365. */
  60366. toColor4(alpha?: number): Color4;
  60367. /**
  60368. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60369. * @returns the new array
  60370. */
  60371. asArray(): number[];
  60372. /**
  60373. * Returns the luminance value
  60374. * @returns a float value
  60375. */
  60376. toLuminance(): number;
  60377. /**
  60378. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60379. * @param otherColor defines the second operand
  60380. * @returns the new Color3 object
  60381. */
  60382. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60383. /**
  60384. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60385. * @param otherColor defines the second operand
  60386. * @param result defines the Color3 object where to store the result
  60387. * @returns the current Color3
  60388. */
  60389. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60390. /**
  60391. * Determines equality between Color3 objects
  60392. * @param otherColor defines the second operand
  60393. * @returns true if the rgb values are equal to the given ones
  60394. */
  60395. equals(otherColor: DeepImmutable<Color3>): boolean;
  60396. /**
  60397. * Determines equality between the current Color3 object and a set of r,b,g values
  60398. * @param r defines the red component to check
  60399. * @param g defines the green component to check
  60400. * @param b defines the blue component to check
  60401. * @returns true if the rgb values are equal to the given ones
  60402. */
  60403. equalsFloats(r: number, g: number, b: number): boolean;
  60404. /**
  60405. * Multiplies in place each rgb value by scale
  60406. * @param scale defines the scaling factor
  60407. * @returns the updated Color3
  60408. */
  60409. scale(scale: number): Color3;
  60410. /**
  60411. * Multiplies the rgb values by scale and stores the result into "result"
  60412. * @param scale defines the scaling factor
  60413. * @param result defines the Color3 object where to store the result
  60414. * @returns the unmodified current Color3
  60415. */
  60416. scaleToRef(scale: number, result: Color3): Color3;
  60417. /**
  60418. * Scale the current Color3 values by a factor and add the result to a given Color3
  60419. * @param scale defines the scale factor
  60420. * @param result defines color to store the result into
  60421. * @returns the unmodified current Color3
  60422. */
  60423. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60424. /**
  60425. * Clamps the rgb values by the min and max values and stores the result into "result"
  60426. * @param min defines minimum clamping value (default is 0)
  60427. * @param max defines maximum clamping value (default is 1)
  60428. * @param result defines color to store the result into
  60429. * @returns the original Color3
  60430. */
  60431. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60432. /**
  60433. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60434. * @param otherColor defines the second operand
  60435. * @returns the new Color3
  60436. */
  60437. add(otherColor: DeepImmutable<Color3>): Color3;
  60438. /**
  60439. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60440. * @param otherColor defines the second operand
  60441. * @param result defines Color3 object to store the result into
  60442. * @returns the unmodified current Color3
  60443. */
  60444. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60445. /**
  60446. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60447. * @param otherColor defines the second operand
  60448. * @returns the new Color3
  60449. */
  60450. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60451. /**
  60452. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60453. * @param otherColor defines the second operand
  60454. * @param result defines Color3 object to store the result into
  60455. * @returns the unmodified current Color3
  60456. */
  60457. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60458. /**
  60459. * Copy the current object
  60460. * @returns a new Color3 copied the current one
  60461. */
  60462. clone(): Color3;
  60463. /**
  60464. * Copies the rgb values from the source in the current Color3
  60465. * @param source defines the source Color3 object
  60466. * @returns the updated Color3 object
  60467. */
  60468. copyFrom(source: DeepImmutable<Color3>): Color3;
  60469. /**
  60470. * Updates the Color3 rgb values from the given floats
  60471. * @param r defines the red component to read from
  60472. * @param g defines the green component to read from
  60473. * @param b defines the blue component to read from
  60474. * @returns the current Color3 object
  60475. */
  60476. copyFromFloats(r: number, g: number, b: number): Color3;
  60477. /**
  60478. * Updates the Color3 rgb values from the given floats
  60479. * @param r defines the red component to read from
  60480. * @param g defines the green component to read from
  60481. * @param b defines the blue component to read from
  60482. * @returns the current Color3 object
  60483. */
  60484. set(r: number, g: number, b: number): Color3;
  60485. /**
  60486. * Compute the Color3 hexadecimal code as a string
  60487. * @returns a string containing the hexadecimal representation of the Color3 object
  60488. */
  60489. toHexString(): string;
  60490. /**
  60491. * Computes a new Color3 converted from the current one to linear space
  60492. * @returns a new Color3 object
  60493. */
  60494. toLinearSpace(): Color3;
  60495. /**
  60496. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60497. * @param convertedColor defines the Color3 object where to store the linear space version
  60498. * @returns the unmodified Color3
  60499. */
  60500. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60501. /**
  60502. * Computes a new Color3 converted from the current one to gamma space
  60503. * @returns a new Color3 object
  60504. */
  60505. toGammaSpace(): Color3;
  60506. /**
  60507. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60508. * @param convertedColor defines the Color3 object where to store the gamma space version
  60509. * @returns the unmodified Color3
  60510. */
  60511. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60512. private static _BlackReadOnly;
  60513. /**
  60514. * Creates a new Color3 from the string containing valid hexadecimal values
  60515. * @param hex defines a string containing valid hexadecimal values
  60516. * @returns a new Color3 object
  60517. */
  60518. static FromHexString(hex: string): Color3;
  60519. /**
  60520. * Creates a new Color3 from the starting index of the given array
  60521. * @param array defines the source array
  60522. * @param offset defines an offset in the source array
  60523. * @returns a new Color3 object
  60524. */
  60525. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60526. /**
  60527. * Creates a new Color3 from integer values (< 256)
  60528. * @param r defines the red component to read from (value between 0 and 255)
  60529. * @param g defines the green component to read from (value between 0 and 255)
  60530. * @param b defines the blue component to read from (value between 0 and 255)
  60531. * @returns a new Color3 object
  60532. */
  60533. static FromInts(r: number, g: number, b: number): Color3;
  60534. /**
  60535. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60536. * @param start defines the start Color3 value
  60537. * @param end defines the end Color3 value
  60538. * @param amount defines the gradient value between start and end
  60539. * @returns a new Color3 object
  60540. */
  60541. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60542. /**
  60543. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60544. * @param left defines the start value
  60545. * @param right defines the end value
  60546. * @param amount defines the gradient factor
  60547. * @param result defines the Color3 object where to store the result
  60548. */
  60549. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60550. /**
  60551. * Returns a Color3 value containing a red color
  60552. * @returns a new Color3 object
  60553. */
  60554. static Red(): Color3;
  60555. /**
  60556. * Returns a Color3 value containing a green color
  60557. * @returns a new Color3 object
  60558. */
  60559. static Green(): Color3;
  60560. /**
  60561. * Returns a Color3 value containing a blue color
  60562. * @returns a new Color3 object
  60563. */
  60564. static Blue(): Color3;
  60565. /**
  60566. * Returns a Color3 value containing a black color
  60567. * @returns a new Color3 object
  60568. */
  60569. static Black(): Color3;
  60570. /**
  60571. * Gets a Color3 value containing a black color that must not be updated
  60572. */
  60573. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60574. /**
  60575. * Returns a Color3 value containing a white color
  60576. * @returns a new Color3 object
  60577. */
  60578. static White(): Color3;
  60579. /**
  60580. * Returns a Color3 value containing a purple color
  60581. * @returns a new Color3 object
  60582. */
  60583. static Purple(): Color3;
  60584. /**
  60585. * Returns a Color3 value containing a magenta color
  60586. * @returns a new Color3 object
  60587. */
  60588. static Magenta(): Color3;
  60589. /**
  60590. * Returns a Color3 value containing a yellow color
  60591. * @returns a new Color3 object
  60592. */
  60593. static Yellow(): Color3;
  60594. /**
  60595. * Returns a Color3 value containing a gray color
  60596. * @returns a new Color3 object
  60597. */
  60598. static Gray(): Color3;
  60599. /**
  60600. * Returns a Color3 value containing a teal color
  60601. * @returns a new Color3 object
  60602. */
  60603. static Teal(): Color3;
  60604. /**
  60605. * Returns a Color3 value containing a random color
  60606. * @returns a new Color3 object
  60607. */
  60608. static Random(): Color3;
  60609. }
  60610. /**
  60611. * Class used to hold a RBGA color
  60612. */
  60613. export class Color4 {
  60614. /**
  60615. * Defines the red component (between 0 and 1, default is 0)
  60616. */
  60617. r: number;
  60618. /**
  60619. * Defines the green component (between 0 and 1, default is 0)
  60620. */
  60621. g: number;
  60622. /**
  60623. * Defines the blue component (between 0 and 1, default is 0)
  60624. */
  60625. b: number;
  60626. /**
  60627. * Defines the alpha component (between 0 and 1, default is 1)
  60628. */
  60629. a: number;
  60630. /**
  60631. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60632. * @param r defines the red component (between 0 and 1, default is 0)
  60633. * @param g defines the green component (between 0 and 1, default is 0)
  60634. * @param b defines the blue component (between 0 and 1, default is 0)
  60635. * @param a defines the alpha component (between 0 and 1, default is 1)
  60636. */
  60637. constructor(
  60638. /**
  60639. * Defines the red component (between 0 and 1, default is 0)
  60640. */
  60641. r?: number,
  60642. /**
  60643. * Defines the green component (between 0 and 1, default is 0)
  60644. */
  60645. g?: number,
  60646. /**
  60647. * Defines the blue component (between 0 and 1, default is 0)
  60648. */
  60649. b?: number,
  60650. /**
  60651. * Defines the alpha component (between 0 and 1, default is 1)
  60652. */
  60653. a?: number);
  60654. /**
  60655. * Adds in place the given Color4 values to the current Color4 object
  60656. * @param right defines the second operand
  60657. * @returns the current updated Color4 object
  60658. */
  60659. addInPlace(right: DeepImmutable<Color4>): Color4;
  60660. /**
  60661. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60662. * @returns the new array
  60663. */
  60664. asArray(): number[];
  60665. /**
  60666. * Stores from the starting index in the given array the Color4 successive values
  60667. * @param array defines the array where to store the r,g,b components
  60668. * @param index defines an optional index in the target array to define where to start storing values
  60669. * @returns the current Color4 object
  60670. */
  60671. toArray(array: number[], index?: number): Color4;
  60672. /**
  60673. * Determines equality between Color4 objects
  60674. * @param otherColor defines the second operand
  60675. * @returns true if the rgba values are equal to the given ones
  60676. */
  60677. equals(otherColor: DeepImmutable<Color4>): boolean;
  60678. /**
  60679. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60680. * @param right defines the second operand
  60681. * @returns a new Color4 object
  60682. */
  60683. add(right: DeepImmutable<Color4>): Color4;
  60684. /**
  60685. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60686. * @param right defines the second operand
  60687. * @returns a new Color4 object
  60688. */
  60689. subtract(right: DeepImmutable<Color4>): Color4;
  60690. /**
  60691. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60692. * @param right defines the second operand
  60693. * @param result defines the Color4 object where to store the result
  60694. * @returns the current Color4 object
  60695. */
  60696. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60697. /**
  60698. * Creates a new Color4 with the current Color4 values multiplied by scale
  60699. * @param scale defines the scaling factor to apply
  60700. * @returns a new Color4 object
  60701. */
  60702. scale(scale: number): Color4;
  60703. /**
  60704. * Multiplies the current Color4 values by scale and stores the result in "result"
  60705. * @param scale defines the scaling factor to apply
  60706. * @param result defines the Color4 object where to store the result
  60707. * @returns the current unmodified Color4
  60708. */
  60709. scaleToRef(scale: number, result: Color4): Color4;
  60710. /**
  60711. * Scale the current Color4 values by a factor and add the result to a given Color4
  60712. * @param scale defines the scale factor
  60713. * @param result defines the Color4 object where to store the result
  60714. * @returns the unmodified current Color4
  60715. */
  60716. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60717. /**
  60718. * Clamps the rgb values by the min and max values and stores the result into "result"
  60719. * @param min defines minimum clamping value (default is 0)
  60720. * @param max defines maximum clamping value (default is 1)
  60721. * @param result defines color to store the result into.
  60722. * @returns the cuurent Color4
  60723. */
  60724. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60725. /**
  60726. * Multipy an Color4 value by another and return a new Color4 object
  60727. * @param color defines the Color4 value to multiply by
  60728. * @returns a new Color4 object
  60729. */
  60730. multiply(color: Color4): Color4;
  60731. /**
  60732. * Multipy a Color4 value by another and push the result in a reference value
  60733. * @param color defines the Color4 value to multiply by
  60734. * @param result defines the Color4 to fill the result in
  60735. * @returns the result Color4
  60736. */
  60737. multiplyToRef(color: Color4, result: Color4): Color4;
  60738. /**
  60739. * Creates a string with the Color4 current values
  60740. * @returns the string representation of the Color4 object
  60741. */
  60742. toString(): string;
  60743. /**
  60744. * Returns the string "Color4"
  60745. * @returns "Color4"
  60746. */
  60747. getClassName(): string;
  60748. /**
  60749. * Compute the Color4 hash code
  60750. * @returns an unique number that can be used to hash Color4 objects
  60751. */
  60752. getHashCode(): number;
  60753. /**
  60754. * Creates a new Color4 copied from the current one
  60755. * @returns a new Color4 object
  60756. */
  60757. clone(): Color4;
  60758. /**
  60759. * Copies the given Color4 values into the current one
  60760. * @param source defines the source Color4 object
  60761. * @returns the current updated Color4 object
  60762. */
  60763. copyFrom(source: Color4): Color4;
  60764. /**
  60765. * Copies the given float values into the current one
  60766. * @param r defines the red component to read from
  60767. * @param g defines the green component to read from
  60768. * @param b defines the blue component to read from
  60769. * @param a defines the alpha component to read from
  60770. * @returns the current updated Color4 object
  60771. */
  60772. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60773. /**
  60774. * Copies the given float values into the current one
  60775. * @param r defines the red component to read from
  60776. * @param g defines the green component to read from
  60777. * @param b defines the blue component to read from
  60778. * @param a defines the alpha component to read from
  60779. * @returns the current updated Color4 object
  60780. */
  60781. set(r: number, g: number, b: number, a: number): Color4;
  60782. /**
  60783. * Compute the Color4 hexadecimal code as a string
  60784. * @returns a string containing the hexadecimal representation of the Color4 object
  60785. */
  60786. toHexString(): string;
  60787. /**
  60788. * Computes a new Color4 converted from the current one to linear space
  60789. * @returns a new Color4 object
  60790. */
  60791. toLinearSpace(): Color4;
  60792. /**
  60793. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60794. * @param convertedColor defines the Color4 object where to store the linear space version
  60795. * @returns the unmodified Color4
  60796. */
  60797. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60798. /**
  60799. * Computes a new Color4 converted from the current one to gamma space
  60800. * @returns a new Color4 object
  60801. */
  60802. toGammaSpace(): Color4;
  60803. /**
  60804. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60805. * @param convertedColor defines the Color4 object where to store the gamma space version
  60806. * @returns the unmodified Color4
  60807. */
  60808. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60809. /**
  60810. * Creates a new Color4 from the string containing valid hexadecimal values
  60811. * @param hex defines a string containing valid hexadecimal values
  60812. * @returns a new Color4 object
  60813. */
  60814. static FromHexString(hex: string): Color4;
  60815. /**
  60816. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60817. * @param left defines the start value
  60818. * @param right defines the end value
  60819. * @param amount defines the gradient factor
  60820. * @returns a new Color4 object
  60821. */
  60822. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60823. /**
  60824. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60825. * @param left defines the start value
  60826. * @param right defines the end value
  60827. * @param amount defines the gradient factor
  60828. * @param result defines the Color4 object where to store data
  60829. */
  60830. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60831. /**
  60832. * Creates a new Color4 from a Color3 and an alpha value
  60833. * @param color3 defines the source Color3 to read from
  60834. * @param alpha defines the alpha component (1.0 by default)
  60835. * @returns a new Color4 object
  60836. */
  60837. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60838. /**
  60839. * Creates a new Color4 from the starting index element of the given array
  60840. * @param array defines the source array to read from
  60841. * @param offset defines the offset in the source array
  60842. * @returns a new Color4 object
  60843. */
  60844. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60845. /**
  60846. * Creates a new Color3 from integer values (< 256)
  60847. * @param r defines the red component to read from (value between 0 and 255)
  60848. * @param g defines the green component to read from (value between 0 and 255)
  60849. * @param b defines the blue component to read from (value between 0 and 255)
  60850. * @param a defines the alpha component to read from (value between 0 and 255)
  60851. * @returns a new Color3 object
  60852. */
  60853. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60854. /**
  60855. * Check the content of a given array and convert it to an array containing RGBA data
  60856. * If the original array was already containing count * 4 values then it is returned directly
  60857. * @param colors defines the array to check
  60858. * @param count defines the number of RGBA data to expect
  60859. * @returns an array containing count * 4 values (RGBA)
  60860. */
  60861. static CheckColors4(colors: number[], count: number): number[];
  60862. }
  60863. /**
  60864. * Class representing a vector containing 2 coordinates
  60865. */
  60866. export class Vector2 {
  60867. /** defines the first coordinate */
  60868. x: number;
  60869. /** defines the second coordinate */
  60870. y: number;
  60871. /**
  60872. * Creates a new Vector2 from the given x and y coordinates
  60873. * @param x defines the first coordinate
  60874. * @param y defines the second coordinate
  60875. */
  60876. constructor(
  60877. /** defines the first coordinate */
  60878. x?: number,
  60879. /** defines the second coordinate */
  60880. y?: number);
  60881. /**
  60882. * Gets a string with the Vector2 coordinates
  60883. * @returns a string with the Vector2 coordinates
  60884. */
  60885. toString(): string;
  60886. /**
  60887. * Gets class name
  60888. * @returns the string "Vector2"
  60889. */
  60890. getClassName(): string;
  60891. /**
  60892. * Gets current vector hash code
  60893. * @returns the Vector2 hash code as a number
  60894. */
  60895. getHashCode(): number;
  60896. /**
  60897. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60898. * @param array defines the source array
  60899. * @param index defines the offset in source array
  60900. * @returns the current Vector2
  60901. */
  60902. toArray(array: FloatArray, index?: number): Vector2;
  60903. /**
  60904. * Copy the current vector to an array
  60905. * @returns a new array with 2 elements: the Vector2 coordinates.
  60906. */
  60907. asArray(): number[];
  60908. /**
  60909. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60910. * @param source defines the source Vector2
  60911. * @returns the current updated Vector2
  60912. */
  60913. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60914. /**
  60915. * Sets the Vector2 coordinates with the given floats
  60916. * @param x defines the first coordinate
  60917. * @param y defines the second coordinate
  60918. * @returns the current updated Vector2
  60919. */
  60920. copyFromFloats(x: number, y: number): Vector2;
  60921. /**
  60922. * Sets the Vector2 coordinates with the given floats
  60923. * @param x defines the first coordinate
  60924. * @param y defines the second coordinate
  60925. * @returns the current updated Vector2
  60926. */
  60927. set(x: number, y: number): Vector2;
  60928. /**
  60929. * Add another vector with the current one
  60930. * @param otherVector defines the other vector
  60931. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60932. */
  60933. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60934. /**
  60935. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60936. * @param otherVector defines the other vector
  60937. * @param result defines the target vector
  60938. * @returns the unmodified current Vector2
  60939. */
  60940. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60941. /**
  60942. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60943. * @param otherVector defines the other vector
  60944. * @returns the current updated Vector2
  60945. */
  60946. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60947. /**
  60948. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60949. * @param otherVector defines the other vector
  60950. * @returns a new Vector2
  60951. */
  60952. addVector3(otherVector: Vector3): Vector2;
  60953. /**
  60954. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60955. * @param otherVector defines the other vector
  60956. * @returns a new Vector2
  60957. */
  60958. subtract(otherVector: Vector2): Vector2;
  60959. /**
  60960. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60961. * @param otherVector defines the other vector
  60962. * @param result defines the target vector
  60963. * @returns the unmodified current Vector2
  60964. */
  60965. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60966. /**
  60967. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60968. * @param otherVector defines the other vector
  60969. * @returns the current updated Vector2
  60970. */
  60971. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60972. /**
  60973. * Multiplies in place the current Vector2 coordinates by the given ones
  60974. * @param otherVector defines the other vector
  60975. * @returns the current updated Vector2
  60976. */
  60977. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60978. /**
  60979. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60980. * @param otherVector defines the other vector
  60981. * @returns a new Vector2
  60982. */
  60983. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60984. /**
  60985. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60986. * @param otherVector defines the other vector
  60987. * @param result defines the target vector
  60988. * @returns the unmodified current Vector2
  60989. */
  60990. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60991. /**
  60992. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60993. * @param x defines the first coordinate
  60994. * @param y defines the second coordinate
  60995. * @returns a new Vector2
  60996. */
  60997. multiplyByFloats(x: number, y: number): Vector2;
  60998. /**
  60999. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  61000. * @param otherVector defines the other vector
  61001. * @returns a new Vector2
  61002. */
  61003. divide(otherVector: Vector2): Vector2;
  61004. /**
  61005. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  61006. * @param otherVector defines the other vector
  61007. * @param result defines the target vector
  61008. * @returns the unmodified current Vector2
  61009. */
  61010. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  61011. /**
  61012. * Divides the current Vector2 coordinates by the given ones
  61013. * @param otherVector defines the other vector
  61014. * @returns the current updated Vector2
  61015. */
  61016. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  61017. /**
  61018. * Gets a new Vector2 with current Vector2 negated coordinates
  61019. * @returns a new Vector2
  61020. */
  61021. negate(): Vector2;
  61022. /**
  61023. * Multiply the Vector2 coordinates by scale
  61024. * @param scale defines the scaling factor
  61025. * @returns the current updated Vector2
  61026. */
  61027. scaleInPlace(scale: number): Vector2;
  61028. /**
  61029. * Returns a new Vector2 scaled by "scale" from the current Vector2
  61030. * @param scale defines the scaling factor
  61031. * @returns a new Vector2
  61032. */
  61033. scale(scale: number): Vector2;
  61034. /**
  61035. * Scale the current Vector2 values by a factor to a given Vector2
  61036. * @param scale defines the scale factor
  61037. * @param result defines the Vector2 object where to store the result
  61038. * @returns the unmodified current Vector2
  61039. */
  61040. scaleToRef(scale: number, result: Vector2): Vector2;
  61041. /**
  61042. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  61043. * @param scale defines the scale factor
  61044. * @param result defines the Vector2 object where to store the result
  61045. * @returns the unmodified current Vector2
  61046. */
  61047. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  61048. /**
  61049. * Gets a boolean if two vectors are equals
  61050. * @param otherVector defines the other vector
  61051. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  61052. */
  61053. equals(otherVector: DeepImmutable<Vector2>): boolean;
  61054. /**
  61055. * Gets a boolean if two vectors are equals (using an epsilon value)
  61056. * @param otherVector defines the other vector
  61057. * @param epsilon defines the minimal distance to consider equality
  61058. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  61059. */
  61060. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  61061. /**
  61062. * Gets a new Vector2 from current Vector2 floored values
  61063. * @returns a new Vector2
  61064. */
  61065. floor(): Vector2;
  61066. /**
  61067. * Gets a new Vector2 from current Vector2 floored values
  61068. * @returns a new Vector2
  61069. */
  61070. fract(): Vector2;
  61071. /**
  61072. * Gets the length of the vector
  61073. * @returns the vector length (float)
  61074. */
  61075. length(): number;
  61076. /**
  61077. * Gets the vector squared length
  61078. * @returns the vector squared length (float)
  61079. */
  61080. lengthSquared(): number;
  61081. /**
  61082. * Normalize the vector
  61083. * @returns the current updated Vector2
  61084. */
  61085. normalize(): Vector2;
  61086. /**
  61087. * Gets a new Vector2 copied from the Vector2
  61088. * @returns a new Vector2
  61089. */
  61090. clone(): Vector2;
  61091. /**
  61092. * Gets a new Vector2(0, 0)
  61093. * @returns a new Vector2
  61094. */
  61095. static Zero(): Vector2;
  61096. /**
  61097. * Gets a new Vector2(1, 1)
  61098. * @returns a new Vector2
  61099. */
  61100. static One(): Vector2;
  61101. /**
  61102. * Gets a new Vector2 set from the given index element of the given array
  61103. * @param array defines the data source
  61104. * @param offset defines the offset in the data source
  61105. * @returns a new Vector2
  61106. */
  61107. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  61108. /**
  61109. * Sets "result" from the given index element of the given array
  61110. * @param array defines the data source
  61111. * @param offset defines the offset in the data source
  61112. * @param result defines the target vector
  61113. */
  61114. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  61115. /**
  61116. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  61117. * @param value1 defines 1st point of control
  61118. * @param value2 defines 2nd point of control
  61119. * @param value3 defines 3rd point of control
  61120. * @param value4 defines 4th point of control
  61121. * @param amount defines the interpolation factor
  61122. * @returns a new Vector2
  61123. */
  61124. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61125. /**
  61126. * 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".
  61127. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61128. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61129. * @param value defines the value to clamp
  61130. * @param min defines the lower limit
  61131. * @param max defines the upper limit
  61132. * @returns a new Vector2
  61133. */
  61134. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61135. /**
  61136. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61137. * @param value1 defines the 1st control point
  61138. * @param tangent1 defines the outgoing tangent
  61139. * @param value2 defines the 2nd control point
  61140. * @param tangent2 defines the incoming tangent
  61141. * @param amount defines the interpolation factor
  61142. * @returns a new Vector2
  61143. */
  61144. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61145. /**
  61146. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61147. * @param start defines the start vector
  61148. * @param end defines the end vector
  61149. * @param amount defines the interpolation factor
  61150. * @returns a new Vector2
  61151. */
  61152. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61153. /**
  61154. * Gets the dot product of the vector "left" and the vector "right"
  61155. * @param left defines first vector
  61156. * @param right defines second vector
  61157. * @returns the dot product (float)
  61158. */
  61159. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61160. /**
  61161. * Returns a new Vector2 equal to the normalized given vector
  61162. * @param vector defines the vector to normalize
  61163. * @returns a new Vector2
  61164. */
  61165. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61166. /**
  61167. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61168. * @param left defines 1st vector
  61169. * @param right defines 2nd vector
  61170. * @returns a new Vector2
  61171. */
  61172. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61173. /**
  61174. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61175. * @param left defines 1st vector
  61176. * @param right defines 2nd vector
  61177. * @returns a new Vector2
  61178. */
  61179. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61180. /**
  61181. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61182. * @param vector defines the vector to transform
  61183. * @param transformation defines the matrix to apply
  61184. * @returns a new Vector2
  61185. */
  61186. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61187. /**
  61188. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61189. * @param vector defines the vector to transform
  61190. * @param transformation defines the matrix to apply
  61191. * @param result defines the target vector
  61192. */
  61193. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61194. /**
  61195. * Determines if a given vector is included in a triangle
  61196. * @param p defines the vector to test
  61197. * @param p0 defines 1st triangle point
  61198. * @param p1 defines 2nd triangle point
  61199. * @param p2 defines 3rd triangle point
  61200. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61201. */
  61202. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61203. /**
  61204. * Gets the distance between the vectors "value1" and "value2"
  61205. * @param value1 defines first vector
  61206. * @param value2 defines second vector
  61207. * @returns the distance between vectors
  61208. */
  61209. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61210. /**
  61211. * Returns the squared distance between the vectors "value1" and "value2"
  61212. * @param value1 defines first vector
  61213. * @param value2 defines second vector
  61214. * @returns the squared distance between vectors
  61215. */
  61216. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61217. /**
  61218. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61219. * @param value1 defines first vector
  61220. * @param value2 defines second vector
  61221. * @returns a new Vector2
  61222. */
  61223. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61224. /**
  61225. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61226. * @param p defines the middle point
  61227. * @param segA defines one point of the segment
  61228. * @param segB defines the other point of the segment
  61229. * @returns the shortest distance
  61230. */
  61231. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61232. }
  61233. /**
  61234. * Classed used to store (x,y,z) vector representation
  61235. * A Vector3 is the main object used in 3D geometry
  61236. * It can represent etiher the coordinates of a point the space, either a direction
  61237. * Reminder: js uses a left handed forward facing system
  61238. */
  61239. export class Vector3 {
  61240. /**
  61241. * Defines the first coordinates (on X axis)
  61242. */
  61243. x: number;
  61244. /**
  61245. * Defines the second coordinates (on Y axis)
  61246. */
  61247. y: number;
  61248. /**
  61249. * Defines the third coordinates (on Z axis)
  61250. */
  61251. z: number;
  61252. private static _UpReadOnly;
  61253. /**
  61254. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61255. * @param x defines the first coordinates (on X axis)
  61256. * @param y defines the second coordinates (on Y axis)
  61257. * @param z defines the third coordinates (on Z axis)
  61258. */
  61259. constructor(
  61260. /**
  61261. * Defines the first coordinates (on X axis)
  61262. */
  61263. x?: number,
  61264. /**
  61265. * Defines the second coordinates (on Y axis)
  61266. */
  61267. y?: number,
  61268. /**
  61269. * Defines the third coordinates (on Z axis)
  61270. */
  61271. z?: number);
  61272. /**
  61273. * Creates a string representation of the Vector3
  61274. * @returns a string with the Vector3 coordinates.
  61275. */
  61276. toString(): string;
  61277. /**
  61278. * Gets the class name
  61279. * @returns the string "Vector3"
  61280. */
  61281. getClassName(): string;
  61282. /**
  61283. * Creates the Vector3 hash code
  61284. * @returns a number which tends to be unique between Vector3 instances
  61285. */
  61286. getHashCode(): number;
  61287. /**
  61288. * Creates an array containing three elements : the coordinates of the Vector3
  61289. * @returns a new array of numbers
  61290. */
  61291. asArray(): number[];
  61292. /**
  61293. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61294. * @param array defines the destination array
  61295. * @param index defines the offset in the destination array
  61296. * @returns the current Vector3
  61297. */
  61298. toArray(array: FloatArray, index?: number): Vector3;
  61299. /**
  61300. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61301. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61302. */
  61303. toQuaternion(): Quaternion;
  61304. /**
  61305. * Adds the given vector to the current Vector3
  61306. * @param otherVector defines the second operand
  61307. * @returns the current updated Vector3
  61308. */
  61309. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61310. /**
  61311. * Adds the given coordinates to the current Vector3
  61312. * @param x defines the x coordinate of the operand
  61313. * @param y defines the y coordinate of the operand
  61314. * @param z defines the z coordinate of the operand
  61315. * @returns the current updated Vector3
  61316. */
  61317. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61318. /**
  61319. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61320. * @param otherVector defines the second operand
  61321. * @returns the resulting Vector3
  61322. */
  61323. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61324. /**
  61325. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61326. * @param otherVector defines the second operand
  61327. * @param result defines the Vector3 object where to store the result
  61328. * @returns the current Vector3
  61329. */
  61330. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61331. /**
  61332. * Subtract the given vector from the current Vector3
  61333. * @param otherVector defines the second operand
  61334. * @returns the current updated Vector3
  61335. */
  61336. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61337. /**
  61338. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61339. * @param otherVector defines the second operand
  61340. * @returns the resulting Vector3
  61341. */
  61342. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61343. /**
  61344. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61345. * @param otherVector defines the second operand
  61346. * @param result defines the Vector3 object where to store the result
  61347. * @returns the current Vector3
  61348. */
  61349. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61350. /**
  61351. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61352. * @param x defines the x coordinate of the operand
  61353. * @param y defines the y coordinate of the operand
  61354. * @param z defines the z coordinate of the operand
  61355. * @returns the resulting Vector3
  61356. */
  61357. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61358. /**
  61359. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61360. * @param x defines the x coordinate of the operand
  61361. * @param y defines the y coordinate of the operand
  61362. * @param z defines the z coordinate of the operand
  61363. * @param result defines the Vector3 object where to store the result
  61364. * @returns the current Vector3
  61365. */
  61366. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61367. /**
  61368. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61369. * @returns a new Vector3
  61370. */
  61371. negate(): Vector3;
  61372. /**
  61373. * Multiplies the Vector3 coordinates by the float "scale"
  61374. * @param scale defines the multiplier factor
  61375. * @returns the current updated Vector3
  61376. */
  61377. scaleInPlace(scale: number): Vector3;
  61378. /**
  61379. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61380. * @param scale defines the multiplier factor
  61381. * @returns a new Vector3
  61382. */
  61383. scale(scale: number): Vector3;
  61384. /**
  61385. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61386. * @param scale defines the multiplier factor
  61387. * @param result defines the Vector3 object where to store the result
  61388. * @returns the current Vector3
  61389. */
  61390. scaleToRef(scale: number, result: Vector3): Vector3;
  61391. /**
  61392. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61393. * @param scale defines the scale factor
  61394. * @param result defines the Vector3 object where to store the result
  61395. * @returns the unmodified current Vector3
  61396. */
  61397. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61398. /**
  61399. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61400. * @param otherVector defines the second operand
  61401. * @returns true if both vectors are equals
  61402. */
  61403. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61404. /**
  61405. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61406. * @param otherVector defines the second operand
  61407. * @param epsilon defines the minimal distance to define values as equals
  61408. * @returns true if both vectors are distant less than epsilon
  61409. */
  61410. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61411. /**
  61412. * Returns true if the current Vector3 coordinates equals the given floats
  61413. * @param x defines the x coordinate of the operand
  61414. * @param y defines the y coordinate of the operand
  61415. * @param z defines the z coordinate of the operand
  61416. * @returns true if both vectors are equals
  61417. */
  61418. equalsToFloats(x: number, y: number, z: number): boolean;
  61419. /**
  61420. * Multiplies the current Vector3 coordinates by the given ones
  61421. * @param otherVector defines the second operand
  61422. * @returns the current updated Vector3
  61423. */
  61424. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61425. /**
  61426. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61427. * @param otherVector defines the second operand
  61428. * @returns the new Vector3
  61429. */
  61430. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61431. /**
  61432. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61433. * @param otherVector defines the second operand
  61434. * @param result defines the Vector3 object where to store the result
  61435. * @returns the current Vector3
  61436. */
  61437. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61438. /**
  61439. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61440. * @param x defines the x coordinate of the operand
  61441. * @param y defines the y coordinate of the operand
  61442. * @param z defines the z coordinate of the operand
  61443. * @returns the new Vector3
  61444. */
  61445. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61446. /**
  61447. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61448. * @param otherVector defines the second operand
  61449. * @returns the new Vector3
  61450. */
  61451. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61452. /**
  61453. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61454. * @param otherVector defines the second operand
  61455. * @param result defines the Vector3 object where to store the result
  61456. * @returns the current Vector3
  61457. */
  61458. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61459. /**
  61460. * Divides the current Vector3 coordinates by the given ones.
  61461. * @param otherVector defines the second operand
  61462. * @returns the current updated Vector3
  61463. */
  61464. divideInPlace(otherVector: Vector3): Vector3;
  61465. /**
  61466. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61467. * @param other defines the second operand
  61468. * @returns the current updated Vector3
  61469. */
  61470. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61471. /**
  61472. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61473. * @param other defines the second operand
  61474. * @returns the current updated Vector3
  61475. */
  61476. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61477. /**
  61478. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61479. * @param x defines the x coordinate of the operand
  61480. * @param y defines the y coordinate of the operand
  61481. * @param z defines the z coordinate of the operand
  61482. * @returns the current updated Vector3
  61483. */
  61484. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61485. /**
  61486. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61487. * @param x defines the x coordinate of the operand
  61488. * @param y defines the y coordinate of the operand
  61489. * @param z defines the z coordinate of the operand
  61490. * @returns the current updated Vector3
  61491. */
  61492. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61493. /**
  61494. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61495. * Check if is non uniform within a certain amount of decimal places to account for this
  61496. * @param epsilon the amount the values can differ
  61497. * @returns if the the vector is non uniform to a certain number of decimal places
  61498. */
  61499. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61500. /**
  61501. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61502. */
  61503. readonly isNonUniform: boolean;
  61504. /**
  61505. * Gets a new Vector3 from current Vector3 floored values
  61506. * @returns a new Vector3
  61507. */
  61508. floor(): Vector3;
  61509. /**
  61510. * Gets a new Vector3 from current Vector3 floored values
  61511. * @returns a new Vector3
  61512. */
  61513. fract(): Vector3;
  61514. /**
  61515. * Gets the length of the Vector3
  61516. * @returns the length of the Vecto3
  61517. */
  61518. length(): number;
  61519. /**
  61520. * Gets the squared length of the Vector3
  61521. * @returns squared length of the Vector3
  61522. */
  61523. lengthSquared(): number;
  61524. /**
  61525. * Normalize the current Vector3.
  61526. * Please note that this is an in place operation.
  61527. * @returns the current updated Vector3
  61528. */
  61529. normalize(): Vector3;
  61530. /**
  61531. * Reorders the x y z properties of the vector in place
  61532. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61533. * @returns the current updated vector
  61534. */
  61535. reorderInPlace(order: string): this;
  61536. /**
  61537. * Rotates the vector around 0,0,0 by a quaternion
  61538. * @param quaternion the rotation quaternion
  61539. * @param result vector to store the result
  61540. * @returns the resulting vector
  61541. */
  61542. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61543. /**
  61544. * Rotates a vector around a given point
  61545. * @param quaternion the rotation quaternion
  61546. * @param point the point to rotate around
  61547. * @param result vector to store the result
  61548. * @returns the resulting vector
  61549. */
  61550. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61551. /**
  61552. * Normalize the current Vector3 with the given input length.
  61553. * Please note that this is an in place operation.
  61554. * @param len the length of the vector
  61555. * @returns the current updated Vector3
  61556. */
  61557. normalizeFromLength(len: number): Vector3;
  61558. /**
  61559. * Normalize the current Vector3 to a new vector
  61560. * @returns the new Vector3
  61561. */
  61562. normalizeToNew(): Vector3;
  61563. /**
  61564. * Normalize the current Vector3 to the reference
  61565. * @param reference define the Vector3 to update
  61566. * @returns the updated Vector3
  61567. */
  61568. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61569. /**
  61570. * Creates a new Vector3 copied from the current Vector3
  61571. * @returns the new Vector3
  61572. */
  61573. clone(): Vector3;
  61574. /**
  61575. * Copies the given vector coordinates to the current Vector3 ones
  61576. * @param source defines the source Vector3
  61577. * @returns the current updated Vector3
  61578. */
  61579. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61580. /**
  61581. * Copies the given floats to the current Vector3 coordinates
  61582. * @param x defines the x coordinate of the operand
  61583. * @param y defines the y coordinate of the operand
  61584. * @param z defines the z coordinate of the operand
  61585. * @returns the current updated Vector3
  61586. */
  61587. copyFromFloats(x: number, y: number, z: number): Vector3;
  61588. /**
  61589. * Copies the given floats to the current Vector3 coordinates
  61590. * @param x defines the x coordinate of the operand
  61591. * @param y defines the y coordinate of the operand
  61592. * @param z defines the z coordinate of the operand
  61593. * @returns the current updated Vector3
  61594. */
  61595. set(x: number, y: number, z: number): Vector3;
  61596. /**
  61597. * Copies the given float to the current Vector3 coordinates
  61598. * @param v defines the x, y and z coordinates of the operand
  61599. * @returns the current updated Vector3
  61600. */
  61601. setAll(v: number): Vector3;
  61602. /**
  61603. * Get the clip factor between two vectors
  61604. * @param vector0 defines the first operand
  61605. * @param vector1 defines the second operand
  61606. * @param axis defines the axis to use
  61607. * @param size defines the size along the axis
  61608. * @returns the clip factor
  61609. */
  61610. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61611. /**
  61612. * Get angle between two vectors
  61613. * @param vector0 angle between vector0 and vector1
  61614. * @param vector1 angle between vector0 and vector1
  61615. * @param normal direction of the normal
  61616. * @return the angle between vector0 and vector1
  61617. */
  61618. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61619. /**
  61620. * Returns a new Vector3 set from the index "offset" of the given array
  61621. * @param array defines the source array
  61622. * @param offset defines the offset in the source array
  61623. * @returns the new Vector3
  61624. */
  61625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61626. /**
  61627. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61628. * This function is deprecated. Use FromArray instead
  61629. * @param array defines the source array
  61630. * @param offset defines the offset in the source array
  61631. * @returns the new Vector3
  61632. */
  61633. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61634. /**
  61635. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61636. * @param array defines the source array
  61637. * @param offset defines the offset in the source array
  61638. * @param result defines the Vector3 where to store the result
  61639. */
  61640. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61641. /**
  61642. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61643. * This function is deprecated. Use FromArrayToRef instead.
  61644. * @param array defines the source array
  61645. * @param offset defines the offset in the source array
  61646. * @param result defines the Vector3 where to store the result
  61647. */
  61648. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61649. /**
  61650. * Sets the given vector "result" with the given floats.
  61651. * @param x defines the x coordinate of the source
  61652. * @param y defines the y coordinate of the source
  61653. * @param z defines the z coordinate of the source
  61654. * @param result defines the Vector3 where to store the result
  61655. */
  61656. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61657. /**
  61658. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61659. * @returns a new empty Vector3
  61660. */
  61661. static Zero(): Vector3;
  61662. /**
  61663. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61664. * @returns a new unit Vector3
  61665. */
  61666. static One(): Vector3;
  61667. /**
  61668. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61669. * @returns a new up Vector3
  61670. */
  61671. static Up(): Vector3;
  61672. /**
  61673. * Gets a up Vector3 that must not be updated
  61674. */
  61675. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61676. /**
  61677. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61678. * @returns a new down Vector3
  61679. */
  61680. static Down(): Vector3;
  61681. /**
  61682. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61683. * @returns a new forward Vector3
  61684. */
  61685. static Forward(): Vector3;
  61686. /**
  61687. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61688. * @returns a new forward Vector3
  61689. */
  61690. static Backward(): Vector3;
  61691. /**
  61692. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61693. * @returns a new right Vector3
  61694. */
  61695. static Right(): Vector3;
  61696. /**
  61697. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61698. * @returns a new left Vector3
  61699. */
  61700. static Left(): Vector3;
  61701. /**
  61702. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61704. * @param vector defines the Vector3 to transform
  61705. * @param transformation defines the transformation matrix
  61706. * @returns the transformed Vector3
  61707. */
  61708. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61709. /**
  61710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61711. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61712. * @param vector defines the Vector3 to transform
  61713. * @param transformation defines the transformation matrix
  61714. * @param result defines the Vector3 where to store the result
  61715. */
  61716. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61717. /**
  61718. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61719. * This method computes tranformed coordinates only, not transformed direction vectors
  61720. * @param x define the x coordinate of the source vector
  61721. * @param y define the y coordinate of the source vector
  61722. * @param z define the z coordinate of the source vector
  61723. * @param transformation defines the transformation matrix
  61724. * @param result defines the Vector3 where to store the result
  61725. */
  61726. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61727. /**
  61728. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61730. * @param vector defines the Vector3 to transform
  61731. * @param transformation defines the transformation matrix
  61732. * @returns the new Vector3
  61733. */
  61734. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61735. /**
  61736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61738. * @param vector defines the Vector3 to transform
  61739. * @param transformation defines the transformation matrix
  61740. * @param result defines the Vector3 where to store the result
  61741. */
  61742. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61743. /**
  61744. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61745. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61746. * @param x define the x coordinate of the source vector
  61747. * @param y define the y coordinate of the source vector
  61748. * @param z define the z coordinate of the source vector
  61749. * @param transformation defines the transformation matrix
  61750. * @param result defines the Vector3 where to store the result
  61751. */
  61752. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61753. /**
  61754. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61755. * @param value1 defines the first control point
  61756. * @param value2 defines the second control point
  61757. * @param value3 defines the third control point
  61758. * @param value4 defines the fourth control point
  61759. * @param amount defines the amount on the spline to use
  61760. * @returns the new Vector3
  61761. */
  61762. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61763. /**
  61764. * 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"
  61765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61767. * @param value defines the current value
  61768. * @param min defines the lower range value
  61769. * @param max defines the upper range value
  61770. * @returns the new Vector3
  61771. */
  61772. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61773. /**
  61774. * 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"
  61775. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61776. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61777. * @param value defines the current value
  61778. * @param min defines the lower range value
  61779. * @param max defines the upper range value
  61780. * @param result defines the Vector3 where to store the result
  61781. */
  61782. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61783. /**
  61784. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61785. * @param value1 defines the first control point
  61786. * @param tangent1 defines the first tangent vector
  61787. * @param value2 defines the second control point
  61788. * @param tangent2 defines the second tangent vector
  61789. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61790. * @returns the new Vector3
  61791. */
  61792. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61793. /**
  61794. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61795. * @param start defines the start value
  61796. * @param end defines the end value
  61797. * @param amount max defines amount between both (between 0 and 1)
  61798. * @returns the new Vector3
  61799. */
  61800. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61801. /**
  61802. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61803. * @param start defines the start value
  61804. * @param end defines the end value
  61805. * @param amount max defines amount between both (between 0 and 1)
  61806. * @param result defines the Vector3 where to store the result
  61807. */
  61808. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61809. /**
  61810. * Returns the dot product (float) between the vectors "left" and "right"
  61811. * @param left defines the left operand
  61812. * @param right defines the right operand
  61813. * @returns the dot product
  61814. */
  61815. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61816. /**
  61817. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61818. * The cross product is then orthogonal to both "left" and "right"
  61819. * @param left defines the left operand
  61820. * @param right defines the right operand
  61821. * @returns the cross product
  61822. */
  61823. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61824. /**
  61825. * Sets the given vector "result" with the cross product of "left" and "right"
  61826. * The cross product is then orthogonal to both "left" and "right"
  61827. * @param left defines the left operand
  61828. * @param right defines the right operand
  61829. * @param result defines the Vector3 where to store the result
  61830. */
  61831. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61832. /**
  61833. * Returns a new Vector3 as the normalization of the given vector
  61834. * @param vector defines the Vector3 to normalize
  61835. * @returns the new Vector3
  61836. */
  61837. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61838. /**
  61839. * Sets the given vector "result" with the normalization of the given first vector
  61840. * @param vector defines the Vector3 to normalize
  61841. * @param result defines the Vector3 where to store the result
  61842. */
  61843. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61844. /**
  61845. * Project a Vector3 onto screen space
  61846. * @param vector defines the Vector3 to project
  61847. * @param world defines the world matrix to use
  61848. * @param transform defines the transform (view x projection) matrix to use
  61849. * @param viewport defines the screen viewport to use
  61850. * @returns the new Vector3
  61851. */
  61852. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61853. /** @hidden */
  61854. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61855. /**
  61856. * Unproject from screen space to object space
  61857. * @param source defines the screen space Vector3 to use
  61858. * @param viewportWidth defines the current width of the viewport
  61859. * @param viewportHeight defines the current height of the viewport
  61860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61861. * @param transform defines the transform (view x projection) matrix to use
  61862. * @returns the new Vector3
  61863. */
  61864. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61865. /**
  61866. * Unproject from screen space to object space
  61867. * @param source defines the screen space Vector3 to use
  61868. * @param viewportWidth defines the current width of the viewport
  61869. * @param viewportHeight defines the current height of the viewport
  61870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61871. * @param view defines the view matrix to use
  61872. * @param projection defines the projection matrix to use
  61873. * @returns the new Vector3
  61874. */
  61875. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61876. /**
  61877. * Unproject from screen space to object space
  61878. * @param source defines the screen space Vector3 to use
  61879. * @param viewportWidth defines the current width of the viewport
  61880. * @param viewportHeight defines the current height of the viewport
  61881. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61882. * @param view defines the view matrix to use
  61883. * @param projection defines the projection matrix to use
  61884. * @param result defines the Vector3 where to store the result
  61885. */
  61886. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61887. /**
  61888. * Unproject from screen space to object space
  61889. * @param sourceX defines the screen space x coordinate to use
  61890. * @param sourceY defines the screen space y coordinate to use
  61891. * @param sourceZ defines the screen space z coordinate to use
  61892. * @param viewportWidth defines the current width of the viewport
  61893. * @param viewportHeight defines the current height of the viewport
  61894. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61895. * @param view defines the view matrix to use
  61896. * @param projection defines the projection matrix to use
  61897. * @param result defines the Vector3 where to store the result
  61898. */
  61899. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61900. /**
  61901. * Gets the minimal coordinate values between two Vector3
  61902. * @param left defines the first operand
  61903. * @param right defines the second operand
  61904. * @returns the new Vector3
  61905. */
  61906. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61907. /**
  61908. * Gets the maximal coordinate values between two Vector3
  61909. * @param left defines the first operand
  61910. * @param right defines the second operand
  61911. * @returns the new Vector3
  61912. */
  61913. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61914. /**
  61915. * Returns the distance between the vectors "value1" and "value2"
  61916. * @param value1 defines the first operand
  61917. * @param value2 defines the second operand
  61918. * @returns the distance
  61919. */
  61920. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61921. /**
  61922. * Returns the squared distance between the vectors "value1" and "value2"
  61923. * @param value1 defines the first operand
  61924. * @param value2 defines the second operand
  61925. * @returns the squared distance
  61926. */
  61927. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61928. /**
  61929. * Returns a new Vector3 located at the center between "value1" and "value2"
  61930. * @param value1 defines the first operand
  61931. * @param value2 defines the second operand
  61932. * @returns the new Vector3
  61933. */
  61934. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61935. /**
  61936. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61937. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61938. * to something in order to rotate it from its local system to the given target system
  61939. * Note: axis1, axis2 and axis3 are normalized during this operation
  61940. * @param axis1 defines the first axis
  61941. * @param axis2 defines the second axis
  61942. * @param axis3 defines the third axis
  61943. * @returns a new Vector3
  61944. */
  61945. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61946. /**
  61947. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61948. * @param axis1 defines the first axis
  61949. * @param axis2 defines the second axis
  61950. * @param axis3 defines the third axis
  61951. * @param ref defines the Vector3 where to store the result
  61952. */
  61953. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61954. }
  61955. /**
  61956. * Vector4 class created for EulerAngle class conversion to Quaternion
  61957. */
  61958. export class Vector4 {
  61959. /** x value of the vector */
  61960. x: number;
  61961. /** y value of the vector */
  61962. y: number;
  61963. /** z value of the vector */
  61964. z: number;
  61965. /** w value of the vector */
  61966. w: number;
  61967. /**
  61968. * Creates a Vector4 object from the given floats.
  61969. * @param x x value of the vector
  61970. * @param y y value of the vector
  61971. * @param z z value of the vector
  61972. * @param w w value of the vector
  61973. */
  61974. constructor(
  61975. /** x value of the vector */
  61976. x: number,
  61977. /** y value of the vector */
  61978. y: number,
  61979. /** z value of the vector */
  61980. z: number,
  61981. /** w value of the vector */
  61982. w: number);
  61983. /**
  61984. * Returns the string with the Vector4 coordinates.
  61985. * @returns a string containing all the vector values
  61986. */
  61987. toString(): string;
  61988. /**
  61989. * Returns the string "Vector4".
  61990. * @returns "Vector4"
  61991. */
  61992. getClassName(): string;
  61993. /**
  61994. * Returns the Vector4 hash code.
  61995. * @returns a unique hash code
  61996. */
  61997. getHashCode(): number;
  61998. /**
  61999. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  62000. * @returns the resulting array
  62001. */
  62002. asArray(): number[];
  62003. /**
  62004. * Populates the given array from the given index with the Vector4 coordinates.
  62005. * @param array array to populate
  62006. * @param index index of the array to start at (default: 0)
  62007. * @returns the Vector4.
  62008. */
  62009. toArray(array: FloatArray, index?: number): Vector4;
  62010. /**
  62011. * Adds the given vector to the current Vector4.
  62012. * @param otherVector the vector to add
  62013. * @returns the updated Vector4.
  62014. */
  62015. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62016. /**
  62017. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  62018. * @param otherVector the vector to add
  62019. * @returns the resulting vector
  62020. */
  62021. add(otherVector: DeepImmutable<Vector4>): Vector4;
  62022. /**
  62023. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  62024. * @param otherVector the vector to add
  62025. * @param result the vector to store the result
  62026. * @returns the current Vector4.
  62027. */
  62028. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62029. /**
  62030. * Subtract in place the given vector from the current Vector4.
  62031. * @param otherVector the vector to subtract
  62032. * @returns the updated Vector4.
  62033. */
  62034. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62035. /**
  62036. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  62037. * @param otherVector the vector to add
  62038. * @returns the new vector with the result
  62039. */
  62040. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  62041. /**
  62042. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  62043. * @param otherVector the vector to subtract
  62044. * @param result the vector to store the result
  62045. * @returns the current Vector4.
  62046. */
  62047. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62048. /**
  62049. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  62050. */
  62051. /**
  62052. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  62053. * @param x value to subtract
  62054. * @param y value to subtract
  62055. * @param z value to subtract
  62056. * @param w value to subtract
  62057. * @returns new vector containing the result
  62058. */
  62059. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62060. /**
  62061. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  62062. * @param x value to subtract
  62063. * @param y value to subtract
  62064. * @param z value to subtract
  62065. * @param w value to subtract
  62066. * @param result the vector to store the result in
  62067. * @returns the current Vector4.
  62068. */
  62069. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  62070. /**
  62071. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  62072. * @returns a new vector with the negated values
  62073. */
  62074. negate(): Vector4;
  62075. /**
  62076. * Multiplies the current Vector4 coordinates by scale (float).
  62077. * @param scale the number to scale with
  62078. * @returns the updated Vector4.
  62079. */
  62080. scaleInPlace(scale: number): Vector4;
  62081. /**
  62082. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  62083. * @param scale the number to scale with
  62084. * @returns a new vector with the result
  62085. */
  62086. scale(scale: number): Vector4;
  62087. /**
  62088. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  62089. * @param scale the number to scale with
  62090. * @param result a vector to store the result in
  62091. * @returns the current Vector4.
  62092. */
  62093. scaleToRef(scale: number, result: Vector4): Vector4;
  62094. /**
  62095. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  62096. * @param scale defines the scale factor
  62097. * @param result defines the Vector4 object where to store the result
  62098. * @returns the unmodified current Vector4
  62099. */
  62100. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  62101. /**
  62102. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  62103. * @param otherVector the vector to compare against
  62104. * @returns true if they are equal
  62105. */
  62106. equals(otherVector: DeepImmutable<Vector4>): boolean;
  62107. /**
  62108. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  62109. * @param otherVector vector to compare against
  62110. * @param epsilon (Default: very small number)
  62111. * @returns true if they are equal
  62112. */
  62113. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  62114. /**
  62115. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  62116. * @param x x value to compare against
  62117. * @param y y value to compare against
  62118. * @param z z value to compare against
  62119. * @param w w value to compare against
  62120. * @returns true if equal
  62121. */
  62122. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62123. /**
  62124. * Multiplies in place the current Vector4 by the given one.
  62125. * @param otherVector vector to multiple with
  62126. * @returns the updated Vector4.
  62127. */
  62128. multiplyInPlace(otherVector: Vector4): Vector4;
  62129. /**
  62130. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62131. * @param otherVector vector to multiple with
  62132. * @returns resulting new vector
  62133. */
  62134. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62135. /**
  62136. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62137. * @param otherVector vector to multiple with
  62138. * @param result vector to store the result
  62139. * @returns the current Vector4.
  62140. */
  62141. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62142. /**
  62143. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62144. * @param x x value multiply with
  62145. * @param y y value multiply with
  62146. * @param z z value multiply with
  62147. * @param w w value multiply with
  62148. * @returns resulting new vector
  62149. */
  62150. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62151. /**
  62152. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62153. * @param otherVector vector to devide with
  62154. * @returns resulting new vector
  62155. */
  62156. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62157. /**
  62158. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62159. * @param otherVector vector to devide with
  62160. * @param result vector to store the result
  62161. * @returns the current Vector4.
  62162. */
  62163. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62164. /**
  62165. * Divides the current Vector3 coordinates by the given ones.
  62166. * @param otherVector vector to devide with
  62167. * @returns the updated Vector3.
  62168. */
  62169. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62170. /**
  62171. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62172. * @param other defines the second operand
  62173. * @returns the current updated Vector4
  62174. */
  62175. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62176. /**
  62177. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62178. * @param other defines the second operand
  62179. * @returns the current updated Vector4
  62180. */
  62181. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62182. /**
  62183. * Gets a new Vector4 from current Vector4 floored values
  62184. * @returns a new Vector4
  62185. */
  62186. floor(): Vector4;
  62187. /**
  62188. * Gets a new Vector4 from current Vector3 floored values
  62189. * @returns a new Vector4
  62190. */
  62191. fract(): Vector4;
  62192. /**
  62193. * Returns the Vector4 length (float).
  62194. * @returns the length
  62195. */
  62196. length(): number;
  62197. /**
  62198. * Returns the Vector4 squared length (float).
  62199. * @returns the length squared
  62200. */
  62201. lengthSquared(): number;
  62202. /**
  62203. * Normalizes in place the Vector4.
  62204. * @returns the updated Vector4.
  62205. */
  62206. normalize(): Vector4;
  62207. /**
  62208. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62209. * @returns this converted to a new vector3
  62210. */
  62211. toVector3(): Vector3;
  62212. /**
  62213. * Returns a new Vector4 copied from the current one.
  62214. * @returns the new cloned vector
  62215. */
  62216. clone(): Vector4;
  62217. /**
  62218. * Updates the current Vector4 with the given one coordinates.
  62219. * @param source the source vector to copy from
  62220. * @returns the updated Vector4.
  62221. */
  62222. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62223. /**
  62224. * Updates the current Vector4 coordinates with the given floats.
  62225. * @param x float to copy from
  62226. * @param y float to copy from
  62227. * @param z float to copy from
  62228. * @param w float to copy from
  62229. * @returns the updated Vector4.
  62230. */
  62231. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62232. /**
  62233. * Updates the current Vector4 coordinates with the given floats.
  62234. * @param x float to set from
  62235. * @param y float to set from
  62236. * @param z float to set from
  62237. * @param w float to set from
  62238. * @returns the updated Vector4.
  62239. */
  62240. set(x: number, y: number, z: number, w: number): Vector4;
  62241. /**
  62242. * Copies the given float to the current Vector3 coordinates
  62243. * @param v defines the x, y, z and w coordinates of the operand
  62244. * @returns the current updated Vector3
  62245. */
  62246. setAll(v: number): Vector4;
  62247. /**
  62248. * Returns a new Vector4 set from the starting index of the given array.
  62249. * @param array the array to pull values from
  62250. * @param offset the offset into the array to start at
  62251. * @returns the new vector
  62252. */
  62253. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62254. /**
  62255. * Updates the given vector "result" from the starting index of the given array.
  62256. * @param array the array to pull values from
  62257. * @param offset the offset into the array to start at
  62258. * @param result the vector to store the result in
  62259. */
  62260. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62261. /**
  62262. * Updates the given vector "result" from the starting index of the given Float32Array.
  62263. * @param array the array to pull values from
  62264. * @param offset the offset into the array to start at
  62265. * @param result the vector to store the result in
  62266. */
  62267. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62268. /**
  62269. * Updates the given vector "result" coordinates from the given floats.
  62270. * @param x float to set from
  62271. * @param y float to set from
  62272. * @param z float to set from
  62273. * @param w float to set from
  62274. * @param result the vector to the floats in
  62275. */
  62276. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62277. /**
  62278. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62279. * @returns the new vector
  62280. */
  62281. static Zero(): Vector4;
  62282. /**
  62283. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62284. * @returns the new vector
  62285. */
  62286. static One(): Vector4;
  62287. /**
  62288. * Returns a new normalized Vector4 from the given one.
  62289. * @param vector the vector to normalize
  62290. * @returns the vector
  62291. */
  62292. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62293. /**
  62294. * Updates the given vector "result" from the normalization of the given one.
  62295. * @param vector the vector to normalize
  62296. * @param result the vector to store the result in
  62297. */
  62298. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62299. /**
  62300. * Returns a vector with the minimum values from the left and right vectors
  62301. * @param left left vector to minimize
  62302. * @param right right vector to minimize
  62303. * @returns a new vector with the minimum of the left and right vector values
  62304. */
  62305. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62306. /**
  62307. * Returns a vector with the maximum values from the left and right vectors
  62308. * @param left left vector to maximize
  62309. * @param right right vector to maximize
  62310. * @returns a new vector with the maximum of the left and right vector values
  62311. */
  62312. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62313. /**
  62314. * Returns the distance (float) between the vectors "value1" and "value2".
  62315. * @param value1 value to calulate the distance between
  62316. * @param value2 value to calulate the distance between
  62317. * @return the distance between the two vectors
  62318. */
  62319. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62320. /**
  62321. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62322. * @param value1 value to calulate the distance between
  62323. * @param value2 value to calulate the distance between
  62324. * @return the distance between the two vectors squared
  62325. */
  62326. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62327. /**
  62328. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62329. * @param value1 value to calulate the center between
  62330. * @param value2 value to calulate the center between
  62331. * @return the center between the two vectors
  62332. */
  62333. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62334. /**
  62335. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62336. * This methods computes transformed normalized direction vectors only.
  62337. * @param vector the vector to transform
  62338. * @param transformation the transformation matrix to apply
  62339. * @returns the new vector
  62340. */
  62341. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62342. /**
  62343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62344. * This methods computes transformed normalized direction vectors only.
  62345. * @param vector the vector to transform
  62346. * @param transformation the transformation matrix to apply
  62347. * @param result the vector to store the result in
  62348. */
  62349. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62350. /**
  62351. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62352. * This methods computes transformed normalized direction vectors only.
  62353. * @param x value to transform
  62354. * @param y value to transform
  62355. * @param z value to transform
  62356. * @param w value to transform
  62357. * @param transformation the transformation matrix to apply
  62358. * @param result the vector to store the results in
  62359. */
  62360. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62361. /**
  62362. * Creates a new Vector4 from a Vector3
  62363. * @param source defines the source data
  62364. * @param w defines the 4th component (default is 0)
  62365. * @returns a new Vector4
  62366. */
  62367. static FromVector3(source: Vector3, w?: number): Vector4;
  62368. }
  62369. /**
  62370. * Interface for the size containing width and height
  62371. */
  62372. export interface ISize {
  62373. /**
  62374. * Width
  62375. */
  62376. width: number;
  62377. /**
  62378. * Heighht
  62379. */
  62380. height: number;
  62381. }
  62382. /**
  62383. * Size containing widht and height
  62384. */
  62385. export class Size implements ISize {
  62386. /**
  62387. * Width
  62388. */
  62389. width: number;
  62390. /**
  62391. * Height
  62392. */
  62393. height: number;
  62394. /**
  62395. * Creates a Size object from the given width and height (floats).
  62396. * @param width width of the new size
  62397. * @param height height of the new size
  62398. */
  62399. constructor(width: number, height: number);
  62400. /**
  62401. * Returns a string with the Size width and height
  62402. * @returns a string with the Size width and height
  62403. */
  62404. toString(): string;
  62405. /**
  62406. * "Size"
  62407. * @returns the string "Size"
  62408. */
  62409. getClassName(): string;
  62410. /**
  62411. * Returns the Size hash code.
  62412. * @returns a hash code for a unique width and height
  62413. */
  62414. getHashCode(): number;
  62415. /**
  62416. * Updates the current size from the given one.
  62417. * @param src the given size
  62418. */
  62419. copyFrom(src: Size): void;
  62420. /**
  62421. * Updates in place the current Size from the given floats.
  62422. * @param width width of the new size
  62423. * @param height height of the new size
  62424. * @returns the updated Size.
  62425. */
  62426. copyFromFloats(width: number, height: number): Size;
  62427. /**
  62428. * Updates in place the current Size from the given floats.
  62429. * @param width width to set
  62430. * @param height height to set
  62431. * @returns the updated Size.
  62432. */
  62433. set(width: number, height: number): Size;
  62434. /**
  62435. * Multiplies the width and height by numbers
  62436. * @param w factor to multiple the width by
  62437. * @param h factor to multiple the height by
  62438. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62439. */
  62440. multiplyByFloats(w: number, h: number): Size;
  62441. /**
  62442. * Clones the size
  62443. * @returns a new Size copied from the given one.
  62444. */
  62445. clone(): Size;
  62446. /**
  62447. * True if the current Size and the given one width and height are strictly equal.
  62448. * @param other the other size to compare against
  62449. * @returns True if the current Size and the given one width and height are strictly equal.
  62450. */
  62451. equals(other: Size): boolean;
  62452. /**
  62453. * The surface of the Size : width * height (float).
  62454. */
  62455. readonly surface: number;
  62456. /**
  62457. * Create a new size of zero
  62458. * @returns a new Size set to (0.0, 0.0)
  62459. */
  62460. static Zero(): Size;
  62461. /**
  62462. * Sums the width and height of two sizes
  62463. * @param otherSize size to add to this size
  62464. * @returns a new Size set as the addition result of the current Size and the given one.
  62465. */
  62466. add(otherSize: Size): Size;
  62467. /**
  62468. * Subtracts the width and height of two
  62469. * @param otherSize size to subtract to this size
  62470. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62471. */
  62472. subtract(otherSize: Size): Size;
  62473. /**
  62474. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62475. * @param start starting size to lerp between
  62476. * @param end end size to lerp between
  62477. * @param amount amount to lerp between the start and end values
  62478. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62479. */
  62480. static Lerp(start: Size, end: Size, amount: number): Size;
  62481. }
  62482. /**
  62483. * Class used to store quaternion data
  62484. * @see https://en.wikipedia.org/wiki/Quaternion
  62485. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62486. */
  62487. export class Quaternion {
  62488. /** defines the first component (0 by default) */
  62489. x: number;
  62490. /** defines the second component (0 by default) */
  62491. y: number;
  62492. /** defines the third component (0 by default) */
  62493. z: number;
  62494. /** defines the fourth component (1.0 by default) */
  62495. w: number;
  62496. /**
  62497. * Creates a new Quaternion from the given floats
  62498. * @param x defines the first component (0 by default)
  62499. * @param y defines the second component (0 by default)
  62500. * @param z defines the third component (0 by default)
  62501. * @param w defines the fourth component (1.0 by default)
  62502. */
  62503. constructor(
  62504. /** defines the first component (0 by default) */
  62505. x?: number,
  62506. /** defines the second component (0 by default) */
  62507. y?: number,
  62508. /** defines the third component (0 by default) */
  62509. z?: number,
  62510. /** defines the fourth component (1.0 by default) */
  62511. w?: number);
  62512. /**
  62513. * Gets a string representation for the current quaternion
  62514. * @returns a string with the Quaternion coordinates
  62515. */
  62516. toString(): string;
  62517. /**
  62518. * Gets the class name of the quaternion
  62519. * @returns the string "Quaternion"
  62520. */
  62521. getClassName(): string;
  62522. /**
  62523. * Gets a hash code for this quaternion
  62524. * @returns the quaternion hash code
  62525. */
  62526. getHashCode(): number;
  62527. /**
  62528. * Copy the quaternion to an array
  62529. * @returns a new array populated with 4 elements from the quaternion coordinates
  62530. */
  62531. asArray(): number[];
  62532. /**
  62533. * Check if two quaternions are equals
  62534. * @param otherQuaternion defines the second operand
  62535. * @return true if the current quaternion and the given one coordinates are strictly equals
  62536. */
  62537. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62538. /**
  62539. * Clone the current quaternion
  62540. * @returns a new quaternion copied from the current one
  62541. */
  62542. clone(): Quaternion;
  62543. /**
  62544. * Copy a quaternion to the current one
  62545. * @param other defines the other quaternion
  62546. * @returns the updated current quaternion
  62547. */
  62548. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62549. /**
  62550. * Updates the current quaternion with the given float coordinates
  62551. * @param x defines the x coordinate
  62552. * @param y defines the y coordinate
  62553. * @param z defines the z coordinate
  62554. * @param w defines the w coordinate
  62555. * @returns the updated current quaternion
  62556. */
  62557. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62558. /**
  62559. * Updates the current quaternion from the given float coordinates
  62560. * @param x defines the x coordinate
  62561. * @param y defines the y coordinate
  62562. * @param z defines the z coordinate
  62563. * @param w defines the w coordinate
  62564. * @returns the updated current quaternion
  62565. */
  62566. set(x: number, y: number, z: number, w: number): Quaternion;
  62567. /**
  62568. * Adds two quaternions
  62569. * @param other defines the second operand
  62570. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62571. */
  62572. add(other: DeepImmutable<Quaternion>): Quaternion;
  62573. /**
  62574. * Add a quaternion to the current one
  62575. * @param other defines the quaternion to add
  62576. * @returns the current quaternion
  62577. */
  62578. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62579. /**
  62580. * Subtract two quaternions
  62581. * @param other defines the second operand
  62582. * @returns a new quaternion as the subtraction result of the given one from the current one
  62583. */
  62584. subtract(other: Quaternion): Quaternion;
  62585. /**
  62586. * Multiplies the current quaternion by a scale factor
  62587. * @param value defines the scale factor
  62588. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62589. */
  62590. scale(value: number): Quaternion;
  62591. /**
  62592. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62593. * @param scale defines the scale factor
  62594. * @param result defines the Quaternion object where to store the result
  62595. * @returns the unmodified current quaternion
  62596. */
  62597. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62598. /**
  62599. * Multiplies in place the current quaternion by a scale factor
  62600. * @param value defines the scale factor
  62601. * @returns the current modified quaternion
  62602. */
  62603. scaleInPlace(value: number): Quaternion;
  62604. /**
  62605. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62606. * @param scale defines the scale factor
  62607. * @param result defines the Quaternion object where to store the result
  62608. * @returns the unmodified current quaternion
  62609. */
  62610. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62611. /**
  62612. * Multiplies two quaternions
  62613. * @param q1 defines the second operand
  62614. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62615. */
  62616. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62617. /**
  62618. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62619. * @param q1 defines the second operand
  62620. * @param result defines the target quaternion
  62621. * @returns the current quaternion
  62622. */
  62623. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62624. /**
  62625. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62626. * @param q1 defines the second operand
  62627. * @returns the currentupdated quaternion
  62628. */
  62629. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62630. /**
  62631. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62632. * @param ref defines the target quaternion
  62633. * @returns the current quaternion
  62634. */
  62635. conjugateToRef(ref: Quaternion): Quaternion;
  62636. /**
  62637. * Conjugates in place (1-q) the current quaternion
  62638. * @returns the current updated quaternion
  62639. */
  62640. conjugateInPlace(): Quaternion;
  62641. /**
  62642. * Conjugates in place (1-q) the current quaternion
  62643. * @returns a new quaternion
  62644. */
  62645. conjugate(): Quaternion;
  62646. /**
  62647. * Gets length of current quaternion
  62648. * @returns the quaternion length (float)
  62649. */
  62650. length(): number;
  62651. /**
  62652. * Normalize in place the current quaternion
  62653. * @returns the current updated quaternion
  62654. */
  62655. normalize(): Quaternion;
  62656. /**
  62657. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62658. * @param order is a reserved parameter and is ignore for now
  62659. * @returns a new Vector3 containing the Euler angles
  62660. */
  62661. toEulerAngles(order?: string): Vector3;
  62662. /**
  62663. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62664. * @param result defines the vector which will be filled with the Euler angles
  62665. * @param order is a reserved parameter and is ignore for now
  62666. * @returns the current unchanged quaternion
  62667. */
  62668. toEulerAnglesToRef(result: Vector3): Quaternion;
  62669. /**
  62670. * Updates the given rotation matrix with the current quaternion values
  62671. * @param result defines the target matrix
  62672. * @returns the current unchanged quaternion
  62673. */
  62674. toRotationMatrix(result: Matrix): Quaternion;
  62675. /**
  62676. * Updates the current quaternion from the given rotation matrix values
  62677. * @param matrix defines the source matrix
  62678. * @returns the current updated quaternion
  62679. */
  62680. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62681. /**
  62682. * Creates a new quaternion from a rotation matrix
  62683. * @param matrix defines the source matrix
  62684. * @returns a new quaternion created from the given rotation matrix values
  62685. */
  62686. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62687. /**
  62688. * Updates the given quaternion with the given rotation matrix values
  62689. * @param matrix defines the source matrix
  62690. * @param result defines the target quaternion
  62691. */
  62692. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62693. /**
  62694. * Returns the dot product (float) between the quaternions "left" and "right"
  62695. * @param left defines the left operand
  62696. * @param right defines the right operand
  62697. * @returns the dot product
  62698. */
  62699. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62700. /**
  62701. * Checks if the two quaternions are close to each other
  62702. * @param quat0 defines the first quaternion to check
  62703. * @param quat1 defines the second quaternion to check
  62704. * @returns true if the two quaternions are close to each other
  62705. */
  62706. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62707. /**
  62708. * Creates an empty quaternion
  62709. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62710. */
  62711. static Zero(): Quaternion;
  62712. /**
  62713. * Inverse a given quaternion
  62714. * @param q defines the source quaternion
  62715. * @returns a new quaternion as the inverted current quaternion
  62716. */
  62717. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62718. /**
  62719. * Inverse a given quaternion
  62720. * @param q defines the source quaternion
  62721. * @param result the quaternion the result will be stored in
  62722. * @returns the result quaternion
  62723. */
  62724. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62725. /**
  62726. * Creates an identity quaternion
  62727. * @returns the identity quaternion
  62728. */
  62729. static Identity(): Quaternion;
  62730. /**
  62731. * Gets a boolean indicating if the given quaternion is identity
  62732. * @param quaternion defines the quaternion to check
  62733. * @returns true if the quaternion is identity
  62734. */
  62735. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62736. /**
  62737. * Creates a quaternion from a rotation around an axis
  62738. * @param axis defines the axis to use
  62739. * @param angle defines the angle to use
  62740. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62741. */
  62742. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62743. /**
  62744. * Creates a rotation around an axis and stores it into the given quaternion
  62745. * @param axis defines the axis to use
  62746. * @param angle defines the angle to use
  62747. * @param result defines the target quaternion
  62748. * @returns the target quaternion
  62749. */
  62750. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62751. /**
  62752. * Creates a new quaternion from data stored into an array
  62753. * @param array defines the data source
  62754. * @param offset defines the offset in the source array where the data starts
  62755. * @returns a new quaternion
  62756. */
  62757. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62758. /**
  62759. * Create a quaternion from Euler rotation angles
  62760. * @param x Pitch
  62761. * @param y Yaw
  62762. * @param z Roll
  62763. * @returns the new Quaternion
  62764. */
  62765. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62766. /**
  62767. * Updates a quaternion from Euler rotation angles
  62768. * @param x Pitch
  62769. * @param y Yaw
  62770. * @param z Roll
  62771. * @param result the quaternion to store the result
  62772. * @returns the updated quaternion
  62773. */
  62774. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62775. /**
  62776. * Create a quaternion from Euler rotation vector
  62777. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62778. * @returns the new Quaternion
  62779. */
  62780. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62781. /**
  62782. * Updates a quaternion from Euler rotation vector
  62783. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62784. * @param result the quaternion to store the result
  62785. * @returns the updated quaternion
  62786. */
  62787. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62788. /**
  62789. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62790. * @param yaw defines the rotation around Y axis
  62791. * @param pitch defines the rotation around X axis
  62792. * @param roll defines the rotation around Z axis
  62793. * @returns the new quaternion
  62794. */
  62795. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62796. /**
  62797. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62798. * @param yaw defines the rotation around Y axis
  62799. * @param pitch defines the rotation around X axis
  62800. * @param roll defines the rotation around Z axis
  62801. * @param result defines the target quaternion
  62802. */
  62803. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62804. /**
  62805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62806. * @param alpha defines the rotation around first axis
  62807. * @param beta defines the rotation around second axis
  62808. * @param gamma defines the rotation around third axis
  62809. * @returns the new quaternion
  62810. */
  62811. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62812. /**
  62813. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62814. * @param alpha defines the rotation around first axis
  62815. * @param beta defines the rotation around second axis
  62816. * @param gamma defines the rotation around third axis
  62817. * @param result defines the target quaternion
  62818. */
  62819. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62820. /**
  62821. * 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)
  62822. * @param axis1 defines the first axis
  62823. * @param axis2 defines the second axis
  62824. * @param axis3 defines the third axis
  62825. * @returns the new quaternion
  62826. */
  62827. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62828. /**
  62829. * 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
  62830. * @param axis1 defines the first axis
  62831. * @param axis2 defines the second axis
  62832. * @param axis3 defines the third axis
  62833. * @param ref defines the target quaternion
  62834. */
  62835. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62836. /**
  62837. * Interpolates between two quaternions
  62838. * @param left defines first quaternion
  62839. * @param right defines second quaternion
  62840. * @param amount defines the gradient to use
  62841. * @returns the new interpolated quaternion
  62842. */
  62843. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62844. /**
  62845. * Interpolates between two quaternions and stores it into a target quaternion
  62846. * @param left defines first quaternion
  62847. * @param right defines second quaternion
  62848. * @param amount defines the gradient to use
  62849. * @param result defines the target quaternion
  62850. */
  62851. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62852. /**
  62853. * Interpolate between two quaternions using Hermite interpolation
  62854. * @param value1 defines first quaternion
  62855. * @param tangent1 defines the incoming tangent
  62856. * @param value2 defines second quaternion
  62857. * @param tangent2 defines the outgoing tangent
  62858. * @param amount defines the target quaternion
  62859. * @returns the new interpolated quaternion
  62860. */
  62861. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62862. }
  62863. /**
  62864. * Class used to store matrix data (4x4)
  62865. */
  62866. export class Matrix {
  62867. private static _updateFlagSeed;
  62868. private static _identityReadOnly;
  62869. private _isIdentity;
  62870. private _isIdentityDirty;
  62871. private _isIdentity3x2;
  62872. private _isIdentity3x2Dirty;
  62873. /**
  62874. * Gets the update flag of the matrix which is an unique number for the matrix.
  62875. * It will be incremented every time the matrix data change.
  62876. * You can use it to speed the comparison between two versions of the same matrix.
  62877. */
  62878. updateFlag: number;
  62879. private readonly _m;
  62880. /**
  62881. * Gets the internal data of the matrix
  62882. */
  62883. readonly m: DeepImmutable<Float32Array>;
  62884. /** @hidden */
  62885. _markAsUpdated(): void;
  62886. /** @hidden */
  62887. private _updateIdentityStatus;
  62888. /**
  62889. * Creates an empty matrix (filled with zeros)
  62890. */
  62891. constructor();
  62892. /**
  62893. * Check if the current matrix is identity
  62894. * @returns true is the matrix is the identity matrix
  62895. */
  62896. isIdentity(): boolean;
  62897. /**
  62898. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62899. * @returns true is the matrix is the identity matrix
  62900. */
  62901. isIdentityAs3x2(): boolean;
  62902. /**
  62903. * Gets the determinant of the matrix
  62904. * @returns the matrix determinant
  62905. */
  62906. determinant(): number;
  62907. /**
  62908. * Returns the matrix as a Float32Array
  62909. * @returns the matrix underlying array
  62910. */
  62911. toArray(): DeepImmutable<Float32Array>;
  62912. /**
  62913. * Returns the matrix as a Float32Array
  62914. * @returns the matrix underlying array.
  62915. */
  62916. asArray(): DeepImmutable<Float32Array>;
  62917. /**
  62918. * Inverts the current matrix in place
  62919. * @returns the current inverted matrix
  62920. */
  62921. invert(): Matrix;
  62922. /**
  62923. * Sets all the matrix elements to zero
  62924. * @returns the current matrix
  62925. */
  62926. reset(): Matrix;
  62927. /**
  62928. * Adds the current matrix with a second one
  62929. * @param other defines the matrix to add
  62930. * @returns a new matrix as the addition of the current matrix and the given one
  62931. */
  62932. add(other: DeepImmutable<Matrix>): Matrix;
  62933. /**
  62934. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62935. * @param other defines the matrix to add
  62936. * @param result defines the target matrix
  62937. * @returns the current matrix
  62938. */
  62939. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62940. /**
  62941. * Adds in place the given matrix to the current matrix
  62942. * @param other defines the second operand
  62943. * @returns the current updated matrix
  62944. */
  62945. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62946. /**
  62947. * Sets the given matrix to the current inverted Matrix
  62948. * @param other defines the target matrix
  62949. * @returns the unmodified current matrix
  62950. */
  62951. invertToRef(other: Matrix): Matrix;
  62952. /**
  62953. * add a value at the specified position in the current Matrix
  62954. * @param index the index of the value within the matrix. between 0 and 15.
  62955. * @param value the value to be added
  62956. * @returns the current updated matrix
  62957. */
  62958. addAtIndex(index: number, value: number): Matrix;
  62959. /**
  62960. * mutiply the specified position in the current Matrix by a value
  62961. * @param index the index of the value within the matrix. between 0 and 15.
  62962. * @param value the value to be added
  62963. * @returns the current updated matrix
  62964. */
  62965. multiplyAtIndex(index: number, value: number): Matrix;
  62966. /**
  62967. * Inserts the translation vector (using 3 floats) in the current matrix
  62968. * @param x defines the 1st component of the translation
  62969. * @param y defines the 2nd component of the translation
  62970. * @param z defines the 3rd component of the translation
  62971. * @returns the current updated matrix
  62972. */
  62973. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62974. /**
  62975. * Adds the translation vector (using 3 floats) in the current matrix
  62976. * @param x defines the 1st component of the translation
  62977. * @param y defines the 2nd component of the translation
  62978. * @param z defines the 3rd component of the translation
  62979. * @returns the current updated matrix
  62980. */
  62981. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62982. /**
  62983. * Inserts the translation vector in the current matrix
  62984. * @param vector3 defines the translation to insert
  62985. * @returns the current updated matrix
  62986. */
  62987. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62988. /**
  62989. * Gets the translation value of the current matrix
  62990. * @returns a new Vector3 as the extracted translation from the matrix
  62991. */
  62992. getTranslation(): Vector3;
  62993. /**
  62994. * Fill a Vector3 with the extracted translation from the matrix
  62995. * @param result defines the Vector3 where to store the translation
  62996. * @returns the current matrix
  62997. */
  62998. getTranslationToRef(result: Vector3): Matrix;
  62999. /**
  63000. * Remove rotation and scaling part from the matrix
  63001. * @returns the updated matrix
  63002. */
  63003. removeRotationAndScaling(): Matrix;
  63004. /**
  63005. * Multiply two matrices
  63006. * @param other defines the second operand
  63007. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  63008. */
  63009. multiply(other: DeepImmutable<Matrix>): Matrix;
  63010. /**
  63011. * Copy the current matrix from the given one
  63012. * @param other defines the source matrix
  63013. * @returns the current updated matrix
  63014. */
  63015. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  63016. /**
  63017. * Populates the given array from the starting index with the current matrix values
  63018. * @param array defines the target array
  63019. * @param offset defines the offset in the target array where to start storing values
  63020. * @returns the current matrix
  63021. */
  63022. copyToArray(array: Float32Array, offset?: number): Matrix;
  63023. /**
  63024. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  63025. * @param other defines the second operand
  63026. * @param result defines the matrix where to store the multiplication
  63027. * @returns the current matrix
  63028. */
  63029. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  63030. /**
  63031. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  63032. * @param other defines the second operand
  63033. * @param result defines the array where to store the multiplication
  63034. * @param offset defines the offset in the target array where to start storing values
  63035. * @returns the current matrix
  63036. */
  63037. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  63038. /**
  63039. * Check equality between this matrix and a second one
  63040. * @param value defines the second matrix to compare
  63041. * @returns true is the current matrix and the given one values are strictly equal
  63042. */
  63043. equals(value: DeepImmutable<Matrix>): boolean;
  63044. /**
  63045. * Clone the current matrix
  63046. * @returns a new matrix from the current matrix
  63047. */
  63048. clone(): Matrix;
  63049. /**
  63050. * Returns the name of the current matrix class
  63051. * @returns the string "Matrix"
  63052. */
  63053. getClassName(): string;
  63054. /**
  63055. * Gets the hash code of the current matrix
  63056. * @returns the hash code
  63057. */
  63058. getHashCode(): number;
  63059. /**
  63060. * Decomposes the current Matrix into a translation, rotation and scaling components
  63061. * @param scale defines the scale vector3 given as a reference to update
  63062. * @param rotation defines the rotation quaternion given as a reference to update
  63063. * @param translation defines the translation vector3 given as a reference to update
  63064. * @returns true if operation was successful
  63065. */
  63066. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  63067. /**
  63068. * Gets specific row of the matrix
  63069. * @param index defines the number of the row to get
  63070. * @returns the index-th row of the current matrix as a new Vector4
  63071. */
  63072. getRow(index: number): Nullable<Vector4>;
  63073. /**
  63074. * Sets the index-th row of the current matrix to the vector4 values
  63075. * @param index defines the number of the row to set
  63076. * @param row defines the target vector4
  63077. * @returns the updated current matrix
  63078. */
  63079. setRow(index: number, row: Vector4): Matrix;
  63080. /**
  63081. * Compute the transpose of the matrix
  63082. * @returns the new transposed matrix
  63083. */
  63084. transpose(): Matrix;
  63085. /**
  63086. * Compute the transpose of the matrix and store it in a given matrix
  63087. * @param result defines the target matrix
  63088. * @returns the current matrix
  63089. */
  63090. transposeToRef(result: Matrix): Matrix;
  63091. /**
  63092. * Sets the index-th row of the current matrix with the given 4 x float values
  63093. * @param index defines the row index
  63094. * @param x defines the x component to set
  63095. * @param y defines the y component to set
  63096. * @param z defines the z component to set
  63097. * @param w defines the w component to set
  63098. * @returns the updated current matrix
  63099. */
  63100. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  63101. /**
  63102. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  63103. * @param scale defines the scale factor
  63104. * @returns a new matrix
  63105. */
  63106. scale(scale: number): Matrix;
  63107. /**
  63108. * Scale the current matrix values by a factor to a given result matrix
  63109. * @param scale defines the scale factor
  63110. * @param result defines the matrix to store the result
  63111. * @returns the current matrix
  63112. */
  63113. scaleToRef(scale: number, result: Matrix): Matrix;
  63114. /**
  63115. * Scale the current matrix values by a factor and add the result to a given matrix
  63116. * @param scale defines the scale factor
  63117. * @param result defines the Matrix to store the result
  63118. * @returns the current matrix
  63119. */
  63120. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63121. /**
  63122. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63123. * @param ref matrix to store the result
  63124. */
  63125. toNormalMatrix(ref: Matrix): void;
  63126. /**
  63127. * Gets only rotation part of the current matrix
  63128. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63129. */
  63130. getRotationMatrix(): Matrix;
  63131. /**
  63132. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63133. * @param result defines the target matrix to store data to
  63134. * @returns the current matrix
  63135. */
  63136. getRotationMatrixToRef(result: Matrix): Matrix;
  63137. /**
  63138. * Toggles model matrix from being right handed to left handed in place and vice versa
  63139. */
  63140. toggleModelMatrixHandInPlace(): void;
  63141. /**
  63142. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63143. */
  63144. toggleProjectionMatrixHandInPlace(): void;
  63145. /**
  63146. * Creates a matrix from an array
  63147. * @param array defines the source array
  63148. * @param offset defines an offset in the source array
  63149. * @returns a new Matrix set from the starting index of the given array
  63150. */
  63151. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63152. /**
  63153. * Copy the content of an array into a given matrix
  63154. * @param array defines the source array
  63155. * @param offset defines an offset in the source array
  63156. * @param result defines the target matrix
  63157. */
  63158. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63159. /**
  63160. * Stores an array into a matrix after having multiplied each component by a given factor
  63161. * @param array defines the source array
  63162. * @param offset defines the offset in the source array
  63163. * @param scale defines the scaling factor
  63164. * @param result defines the target matrix
  63165. */
  63166. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63167. /**
  63168. * Gets an identity matrix that must not be updated
  63169. */
  63170. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63171. /**
  63172. * Stores a list of values (16) inside a given matrix
  63173. * @param initialM11 defines 1st value of 1st row
  63174. * @param initialM12 defines 2nd value of 1st row
  63175. * @param initialM13 defines 3rd value of 1st row
  63176. * @param initialM14 defines 4th value of 1st row
  63177. * @param initialM21 defines 1st value of 2nd row
  63178. * @param initialM22 defines 2nd value of 2nd row
  63179. * @param initialM23 defines 3rd value of 2nd row
  63180. * @param initialM24 defines 4th value of 2nd row
  63181. * @param initialM31 defines 1st value of 3rd row
  63182. * @param initialM32 defines 2nd value of 3rd row
  63183. * @param initialM33 defines 3rd value of 3rd row
  63184. * @param initialM34 defines 4th value of 3rd row
  63185. * @param initialM41 defines 1st value of 4th row
  63186. * @param initialM42 defines 2nd value of 4th row
  63187. * @param initialM43 defines 3rd value of 4th row
  63188. * @param initialM44 defines 4th value of 4th row
  63189. * @param result defines the target matrix
  63190. */
  63191. 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;
  63192. /**
  63193. * Creates new matrix from a list of values (16)
  63194. * @param initialM11 defines 1st value of 1st row
  63195. * @param initialM12 defines 2nd value of 1st row
  63196. * @param initialM13 defines 3rd value of 1st row
  63197. * @param initialM14 defines 4th value of 1st row
  63198. * @param initialM21 defines 1st value of 2nd row
  63199. * @param initialM22 defines 2nd value of 2nd row
  63200. * @param initialM23 defines 3rd value of 2nd row
  63201. * @param initialM24 defines 4th value of 2nd row
  63202. * @param initialM31 defines 1st value of 3rd row
  63203. * @param initialM32 defines 2nd value of 3rd row
  63204. * @param initialM33 defines 3rd value of 3rd row
  63205. * @param initialM34 defines 4th value of 3rd row
  63206. * @param initialM41 defines 1st value of 4th row
  63207. * @param initialM42 defines 2nd value of 4th row
  63208. * @param initialM43 defines 3rd value of 4th row
  63209. * @param initialM44 defines 4th value of 4th row
  63210. * @returns the new matrix
  63211. */
  63212. 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;
  63213. /**
  63214. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63215. * @param scale defines the scale vector3
  63216. * @param rotation defines the rotation quaternion
  63217. * @param translation defines the translation vector3
  63218. * @returns a new matrix
  63219. */
  63220. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63221. /**
  63222. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63223. * @param scale defines the scale vector3
  63224. * @param rotation defines the rotation quaternion
  63225. * @param translation defines the translation vector3
  63226. * @param result defines the target matrix
  63227. */
  63228. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63229. /**
  63230. * Creates a new identity matrix
  63231. * @returns a new identity matrix
  63232. */
  63233. static Identity(): Matrix;
  63234. /**
  63235. * Creates a new identity matrix and stores the result in a given matrix
  63236. * @param result defines the target matrix
  63237. */
  63238. static IdentityToRef(result: Matrix): void;
  63239. /**
  63240. * Creates a new zero matrix
  63241. * @returns a new zero matrix
  63242. */
  63243. static Zero(): Matrix;
  63244. /**
  63245. * Creates a new rotation matrix for "angle" radians around the X axis
  63246. * @param angle defines the angle (in radians) to use
  63247. * @return the new matrix
  63248. */
  63249. static RotationX(angle: number): Matrix;
  63250. /**
  63251. * Creates a new matrix as the invert of a given matrix
  63252. * @param source defines the source matrix
  63253. * @returns the new matrix
  63254. */
  63255. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63256. /**
  63257. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63258. * @param angle defines the angle (in radians) to use
  63259. * @param result defines the target matrix
  63260. */
  63261. static RotationXToRef(angle: number, result: Matrix): void;
  63262. /**
  63263. * Creates a new rotation matrix for "angle" radians around the Y axis
  63264. * @param angle defines the angle (in radians) to use
  63265. * @return the new matrix
  63266. */
  63267. static RotationY(angle: number): Matrix;
  63268. /**
  63269. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63270. * @param angle defines the angle (in radians) to use
  63271. * @param result defines the target matrix
  63272. */
  63273. static RotationYToRef(angle: number, result: Matrix): void;
  63274. /**
  63275. * Creates a new rotation matrix for "angle" radians around the Z axis
  63276. * @param angle defines the angle (in radians) to use
  63277. * @return the new matrix
  63278. */
  63279. static RotationZ(angle: number): Matrix;
  63280. /**
  63281. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63282. * @param angle defines the angle (in radians) to use
  63283. * @param result defines the target matrix
  63284. */
  63285. static RotationZToRef(angle: number, result: Matrix): void;
  63286. /**
  63287. * Creates a new rotation matrix for "angle" radians around the given axis
  63288. * @param axis defines the axis to use
  63289. * @param angle defines the angle (in radians) to use
  63290. * @return the new matrix
  63291. */
  63292. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63293. /**
  63294. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63295. * @param axis defines the axis to use
  63296. * @param angle defines the angle (in radians) to use
  63297. * @param result defines the target matrix
  63298. */
  63299. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63300. /**
  63301. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63302. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63303. * @param from defines the vector to align
  63304. * @param to defines the vector to align to
  63305. * @param result defines the target matrix
  63306. */
  63307. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63308. /**
  63309. * Creates a rotation matrix
  63310. * @param yaw defines the yaw angle in radians (Y axis)
  63311. * @param pitch defines the pitch angle in radians (X axis)
  63312. * @param roll defines the roll angle in radians (X axis)
  63313. * @returns the new rotation matrix
  63314. */
  63315. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63316. /**
  63317. * Creates a rotation matrix and stores it in a given matrix
  63318. * @param yaw defines the yaw angle in radians (Y axis)
  63319. * @param pitch defines the pitch angle in radians (X axis)
  63320. * @param roll defines the roll angle in radians (X axis)
  63321. * @param result defines the target matrix
  63322. */
  63323. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63324. /**
  63325. * Creates a scaling matrix
  63326. * @param x defines the scale factor on X axis
  63327. * @param y defines the scale factor on Y axis
  63328. * @param z defines the scale factor on Z axis
  63329. * @returns the new matrix
  63330. */
  63331. static Scaling(x: number, y: number, z: number): Matrix;
  63332. /**
  63333. * Creates a scaling matrix and stores it in a given matrix
  63334. * @param x defines the scale factor on X axis
  63335. * @param y defines the scale factor on Y axis
  63336. * @param z defines the scale factor on Z axis
  63337. * @param result defines the target matrix
  63338. */
  63339. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63340. /**
  63341. * Creates a translation matrix
  63342. * @param x defines the translation on X axis
  63343. * @param y defines the translation on Y axis
  63344. * @param z defines the translationon Z axis
  63345. * @returns the new matrix
  63346. */
  63347. static Translation(x: number, y: number, z: number): Matrix;
  63348. /**
  63349. * Creates a translation matrix and stores it in a given matrix
  63350. * @param x defines the translation on X axis
  63351. * @param y defines the translation on Y axis
  63352. * @param z defines the translationon Z axis
  63353. * @param result defines the target matrix
  63354. */
  63355. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63356. /**
  63357. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63358. * @param startValue defines the start value
  63359. * @param endValue defines the end value
  63360. * @param gradient defines the gradient factor
  63361. * @returns the new matrix
  63362. */
  63363. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63364. /**
  63365. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63366. * @param startValue defines the start value
  63367. * @param endValue defines the end value
  63368. * @param gradient defines the gradient factor
  63369. * @param result defines the Matrix object where to store data
  63370. */
  63371. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63372. /**
  63373. * Builds a new matrix whose values are computed by:
  63374. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63375. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63376. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63377. * @param startValue defines the first matrix
  63378. * @param endValue defines the second matrix
  63379. * @param gradient defines the gradient between the two matrices
  63380. * @returns the new matrix
  63381. */
  63382. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63383. /**
  63384. * Update a matrix to values which are computed by:
  63385. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63386. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63387. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63388. * @param startValue defines the first matrix
  63389. * @param endValue defines the second matrix
  63390. * @param gradient defines the gradient between the two matrices
  63391. * @param result defines the target matrix
  63392. */
  63393. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63394. /**
  63395. * 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"
  63396. * This function works in left handed mode
  63397. * @param eye defines the final position of the entity
  63398. * @param target defines where the entity should look at
  63399. * @param up defines the up vector for the entity
  63400. * @returns the new matrix
  63401. */
  63402. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63403. /**
  63404. * 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".
  63405. * This function works in left handed mode
  63406. * @param eye defines the final position of the entity
  63407. * @param target defines where the entity should look at
  63408. * @param up defines the up vector for the entity
  63409. * @param result defines the target matrix
  63410. */
  63411. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63412. /**
  63413. * 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"
  63414. * This function works in right handed mode
  63415. * @param eye defines the final position of the entity
  63416. * @param target defines where the entity should look at
  63417. * @param up defines the up vector for the entity
  63418. * @returns the new matrix
  63419. */
  63420. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63421. /**
  63422. * 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".
  63423. * This function works in right handed mode
  63424. * @param eye defines the final position of the entity
  63425. * @param target defines where the entity should look at
  63426. * @param up defines the up vector for the entity
  63427. * @param result defines the target matrix
  63428. */
  63429. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63430. /**
  63431. * Create a left-handed orthographic projection matrix
  63432. * @param width defines the viewport width
  63433. * @param height defines the viewport height
  63434. * @param znear defines the near clip plane
  63435. * @param zfar defines the far clip plane
  63436. * @returns a new matrix as a left-handed orthographic projection matrix
  63437. */
  63438. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63439. /**
  63440. * Store a left-handed orthographic projection to a given matrix
  63441. * @param width defines the viewport width
  63442. * @param height defines the viewport height
  63443. * @param znear defines the near clip plane
  63444. * @param zfar defines the far clip plane
  63445. * @param result defines the target matrix
  63446. */
  63447. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63448. /**
  63449. * Create a left-handed orthographic projection matrix
  63450. * @param left defines the viewport left coordinate
  63451. * @param right defines the viewport right coordinate
  63452. * @param bottom defines the viewport bottom coordinate
  63453. * @param top defines the viewport top coordinate
  63454. * @param znear defines the near clip plane
  63455. * @param zfar defines the far clip plane
  63456. * @returns a new matrix as a left-handed orthographic projection matrix
  63457. */
  63458. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63459. /**
  63460. * Stores a left-handed orthographic projection into a given matrix
  63461. * @param left defines the viewport left coordinate
  63462. * @param right defines the viewport right coordinate
  63463. * @param bottom defines the viewport bottom coordinate
  63464. * @param top defines the viewport top coordinate
  63465. * @param znear defines the near clip plane
  63466. * @param zfar defines the far clip plane
  63467. * @param result defines the target matrix
  63468. */
  63469. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63470. /**
  63471. * Creates a right-handed orthographic projection matrix
  63472. * @param left defines the viewport left coordinate
  63473. * @param right defines the viewport right coordinate
  63474. * @param bottom defines the viewport bottom coordinate
  63475. * @param top defines the viewport top coordinate
  63476. * @param znear defines the near clip plane
  63477. * @param zfar defines the far clip plane
  63478. * @returns a new matrix as a right-handed orthographic projection matrix
  63479. */
  63480. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63481. /**
  63482. * Stores a right-handed orthographic projection into a given matrix
  63483. * @param left defines the viewport left coordinate
  63484. * @param right defines the viewport right coordinate
  63485. * @param bottom defines the viewport bottom coordinate
  63486. * @param top defines the viewport top coordinate
  63487. * @param znear defines the near clip plane
  63488. * @param zfar defines the far clip plane
  63489. * @param result defines the target matrix
  63490. */
  63491. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63492. /**
  63493. * Creates a left-handed perspective projection matrix
  63494. * @param width defines the viewport width
  63495. * @param height defines the viewport height
  63496. * @param znear defines the near clip plane
  63497. * @param zfar defines the far clip plane
  63498. * @returns a new matrix as a left-handed perspective projection matrix
  63499. */
  63500. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63501. /**
  63502. * Creates a left-handed perspective projection matrix
  63503. * @param fov defines the horizontal field of view
  63504. * @param aspect defines the aspect ratio
  63505. * @param znear defines the near clip plane
  63506. * @param zfar defines the far clip plane
  63507. * @returns a new matrix as a left-handed perspective projection matrix
  63508. */
  63509. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63510. /**
  63511. * Stores a left-handed perspective projection into a given matrix
  63512. * @param fov defines the horizontal field of view
  63513. * @param aspect defines the aspect ratio
  63514. * @param znear defines the near clip plane
  63515. * @param zfar defines the far clip plane
  63516. * @param result defines the target matrix
  63517. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63518. */
  63519. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63520. /**
  63521. * Creates a right-handed perspective projection matrix
  63522. * @param fov defines the horizontal field of view
  63523. * @param aspect defines the aspect ratio
  63524. * @param znear defines the near clip plane
  63525. * @param zfar defines the far clip plane
  63526. * @returns a new matrix as a right-handed perspective projection matrix
  63527. */
  63528. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63529. /**
  63530. * Stores a right-handed perspective projection into a given matrix
  63531. * @param fov defines the horizontal field of view
  63532. * @param aspect defines the aspect ratio
  63533. * @param znear defines the near clip plane
  63534. * @param zfar defines the far clip plane
  63535. * @param result defines the target matrix
  63536. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63537. */
  63538. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63539. /**
  63540. * Stores a perspective projection for WebVR info a given matrix
  63541. * @param fov defines the field of view
  63542. * @param znear defines the near clip plane
  63543. * @param zfar defines the far clip plane
  63544. * @param result defines the target matrix
  63545. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63546. */
  63547. static PerspectiveFovWebVRToRef(fov: {
  63548. upDegrees: number;
  63549. downDegrees: number;
  63550. leftDegrees: number;
  63551. rightDegrees: number;
  63552. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63553. /**
  63554. * Computes a complete transformation matrix
  63555. * @param viewport defines the viewport to use
  63556. * @param world defines the world matrix
  63557. * @param view defines the view matrix
  63558. * @param projection defines the projection matrix
  63559. * @param zmin defines the near clip plane
  63560. * @param zmax defines the far clip plane
  63561. * @returns the transformation matrix
  63562. */
  63563. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63564. /**
  63565. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63566. * @param matrix defines the matrix to use
  63567. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63568. */
  63569. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63570. /**
  63571. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63572. * @param matrix defines the matrix to use
  63573. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63574. */
  63575. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63576. /**
  63577. * Compute the transpose of a given matrix
  63578. * @param matrix defines the matrix to transpose
  63579. * @returns the new matrix
  63580. */
  63581. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63582. /**
  63583. * Compute the transpose of a matrix and store it in a target matrix
  63584. * @param matrix defines the matrix to transpose
  63585. * @param result defines the target matrix
  63586. */
  63587. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63588. /**
  63589. * Computes a reflection matrix from a plane
  63590. * @param plane defines the reflection plane
  63591. * @returns a new matrix
  63592. */
  63593. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63594. /**
  63595. * Computes a reflection matrix from a plane
  63596. * @param plane defines the reflection plane
  63597. * @param result defines the target matrix
  63598. */
  63599. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63600. /**
  63601. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63602. * @param xaxis defines the value of the 1st axis
  63603. * @param yaxis defines the value of the 2nd axis
  63604. * @param zaxis defines the value of the 3rd axis
  63605. * @param result defines the target matrix
  63606. */
  63607. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63608. /**
  63609. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63610. * @param quat defines the quaternion to use
  63611. * @param result defines the target matrix
  63612. */
  63613. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63614. }
  63615. /**
  63616. * Represens a plane by the equation ax + by + cz + d = 0
  63617. */
  63618. export class Plane {
  63619. /**
  63620. * Normal of the plane (a,b,c)
  63621. */
  63622. normal: Vector3;
  63623. /**
  63624. * d component of the plane
  63625. */
  63626. d: number;
  63627. /**
  63628. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63629. * @param a a component of the plane
  63630. * @param b b component of the plane
  63631. * @param c c component of the plane
  63632. * @param d d component of the plane
  63633. */
  63634. constructor(a: number, b: number, c: number, d: number);
  63635. /**
  63636. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63637. */
  63638. asArray(): number[];
  63639. /**
  63640. * @returns a new plane copied from the current Plane.
  63641. */
  63642. clone(): Plane;
  63643. /**
  63644. * @returns the string "Plane".
  63645. */
  63646. getClassName(): string;
  63647. /**
  63648. * @returns the Plane hash code.
  63649. */
  63650. getHashCode(): number;
  63651. /**
  63652. * Normalize the current Plane in place.
  63653. * @returns the updated Plane.
  63654. */
  63655. normalize(): Plane;
  63656. /**
  63657. * Applies a transformation the plane and returns the result
  63658. * @param transformation the transformation matrix to be applied to the plane
  63659. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63660. */
  63661. transform(transformation: DeepImmutable<Matrix>): Plane;
  63662. /**
  63663. * Calcualtte the dot product between the point and the plane normal
  63664. * @param point point to calculate the dot product with
  63665. * @returns the dot product (float) of the point coordinates and the plane normal.
  63666. */
  63667. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63668. /**
  63669. * Updates the current Plane from the plane defined by the three given points.
  63670. * @param point1 one of the points used to contruct the plane
  63671. * @param point2 one of the points used to contruct the plane
  63672. * @param point3 one of the points used to contruct the plane
  63673. * @returns the updated Plane.
  63674. */
  63675. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63676. /**
  63677. * Checks if the plane is facing a given direction
  63678. * @param direction the direction to check if the plane is facing
  63679. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63680. * @returns True is the vector "direction" is the same side than the plane normal.
  63681. */
  63682. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63683. /**
  63684. * Calculates the distance to a point
  63685. * @param point point to calculate distance to
  63686. * @returns the signed distance (float) from the given point to the Plane.
  63687. */
  63688. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63689. /**
  63690. * Creates a plane from an array
  63691. * @param array the array to create a plane from
  63692. * @returns a new Plane from the given array.
  63693. */
  63694. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63695. /**
  63696. * Creates a plane from three points
  63697. * @param point1 point used to create the plane
  63698. * @param point2 point used to create the plane
  63699. * @param point3 point used to create the plane
  63700. * @returns a new Plane defined by the three given points.
  63701. */
  63702. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63703. /**
  63704. * Creates a plane from an origin point and a normal
  63705. * @param origin origin of the plane to be constructed
  63706. * @param normal normal of the plane to be constructed
  63707. * @returns a new Plane the normal vector to this plane at the given origin point.
  63708. * Note : the vector "normal" is updated because normalized.
  63709. */
  63710. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63711. /**
  63712. * Calculates the distance from a plane and a point
  63713. * @param origin origin of the plane to be constructed
  63714. * @param normal normal of the plane to be constructed
  63715. * @param point point to calculate distance to
  63716. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63717. */
  63718. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63719. }
  63720. /**
  63721. * Class used to represent a viewport on screen
  63722. */
  63723. export class Viewport {
  63724. /** viewport left coordinate */
  63725. x: number;
  63726. /** viewport top coordinate */
  63727. y: number;
  63728. /**viewport width */
  63729. width: number;
  63730. /** viewport height */
  63731. height: number;
  63732. /**
  63733. * Creates a Viewport object located at (x, y) and sized (width, height)
  63734. * @param x defines viewport left coordinate
  63735. * @param y defines viewport top coordinate
  63736. * @param width defines the viewport width
  63737. * @param height defines the viewport height
  63738. */
  63739. constructor(
  63740. /** viewport left coordinate */
  63741. x: number,
  63742. /** viewport top coordinate */
  63743. y: number,
  63744. /**viewport width */
  63745. width: number,
  63746. /** viewport height */
  63747. height: number);
  63748. /**
  63749. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63750. * @param renderWidth defines the rendering width
  63751. * @param renderHeight defines the rendering height
  63752. * @returns a new Viewport
  63753. */
  63754. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63755. /**
  63756. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63757. * @param renderWidth defines the rendering width
  63758. * @param renderHeight defines the rendering height
  63759. * @param ref defines the target viewport
  63760. * @returns the current viewport
  63761. */
  63762. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63763. /**
  63764. * Returns a new Viewport copied from the current one
  63765. * @returns a new Viewport
  63766. */
  63767. clone(): Viewport;
  63768. }
  63769. /**
  63770. * Reprasents a camera frustum
  63771. */
  63772. export class Frustum {
  63773. /**
  63774. * Gets the planes representing the frustum
  63775. * @param transform matrix to be applied to the returned planes
  63776. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63777. */
  63778. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63779. /**
  63780. * Gets the near frustum plane transformed by the transform matrix
  63781. * @param transform transformation matrix to be applied to the resulting frustum plane
  63782. * @param frustumPlane the resuling frustum plane
  63783. */
  63784. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63785. /**
  63786. * Gets the far frustum plane transformed by the transform matrix
  63787. * @param transform transformation matrix to be applied to the resulting frustum plane
  63788. * @param frustumPlane the resuling frustum plane
  63789. */
  63790. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63791. /**
  63792. * Gets the left frustum plane transformed by the transform matrix
  63793. * @param transform transformation matrix to be applied to the resulting frustum plane
  63794. * @param frustumPlane the resuling frustum plane
  63795. */
  63796. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63797. /**
  63798. * Gets the right frustum plane transformed by the transform matrix
  63799. * @param transform transformation matrix to be applied to the resulting frustum plane
  63800. * @param frustumPlane the resuling frustum plane
  63801. */
  63802. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63803. /**
  63804. * Gets the top frustum plane transformed by the transform matrix
  63805. * @param transform transformation matrix to be applied to the resulting frustum plane
  63806. * @param frustumPlane the resuling frustum plane
  63807. */
  63808. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63809. /**
  63810. * Gets the bottom frustum plane transformed by the transform matrix
  63811. * @param transform transformation matrix to be applied to the resulting frustum plane
  63812. * @param frustumPlane the resuling frustum plane
  63813. */
  63814. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63815. /**
  63816. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63817. * @param transform transformation matrix to be applied to the resulting frustum planes
  63818. * @param frustumPlanes the resuling frustum planes
  63819. */
  63820. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63821. }
  63822. /** Defines supported spaces */
  63823. export enum Space {
  63824. /** Local (object) space */
  63825. LOCAL = 0,
  63826. /** World space */
  63827. WORLD = 1,
  63828. /** Bone space */
  63829. BONE = 2
  63830. }
  63831. /** Defines the 3 main axes */
  63832. export class Axis {
  63833. /** X axis */
  63834. static X: Vector3;
  63835. /** Y axis */
  63836. static Y: Vector3;
  63837. /** Z axis */
  63838. static Z: Vector3;
  63839. }
  63840. /** Class used to represent a Bezier curve */
  63841. export class BezierCurve {
  63842. /**
  63843. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63844. * @param t defines the time
  63845. * @param x1 defines the left coordinate on X axis
  63846. * @param y1 defines the left coordinate on Y axis
  63847. * @param x2 defines the right coordinate on X axis
  63848. * @param y2 defines the right coordinate on Y axis
  63849. * @returns the interpolated value
  63850. */
  63851. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63852. }
  63853. /**
  63854. * Defines potential orientation for back face culling
  63855. */
  63856. export enum Orientation {
  63857. /**
  63858. * Clockwise
  63859. */
  63860. CW = 0,
  63861. /** Counter clockwise */
  63862. CCW = 1
  63863. }
  63864. /**
  63865. * Defines angle representation
  63866. */
  63867. export class Angle {
  63868. private _radians;
  63869. /**
  63870. * Creates an Angle object of "radians" radians (float).
  63871. * @param radians the angle in radians
  63872. */
  63873. constructor(radians: number);
  63874. /**
  63875. * Get value in degrees
  63876. * @returns the Angle value in degrees (float)
  63877. */
  63878. degrees(): number;
  63879. /**
  63880. * Get value in radians
  63881. * @returns the Angle value in radians (float)
  63882. */
  63883. radians(): number;
  63884. /**
  63885. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63886. * @param a defines first vector
  63887. * @param b defines second vector
  63888. * @returns a new Angle
  63889. */
  63890. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63891. /**
  63892. * Gets a new Angle object from the given float in radians
  63893. * @param radians defines the angle value in radians
  63894. * @returns a new Angle
  63895. */
  63896. static FromRadians(radians: number): Angle;
  63897. /**
  63898. * Gets a new Angle object from the given float in degrees
  63899. * @param degrees defines the angle value in degrees
  63900. * @returns a new Angle
  63901. */
  63902. static FromDegrees(degrees: number): Angle;
  63903. }
  63904. /**
  63905. * This represents an arc in a 2d space.
  63906. */
  63907. export class Arc2 {
  63908. /** Defines the start point of the arc */
  63909. startPoint: Vector2;
  63910. /** Defines the mid point of the arc */
  63911. midPoint: Vector2;
  63912. /** Defines the end point of the arc */
  63913. endPoint: Vector2;
  63914. /**
  63915. * Defines the center point of the arc.
  63916. */
  63917. centerPoint: Vector2;
  63918. /**
  63919. * Defines the radius of the arc.
  63920. */
  63921. radius: number;
  63922. /**
  63923. * Defines the angle of the arc (from mid point to end point).
  63924. */
  63925. angle: Angle;
  63926. /**
  63927. * Defines the start angle of the arc (from start point to middle point).
  63928. */
  63929. startAngle: Angle;
  63930. /**
  63931. * Defines the orientation of the arc (clock wise/counter clock wise).
  63932. */
  63933. orientation: Orientation;
  63934. /**
  63935. * Creates an Arc object from the three given points : start, middle and end.
  63936. * @param startPoint Defines the start point of the arc
  63937. * @param midPoint Defines the midlle point of the arc
  63938. * @param endPoint Defines the end point of the arc
  63939. */
  63940. constructor(
  63941. /** Defines the start point of the arc */
  63942. startPoint: Vector2,
  63943. /** Defines the mid point of the arc */
  63944. midPoint: Vector2,
  63945. /** Defines the end point of the arc */
  63946. endPoint: Vector2);
  63947. }
  63948. /**
  63949. * Represents a 2D path made up of multiple 2D points
  63950. */
  63951. export class Path2 {
  63952. private _points;
  63953. private _length;
  63954. /**
  63955. * If the path start and end point are the same
  63956. */
  63957. closed: boolean;
  63958. /**
  63959. * Creates a Path2 object from the starting 2D coordinates x and y.
  63960. * @param x the starting points x value
  63961. * @param y the starting points y value
  63962. */
  63963. constructor(x: number, y: number);
  63964. /**
  63965. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63966. * @param x the added points x value
  63967. * @param y the added points y value
  63968. * @returns the updated Path2.
  63969. */
  63970. addLineTo(x: number, y: number): Path2;
  63971. /**
  63972. * 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.
  63973. * @param midX middle point x value
  63974. * @param midY middle point y value
  63975. * @param endX end point x value
  63976. * @param endY end point y value
  63977. * @param numberOfSegments (default: 36)
  63978. * @returns the updated Path2.
  63979. */
  63980. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63981. /**
  63982. * Closes the Path2.
  63983. * @returns the Path2.
  63984. */
  63985. close(): Path2;
  63986. /**
  63987. * Gets the sum of the distance between each sequential point in the path
  63988. * @returns the Path2 total length (float).
  63989. */
  63990. length(): number;
  63991. /**
  63992. * Gets the points which construct the path
  63993. * @returns the Path2 internal array of points.
  63994. */
  63995. getPoints(): Vector2[];
  63996. /**
  63997. * Retreives the point at the distance aways from the starting point
  63998. * @param normalizedLengthPosition the length along the path to retreive the point from
  63999. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  64000. */
  64001. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  64002. /**
  64003. * Creates a new path starting from an x and y position
  64004. * @param x starting x value
  64005. * @param y starting y value
  64006. * @returns a new Path2 starting at the coordinates (x, y).
  64007. */
  64008. static StartingAt(x: number, y: number): Path2;
  64009. }
  64010. /**
  64011. * Represents a 3D path made up of multiple 3D points
  64012. */
  64013. export class Path3D {
  64014. /**
  64015. * an array of Vector3, the curve axis of the Path3D
  64016. */
  64017. path: Vector3[];
  64018. private _curve;
  64019. private _distances;
  64020. private _tangents;
  64021. private _normals;
  64022. private _binormals;
  64023. private _raw;
  64024. /**
  64025. * new Path3D(path, normal, raw)
  64026. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  64027. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  64028. * @param path an array of Vector3, the curve axis of the Path3D
  64029. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  64030. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  64031. */
  64032. constructor(
  64033. /**
  64034. * an array of Vector3, the curve axis of the Path3D
  64035. */
  64036. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  64037. /**
  64038. * Returns the Path3D array of successive Vector3 designing its curve.
  64039. * @returns the Path3D array of successive Vector3 designing its curve.
  64040. */
  64041. getCurve(): Vector3[];
  64042. /**
  64043. * Returns an array populated with tangent vectors on each Path3D curve point.
  64044. * @returns an array populated with tangent vectors on each Path3D curve point.
  64045. */
  64046. getTangents(): Vector3[];
  64047. /**
  64048. * Returns an array populated with normal vectors on each Path3D curve point.
  64049. * @returns an array populated with normal vectors on each Path3D curve point.
  64050. */
  64051. getNormals(): Vector3[];
  64052. /**
  64053. * Returns an array populated with binormal vectors on each Path3D curve point.
  64054. * @returns an array populated with binormal vectors on each Path3D curve point.
  64055. */
  64056. getBinormals(): Vector3[];
  64057. /**
  64058. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  64059. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  64060. */
  64061. getDistances(): number[];
  64062. /**
  64063. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  64064. * @param path path which all values are copied into the curves points
  64065. * @param firstNormal which should be projected onto the curve
  64066. * @returns the same object updated.
  64067. */
  64068. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  64069. private _compute;
  64070. private _getFirstNonNullVector;
  64071. private _getLastNonNullVector;
  64072. private _normalVector;
  64073. }
  64074. /**
  64075. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64076. * A Curve3 is designed from a series of successive Vector3.
  64077. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  64078. */
  64079. export class Curve3 {
  64080. private _points;
  64081. private _length;
  64082. /**
  64083. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  64084. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  64085. * @param v1 (Vector3) the control point
  64086. * @param v2 (Vector3) the end point of the Quadratic Bezier
  64087. * @param nbPoints (integer) the wanted number of points in the curve
  64088. * @returns the created Curve3
  64089. */
  64090. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64091. /**
  64092. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  64093. * @param v0 (Vector3) the origin point of the Cubic Bezier
  64094. * @param v1 (Vector3) the first control point
  64095. * @param v2 (Vector3) the second control point
  64096. * @param v3 (Vector3) the end point of the Cubic Bezier
  64097. * @param nbPoints (integer) the wanted number of points in the curve
  64098. * @returns the created Curve3
  64099. */
  64100. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64101. /**
  64102. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  64103. * @param p1 (Vector3) the origin point of the Hermite Spline
  64104. * @param t1 (Vector3) the tangent vector at the origin point
  64105. * @param p2 (Vector3) the end point of the Hermite Spline
  64106. * @param t2 (Vector3) the tangent vector at the end point
  64107. * @param nbPoints (integer) the wanted number of points in the curve
  64108. * @returns the created Curve3
  64109. */
  64110. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64111. /**
  64112. * Returns a Curve3 object along a CatmullRom Spline curve :
  64113. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  64114. * @param nbPoints (integer) the wanted number of points between each curve control points
  64115. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  64116. * @returns the created Curve3
  64117. */
  64118. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  64119. /**
  64120. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64121. * A Curve3 is designed from a series of successive Vector3.
  64122. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64123. * @param points points which make up the curve
  64124. */
  64125. constructor(points: Vector3[]);
  64126. /**
  64127. * @returns the Curve3 stored array of successive Vector3
  64128. */
  64129. getPoints(): Vector3[];
  64130. /**
  64131. * @returns the computed length (float) of the curve.
  64132. */
  64133. length(): number;
  64134. /**
  64135. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64136. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64137. * curveA and curveB keep unchanged.
  64138. * @param curve the curve to continue from this curve
  64139. * @returns the newly constructed curve
  64140. */
  64141. continue(curve: DeepImmutable<Curve3>): Curve3;
  64142. private _computeLength;
  64143. }
  64144. /**
  64145. * Contains position and normal vectors for a vertex
  64146. */
  64147. export class PositionNormalVertex {
  64148. /** the position of the vertex (defaut: 0,0,0) */
  64149. position: Vector3;
  64150. /** the normal of the vertex (defaut: 0,1,0) */
  64151. normal: Vector3;
  64152. /**
  64153. * Creates a PositionNormalVertex
  64154. * @param position the position of the vertex (defaut: 0,0,0)
  64155. * @param normal the normal of the vertex (defaut: 0,1,0)
  64156. */
  64157. constructor(
  64158. /** the position of the vertex (defaut: 0,0,0) */
  64159. position?: Vector3,
  64160. /** the normal of the vertex (defaut: 0,1,0) */
  64161. normal?: Vector3);
  64162. /**
  64163. * Clones the PositionNormalVertex
  64164. * @returns the cloned PositionNormalVertex
  64165. */
  64166. clone(): PositionNormalVertex;
  64167. }
  64168. /**
  64169. * Contains position, normal and uv vectors for a vertex
  64170. */
  64171. export class PositionNormalTextureVertex {
  64172. /** the position of the vertex (defaut: 0,0,0) */
  64173. position: Vector3;
  64174. /** the normal of the vertex (defaut: 0,1,0) */
  64175. normal: Vector3;
  64176. /** the uv of the vertex (default: 0,0) */
  64177. uv: Vector2;
  64178. /**
  64179. * Creates a PositionNormalTextureVertex
  64180. * @param position the position of the vertex (defaut: 0,0,0)
  64181. * @param normal the normal of the vertex (defaut: 0,1,0)
  64182. * @param uv the uv of the vertex (default: 0,0)
  64183. */
  64184. constructor(
  64185. /** the position of the vertex (defaut: 0,0,0) */
  64186. position?: Vector3,
  64187. /** the normal of the vertex (defaut: 0,1,0) */
  64188. normal?: Vector3,
  64189. /** the uv of the vertex (default: 0,0) */
  64190. uv?: Vector2);
  64191. /**
  64192. * Clones the PositionNormalTextureVertex
  64193. * @returns the cloned PositionNormalTextureVertex
  64194. */
  64195. clone(): PositionNormalTextureVertex;
  64196. }
  64197. /**
  64198. * @hidden
  64199. */
  64200. export class Tmp {
  64201. static Color3: Color3[];
  64202. static Color4: Color4[];
  64203. static Vector2: Vector2[];
  64204. static Vector3: Vector3[];
  64205. static Vector4: Vector4[];
  64206. static Quaternion: Quaternion[];
  64207. static Matrix: Matrix[];
  64208. }
  64209. }
  64210. declare module BABYLON {
  64211. /**
  64212. * Class used to enable access to offline support
  64213. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64214. */
  64215. export interface IOfflineProvider {
  64216. /**
  64217. * Gets a boolean indicating if scene must be saved in the database
  64218. */
  64219. enableSceneOffline: boolean;
  64220. /**
  64221. * Gets a boolean indicating if textures must be saved in the database
  64222. */
  64223. enableTexturesOffline: boolean;
  64224. /**
  64225. * Open the offline support and make it available
  64226. * @param successCallback defines the callback to call on success
  64227. * @param errorCallback defines the callback to call on error
  64228. */
  64229. open(successCallback: () => void, errorCallback: () => void): void;
  64230. /**
  64231. * Loads an image from the offline support
  64232. * @param url defines the url to load from
  64233. * @param image defines the target DOM image
  64234. */
  64235. loadImage(url: string, image: HTMLImageElement): void;
  64236. /**
  64237. * Loads a file from offline support
  64238. * @param url defines the URL to load from
  64239. * @param sceneLoaded defines a callback to call on success
  64240. * @param progressCallBack defines a callback to call when progress changed
  64241. * @param errorCallback defines a callback to call on error
  64242. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64243. */
  64244. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64245. }
  64246. }
  64247. declare module BABYLON {
  64248. /**
  64249. * A class serves as a medium between the observable and its observers
  64250. */
  64251. export class EventState {
  64252. /**
  64253. * Create a new EventState
  64254. * @param mask defines the mask associated with this state
  64255. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64256. * @param target defines the original target of the state
  64257. * @param currentTarget defines the current target of the state
  64258. */
  64259. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64260. /**
  64261. * Initialize the current event state
  64262. * @param mask defines the mask associated with this state
  64263. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64264. * @param target defines the original target of the state
  64265. * @param currentTarget defines the current target of the state
  64266. * @returns the current event state
  64267. */
  64268. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64269. /**
  64270. * An Observer can set this property to true to prevent subsequent observers of being notified
  64271. */
  64272. skipNextObservers: boolean;
  64273. /**
  64274. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64275. */
  64276. mask: number;
  64277. /**
  64278. * The object that originally notified the event
  64279. */
  64280. target?: any;
  64281. /**
  64282. * The current object in the bubbling phase
  64283. */
  64284. currentTarget?: any;
  64285. /**
  64286. * This will be populated with the return value of the last function that was executed.
  64287. * If it is the first function in the callback chain it will be the event data.
  64288. */
  64289. lastReturnValue?: any;
  64290. }
  64291. /**
  64292. * Represent an Observer registered to a given Observable object.
  64293. */
  64294. export class Observer<T> {
  64295. /**
  64296. * Defines the callback to call when the observer is notified
  64297. */
  64298. callback: (eventData: T, eventState: EventState) => void;
  64299. /**
  64300. * Defines the mask of the observer (used to filter notifications)
  64301. */
  64302. mask: number;
  64303. /**
  64304. * Defines the current scope used to restore the JS context
  64305. */
  64306. scope: any;
  64307. /** @hidden */
  64308. _willBeUnregistered: boolean;
  64309. /**
  64310. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64311. */
  64312. unregisterOnNextCall: boolean;
  64313. /**
  64314. * Creates a new observer
  64315. * @param callback defines the callback to call when the observer is notified
  64316. * @param mask defines the mask of the observer (used to filter notifications)
  64317. * @param scope defines the current scope used to restore the JS context
  64318. */
  64319. constructor(
  64320. /**
  64321. * Defines the callback to call when the observer is notified
  64322. */
  64323. callback: (eventData: T, eventState: EventState) => void,
  64324. /**
  64325. * Defines the mask of the observer (used to filter notifications)
  64326. */
  64327. mask: number,
  64328. /**
  64329. * Defines the current scope used to restore the JS context
  64330. */
  64331. scope?: any);
  64332. }
  64333. /**
  64334. * Represent a list of observers registered to multiple Observables object.
  64335. */
  64336. export class MultiObserver<T> {
  64337. private _observers;
  64338. private _observables;
  64339. /**
  64340. * Release associated resources
  64341. */
  64342. dispose(): void;
  64343. /**
  64344. * Raise a callback when one of the observable will notify
  64345. * @param observables defines a list of observables to watch
  64346. * @param callback defines the callback to call on notification
  64347. * @param mask defines the mask used to filter notifications
  64348. * @param scope defines the current scope used to restore the JS context
  64349. * @returns the new MultiObserver
  64350. */
  64351. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64352. }
  64353. /**
  64354. * The Observable class is a simple implementation of the Observable pattern.
  64355. *
  64356. * 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.
  64357. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64358. * 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).
  64359. * 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.
  64360. */
  64361. export class Observable<T> {
  64362. private _observers;
  64363. private _eventState;
  64364. private _onObserverAdded;
  64365. /**
  64366. * Creates a new observable
  64367. * @param onObserverAdded defines a callback to call when a new observer is added
  64368. */
  64369. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64370. /**
  64371. * Create a new Observer with the specified callback
  64372. * @param callback the callback that will be executed for that Observer
  64373. * @param mask the mask used to filter observers
  64374. * @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.
  64375. * @param scope optional scope for the callback to be called from
  64376. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64377. * @returns the new observer created for the callback
  64378. */
  64379. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64380. /**
  64381. * Create a new Observer with the specified callback and unregisters after the next notification
  64382. * @param callback the callback that will be executed for that Observer
  64383. * @returns the new observer created for the callback
  64384. */
  64385. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64386. /**
  64387. * Remove an Observer from the Observable object
  64388. * @param observer the instance of the Observer to remove
  64389. * @returns false if it doesn't belong to this Observable
  64390. */
  64391. remove(observer: Nullable<Observer<T>>): boolean;
  64392. /**
  64393. * Remove a callback from the Observable object
  64394. * @param callback the callback to remove
  64395. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64396. * @returns false if it doesn't belong to this Observable
  64397. */
  64398. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64399. private _deferUnregister;
  64400. private _remove;
  64401. /**
  64402. * Moves the observable to the top of the observer list making it get called first when notified
  64403. * @param observer the observer to move
  64404. */
  64405. makeObserverTopPriority(observer: Observer<T>): void;
  64406. /**
  64407. * Moves the observable to the bottom of the observer list making it get called last when notified
  64408. * @param observer the observer to move
  64409. */
  64410. makeObserverBottomPriority(observer: Observer<T>): void;
  64411. /**
  64412. * Notify all Observers by calling their respective callback with the given data
  64413. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64414. * @param eventData defines the data to send to all observers
  64415. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64416. * @param target defines the original target of the state
  64417. * @param currentTarget defines the current target of the state
  64418. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64419. */
  64420. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64421. /**
  64422. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64423. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64424. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64425. * and it is crucial that all callbacks will be executed.
  64426. * The order of the callbacks is kept, callbacks are not executed parallel.
  64427. *
  64428. * @param eventData The data to be sent to each callback
  64429. * @param mask is used to filter observers defaults to -1
  64430. * @param target defines the callback target (see EventState)
  64431. * @param currentTarget defines he current object in the bubbling phase
  64432. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64433. */
  64434. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64435. /**
  64436. * Notify a specific observer
  64437. * @param observer defines the observer to notify
  64438. * @param eventData defines the data to be sent to each callback
  64439. * @param mask is used to filter observers defaults to -1
  64440. */
  64441. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64442. /**
  64443. * Gets a boolean indicating if the observable has at least one observer
  64444. * @returns true is the Observable has at least one Observer registered
  64445. */
  64446. hasObservers(): boolean;
  64447. /**
  64448. * Clear the list of observers
  64449. */
  64450. clear(): void;
  64451. /**
  64452. * Clone the current observable
  64453. * @returns a new observable
  64454. */
  64455. clone(): Observable<T>;
  64456. /**
  64457. * Does this observable handles observer registered with a given mask
  64458. * @param mask defines the mask to be tested
  64459. * @return whether or not one observer registered with the given mask is handeled
  64460. **/
  64461. hasSpecificMask(mask?: number): boolean;
  64462. }
  64463. }
  64464. declare module BABYLON {
  64465. /**
  64466. * Class used to help managing file picking and drag'n'drop
  64467. * File Storage
  64468. */
  64469. export class FilesInputStore {
  64470. /**
  64471. * List of files ready to be loaded
  64472. */
  64473. static FilesToLoad: {
  64474. [key: string]: File;
  64475. };
  64476. }
  64477. }
  64478. declare module BABYLON {
  64479. /** Defines the cross module used constants to avoid circular dependncies */
  64480. export class Constants {
  64481. /** Defines that alpha blending is disabled */
  64482. static readonly ALPHA_DISABLE: number;
  64483. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64484. static readonly ALPHA_ADD: number;
  64485. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64486. static readonly ALPHA_COMBINE: number;
  64487. /** Defines that alpha blending to DEST - SRC * DEST */
  64488. static readonly ALPHA_SUBTRACT: number;
  64489. /** Defines that alpha blending to SRC * DEST */
  64490. static readonly ALPHA_MULTIPLY: number;
  64491. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64492. static readonly ALPHA_MAXIMIZED: number;
  64493. /** Defines that alpha blending to SRC + DEST */
  64494. static readonly ALPHA_ONEONE: number;
  64495. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64496. static readonly ALPHA_PREMULTIPLIED: number;
  64497. /**
  64498. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64499. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64500. */
  64501. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64502. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64503. static readonly ALPHA_INTERPOLATE: number;
  64504. /**
  64505. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64506. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64507. */
  64508. static readonly ALPHA_SCREENMODE: number;
  64509. /** Defines that the ressource is not delayed*/
  64510. static readonly DELAYLOADSTATE_NONE: number;
  64511. /** Defines that the ressource was successfully delay loaded */
  64512. static readonly DELAYLOADSTATE_LOADED: number;
  64513. /** Defines that the ressource is currently delay loading */
  64514. static readonly DELAYLOADSTATE_LOADING: number;
  64515. /** Defines that the ressource is delayed and has not started loading */
  64516. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64518. static readonly NEVER: number;
  64519. /** 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 */
  64520. static readonly ALWAYS: number;
  64521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64522. static readonly LESS: number;
  64523. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64524. static readonly EQUAL: number;
  64525. /** 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 */
  64526. static readonly LEQUAL: number;
  64527. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64528. static readonly GREATER: number;
  64529. /** 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 */
  64530. static readonly GEQUAL: number;
  64531. /** 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 */
  64532. static readonly NOTEQUAL: number;
  64533. /** Passed to stencilOperation to specify that stencil value must be kept */
  64534. static readonly KEEP: number;
  64535. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64536. static readonly REPLACE: number;
  64537. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64538. static readonly INCR: number;
  64539. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64540. static readonly DECR: number;
  64541. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64542. static readonly INVERT: number;
  64543. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64544. static readonly INCR_WRAP: number;
  64545. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64546. static readonly DECR_WRAP: number;
  64547. /** Texture is not repeating outside of 0..1 UVs */
  64548. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64549. /** Texture is repeating outside of 0..1 UVs */
  64550. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64551. /** Texture is repeating and mirrored */
  64552. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64553. /** ALPHA */
  64554. static readonly TEXTUREFORMAT_ALPHA: number;
  64555. /** LUMINANCE */
  64556. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64557. /** LUMINANCE_ALPHA */
  64558. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64559. /** RGB */
  64560. static readonly TEXTUREFORMAT_RGB: number;
  64561. /** RGBA */
  64562. static readonly TEXTUREFORMAT_RGBA: number;
  64563. /** RED */
  64564. static readonly TEXTUREFORMAT_RED: number;
  64565. /** RED (2nd reference) */
  64566. static readonly TEXTUREFORMAT_R: number;
  64567. /** RG */
  64568. static readonly TEXTUREFORMAT_RG: number;
  64569. /** RED_INTEGER */
  64570. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64571. /** RED_INTEGER (2nd reference) */
  64572. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64573. /** RG_INTEGER */
  64574. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64575. /** RGB_INTEGER */
  64576. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64577. /** RGBA_INTEGER */
  64578. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64579. /** UNSIGNED_BYTE */
  64580. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64581. /** UNSIGNED_BYTE (2nd reference) */
  64582. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64583. /** FLOAT */
  64584. static readonly TEXTURETYPE_FLOAT: number;
  64585. /** HALF_FLOAT */
  64586. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64587. /** BYTE */
  64588. static readonly TEXTURETYPE_BYTE: number;
  64589. /** SHORT */
  64590. static readonly TEXTURETYPE_SHORT: number;
  64591. /** UNSIGNED_SHORT */
  64592. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64593. /** INT */
  64594. static readonly TEXTURETYPE_INT: number;
  64595. /** UNSIGNED_INT */
  64596. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64597. /** UNSIGNED_SHORT_4_4_4_4 */
  64598. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64599. /** UNSIGNED_SHORT_5_5_5_1 */
  64600. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64601. /** UNSIGNED_SHORT_5_6_5 */
  64602. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64603. /** UNSIGNED_INT_2_10_10_10_REV */
  64604. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64605. /** UNSIGNED_INT_24_8 */
  64606. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64607. /** UNSIGNED_INT_10F_11F_11F_REV */
  64608. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64609. /** UNSIGNED_INT_5_9_9_9_REV */
  64610. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64611. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64612. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64613. /** nearest is mag = nearest and min = nearest and mip = linear */
  64614. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64615. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64616. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64617. /** Trilinear is mag = linear and min = linear and mip = linear */
  64618. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64619. /** nearest is mag = nearest and min = nearest and mip = linear */
  64620. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64621. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64622. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64623. /** Trilinear is mag = linear and min = linear and mip = linear */
  64624. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64625. /** mag = nearest and min = nearest and mip = nearest */
  64626. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64627. /** mag = nearest and min = linear and mip = nearest */
  64628. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64629. /** mag = nearest and min = linear and mip = linear */
  64630. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64631. /** mag = nearest and min = linear and mip = none */
  64632. static readonly TEXTURE_NEAREST_LINEAR: number;
  64633. /** mag = nearest and min = nearest and mip = none */
  64634. static readonly TEXTURE_NEAREST_NEAREST: number;
  64635. /** mag = linear and min = nearest and mip = nearest */
  64636. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64637. /** mag = linear and min = nearest and mip = linear */
  64638. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64639. /** mag = linear and min = linear and mip = none */
  64640. static readonly TEXTURE_LINEAR_LINEAR: number;
  64641. /** mag = linear and min = nearest and mip = none */
  64642. static readonly TEXTURE_LINEAR_NEAREST: number;
  64643. /** Explicit coordinates mode */
  64644. static readonly TEXTURE_EXPLICIT_MODE: number;
  64645. /** Spherical coordinates mode */
  64646. static readonly TEXTURE_SPHERICAL_MODE: number;
  64647. /** Planar coordinates mode */
  64648. static readonly TEXTURE_PLANAR_MODE: number;
  64649. /** Cubic coordinates mode */
  64650. static readonly TEXTURE_CUBIC_MODE: number;
  64651. /** Projection coordinates mode */
  64652. static readonly TEXTURE_PROJECTION_MODE: number;
  64653. /** Skybox coordinates mode */
  64654. static readonly TEXTURE_SKYBOX_MODE: number;
  64655. /** Inverse Cubic coordinates mode */
  64656. static readonly TEXTURE_INVCUBIC_MODE: number;
  64657. /** Equirectangular coordinates mode */
  64658. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64659. /** Equirectangular Fixed coordinates mode */
  64660. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64661. /** Equirectangular Fixed Mirrored coordinates mode */
  64662. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64663. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64664. static readonly SCALEMODE_FLOOR: number;
  64665. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64666. static readonly SCALEMODE_NEAREST: number;
  64667. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64668. static readonly SCALEMODE_CEILING: number;
  64669. /**
  64670. * The dirty texture flag value
  64671. */
  64672. static readonly MATERIAL_TextureDirtyFlag: number;
  64673. /**
  64674. * The dirty light flag value
  64675. */
  64676. static readonly MATERIAL_LightDirtyFlag: number;
  64677. /**
  64678. * The dirty fresnel flag value
  64679. */
  64680. static readonly MATERIAL_FresnelDirtyFlag: number;
  64681. /**
  64682. * The dirty attribute flag value
  64683. */
  64684. static readonly MATERIAL_AttributesDirtyFlag: number;
  64685. /**
  64686. * The dirty misc flag value
  64687. */
  64688. static readonly MATERIAL_MiscDirtyFlag: number;
  64689. /**
  64690. * The all dirty flag value
  64691. */
  64692. static readonly MATERIAL_AllDirtyFlag: number;
  64693. /**
  64694. * Returns the triangle fill mode
  64695. */
  64696. static readonly MATERIAL_TriangleFillMode: number;
  64697. /**
  64698. * Returns the wireframe mode
  64699. */
  64700. static readonly MATERIAL_WireFrameFillMode: number;
  64701. /**
  64702. * Returns the point fill mode
  64703. */
  64704. static readonly MATERIAL_PointFillMode: number;
  64705. /**
  64706. * Returns the point list draw mode
  64707. */
  64708. static readonly MATERIAL_PointListDrawMode: number;
  64709. /**
  64710. * Returns the line list draw mode
  64711. */
  64712. static readonly MATERIAL_LineListDrawMode: number;
  64713. /**
  64714. * Returns the line loop draw mode
  64715. */
  64716. static readonly MATERIAL_LineLoopDrawMode: number;
  64717. /**
  64718. * Returns the line strip draw mode
  64719. */
  64720. static readonly MATERIAL_LineStripDrawMode: number;
  64721. /**
  64722. * Returns the triangle strip draw mode
  64723. */
  64724. static readonly MATERIAL_TriangleStripDrawMode: number;
  64725. /**
  64726. * Returns the triangle fan draw mode
  64727. */
  64728. static readonly MATERIAL_TriangleFanDrawMode: number;
  64729. /**
  64730. * Stores the clock-wise side orientation
  64731. */
  64732. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64733. /**
  64734. * Stores the counter clock-wise side orientation
  64735. */
  64736. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64737. /**
  64738. * Nothing
  64739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64740. */
  64741. static readonly ACTION_NothingTrigger: number;
  64742. /**
  64743. * On pick
  64744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64745. */
  64746. static readonly ACTION_OnPickTrigger: number;
  64747. /**
  64748. * On left pick
  64749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64750. */
  64751. static readonly ACTION_OnLeftPickTrigger: number;
  64752. /**
  64753. * On right pick
  64754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64755. */
  64756. static readonly ACTION_OnRightPickTrigger: number;
  64757. /**
  64758. * On center pick
  64759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64760. */
  64761. static readonly ACTION_OnCenterPickTrigger: number;
  64762. /**
  64763. * On pick down
  64764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64765. */
  64766. static readonly ACTION_OnPickDownTrigger: number;
  64767. /**
  64768. * On double pick
  64769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64770. */
  64771. static readonly ACTION_OnDoublePickTrigger: number;
  64772. /**
  64773. * On pick up
  64774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64775. */
  64776. static readonly ACTION_OnPickUpTrigger: number;
  64777. /**
  64778. * On pick out.
  64779. * This trigger will only be raised if you also declared a OnPickDown
  64780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64781. */
  64782. static readonly ACTION_OnPickOutTrigger: number;
  64783. /**
  64784. * On long press
  64785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64786. */
  64787. static readonly ACTION_OnLongPressTrigger: number;
  64788. /**
  64789. * On pointer over
  64790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64791. */
  64792. static readonly ACTION_OnPointerOverTrigger: number;
  64793. /**
  64794. * On pointer out
  64795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64796. */
  64797. static readonly ACTION_OnPointerOutTrigger: number;
  64798. /**
  64799. * On every frame
  64800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64801. */
  64802. static readonly ACTION_OnEveryFrameTrigger: number;
  64803. /**
  64804. * On intersection enter
  64805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64806. */
  64807. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64808. /**
  64809. * On intersection exit
  64810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64811. */
  64812. static readonly ACTION_OnIntersectionExitTrigger: number;
  64813. /**
  64814. * On key down
  64815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64816. */
  64817. static readonly ACTION_OnKeyDownTrigger: number;
  64818. /**
  64819. * On key up
  64820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64821. */
  64822. static readonly ACTION_OnKeyUpTrigger: number;
  64823. /**
  64824. * Billboard mode will only apply to Y axis
  64825. */
  64826. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64827. /**
  64828. * Billboard mode will apply to all axes
  64829. */
  64830. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64831. /**
  64832. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64833. */
  64834. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64835. /**
  64836. * Gets or sets base Assets URL
  64837. */
  64838. static readonly PARTICLES_BaseAssetsUrl: string;
  64839. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64840. * Test order :
  64841. * Is the bounding sphere outside the frustum ?
  64842. * If not, are the bounding box vertices outside the frustum ?
  64843. * It not, then the cullable object is in the frustum.
  64844. */
  64845. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64846. /** Culling strategy : Bounding Sphere Only.
  64847. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64848. * It's also less accurate than the standard because some not visible objects can still be selected.
  64849. * Test : is the bounding sphere outside the frustum ?
  64850. * If not, then the cullable object is in the frustum.
  64851. */
  64852. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64853. /** Culling strategy : Optimistic Inclusion.
  64854. * This in an inclusion test first, then the standard exclusion test.
  64855. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64856. * 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.
  64857. * Anyway, it's as accurate as the standard strategy.
  64858. * Test :
  64859. * Is the cullable object bounding sphere center in the frustum ?
  64860. * If not, apply the default culling strategy.
  64861. */
  64862. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64863. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64864. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64865. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64866. * 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.
  64867. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64868. * Test :
  64869. * Is the cullable object bounding sphere center in the frustum ?
  64870. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64871. */
  64872. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64873. /**
  64874. * No logging while loading
  64875. */
  64876. static readonly SCENELOADER_NO_LOGGING: number;
  64877. /**
  64878. * Minimal logging while loading
  64879. */
  64880. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64881. /**
  64882. * Summary logging while loading
  64883. */
  64884. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64885. /**
  64886. * Detailled logging while loading
  64887. */
  64888. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64889. }
  64890. }
  64891. declare module BABYLON {
  64892. /**
  64893. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64894. * Babylon.js
  64895. */
  64896. export class DomManagement {
  64897. /**
  64898. * Checks if the window object exists
  64899. * @returns true if the window object exists
  64900. */
  64901. static IsWindowObjectExist(): boolean;
  64902. /**
  64903. * Extracts text content from a DOM element hierarchy
  64904. * @param element defines the root element
  64905. * @returns a string
  64906. */
  64907. static GetDOMTextContent(element: HTMLElement): string;
  64908. }
  64909. }
  64910. declare module BABYLON {
  64911. /**
  64912. * Logger used througouht the application to allow configuration of
  64913. * the log level required for the messages.
  64914. */
  64915. export class Logger {
  64916. /**
  64917. * No log
  64918. */
  64919. static readonly NoneLogLevel: number;
  64920. /**
  64921. * Only message logs
  64922. */
  64923. static readonly MessageLogLevel: number;
  64924. /**
  64925. * Only warning logs
  64926. */
  64927. static readonly WarningLogLevel: number;
  64928. /**
  64929. * Only error logs
  64930. */
  64931. static readonly ErrorLogLevel: number;
  64932. /**
  64933. * All logs
  64934. */
  64935. static readonly AllLogLevel: number;
  64936. private static _LogCache;
  64937. /**
  64938. * Gets a value indicating the number of loading errors
  64939. * @ignorenaming
  64940. */
  64941. static errorsCount: number;
  64942. /**
  64943. * Callback called when a new log is added
  64944. */
  64945. static OnNewCacheEntry: (entry: string) => void;
  64946. private static _AddLogEntry;
  64947. private static _FormatMessage;
  64948. private static _LogDisabled;
  64949. private static _LogEnabled;
  64950. private static _WarnDisabled;
  64951. private static _WarnEnabled;
  64952. private static _ErrorDisabled;
  64953. private static _ErrorEnabled;
  64954. /**
  64955. * Log a message to the console
  64956. */
  64957. static Log: (message: string) => void;
  64958. /**
  64959. * Write a warning message to the console
  64960. */
  64961. static Warn: (message: string) => void;
  64962. /**
  64963. * Write an error message to the console
  64964. */
  64965. static Error: (message: string) => void;
  64966. /**
  64967. * Gets current log cache (list of logs)
  64968. */
  64969. static readonly LogCache: string;
  64970. /**
  64971. * Clears the log cache
  64972. */
  64973. static ClearLogCache(): void;
  64974. /**
  64975. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64976. */
  64977. static LogLevels: number;
  64978. }
  64979. }
  64980. declare module BABYLON {
  64981. /** @hidden */
  64982. export class _TypeStore {
  64983. /** @hidden */
  64984. static RegisteredTypes: {
  64985. [key: string]: Object;
  64986. };
  64987. /** @hidden */
  64988. static GetClass(fqdn: string): any;
  64989. }
  64990. }
  64991. declare module BABYLON {
  64992. /**
  64993. * Class containing a set of static utilities functions for deep copy.
  64994. */
  64995. export class DeepCopier {
  64996. /**
  64997. * Tries to copy an object by duplicating every property
  64998. * @param source defines the source object
  64999. * @param destination defines the target object
  65000. * @param doNotCopyList defines a list of properties to avoid
  65001. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65002. */
  65003. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65004. }
  65005. }
  65006. declare module BABYLON {
  65007. /**
  65008. * Class containing a set of static utilities functions for precision date
  65009. */
  65010. export class PrecisionDate {
  65011. /**
  65012. * Gets either window.performance.now() if supported or Date.now() else
  65013. */
  65014. static readonly Now: number;
  65015. }
  65016. }
  65017. declare module BABYLON {
  65018. /** @hidden */
  65019. export class _DevTools {
  65020. static WarnImport(name: string): string;
  65021. }
  65022. }
  65023. declare module BABYLON {
  65024. /**
  65025. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  65026. */
  65027. export class WebRequest {
  65028. private _xhr;
  65029. /**
  65030. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  65031. * i.e. when loading files, where the server/service expects an Authorization header
  65032. */
  65033. static CustomRequestHeaders: {
  65034. [key: string]: string;
  65035. };
  65036. /**
  65037. * Add callback functions in this array to update all the requests before they get sent to the network
  65038. */
  65039. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  65040. private _injectCustomRequestHeaders;
  65041. /**
  65042. * Gets or sets a function to be called when loading progress changes
  65043. */
  65044. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  65045. /**
  65046. * Returns client's state
  65047. */
  65048. readonly readyState: number;
  65049. /**
  65050. * Returns client's status
  65051. */
  65052. readonly status: number;
  65053. /**
  65054. * Returns client's status as a text
  65055. */
  65056. readonly statusText: string;
  65057. /**
  65058. * Returns client's response
  65059. */
  65060. readonly response: any;
  65061. /**
  65062. * Returns client's response url
  65063. */
  65064. readonly responseURL: string;
  65065. /**
  65066. * Returns client's response as text
  65067. */
  65068. readonly responseText: string;
  65069. /**
  65070. * Gets or sets the expected response type
  65071. */
  65072. responseType: XMLHttpRequestResponseType;
  65073. /** @hidden */
  65074. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65075. /** @hidden */
  65076. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65077. /**
  65078. * Cancels any network activity
  65079. */
  65080. abort(): void;
  65081. /**
  65082. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65083. * @param body defines an optional request body
  65084. */
  65085. send(body?: Document | BodyInit | null): void;
  65086. /**
  65087. * Sets the request method, request URL
  65088. * @param method defines the method to use (GET, POST, etc..)
  65089. * @param url defines the url to connect with
  65090. */
  65091. open(method: string, url: string): void;
  65092. }
  65093. }
  65094. declare module BABYLON {
  65095. /**
  65096. * Class used to evalaute queries containing `and` and `or` operators
  65097. */
  65098. export class AndOrNotEvaluator {
  65099. /**
  65100. * Evaluate a query
  65101. * @param query defines the query to evaluate
  65102. * @param evaluateCallback defines the callback used to filter result
  65103. * @returns true if the query matches
  65104. */
  65105. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  65106. private static _HandleParenthesisContent;
  65107. private static _SimplifyNegation;
  65108. }
  65109. }
  65110. declare module BABYLON {
  65111. /**
  65112. * Class used to store custom tags
  65113. */
  65114. export class Tags {
  65115. /**
  65116. * Adds support for tags on the given object
  65117. * @param obj defines the object to use
  65118. */
  65119. static EnableFor(obj: any): void;
  65120. /**
  65121. * Removes tags support
  65122. * @param obj defines the object to use
  65123. */
  65124. static DisableFor(obj: any): void;
  65125. /**
  65126. * Gets a boolean indicating if the given object has tags
  65127. * @param obj defines the object to use
  65128. * @returns a boolean
  65129. */
  65130. static HasTags(obj: any): boolean;
  65131. /**
  65132. * Gets the tags available on a given object
  65133. * @param obj defines the object to use
  65134. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65135. * @returns the tags
  65136. */
  65137. static GetTags(obj: any, asString?: boolean): any;
  65138. /**
  65139. * Adds tags to an object
  65140. * @param obj defines the object to use
  65141. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65142. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65143. */
  65144. static AddTagsTo(obj: any, tagsString: string): void;
  65145. /**
  65146. * @hidden
  65147. */
  65148. static _AddTagTo(obj: any, tag: string): void;
  65149. /**
  65150. * Removes specific tags from a specific object
  65151. * @param obj defines the object to use
  65152. * @param tagsString defines the tags to remove
  65153. */
  65154. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65155. /**
  65156. * @hidden
  65157. */
  65158. static _RemoveTagFrom(obj: any, tag: string): void;
  65159. /**
  65160. * Defines if tags hosted on an object match a given query
  65161. * @param obj defines the object to use
  65162. * @param tagsQuery defines the tag query
  65163. * @returns a boolean
  65164. */
  65165. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65166. }
  65167. }
  65168. declare module BABYLON {
  65169. /**
  65170. * Manages the defines for the Material
  65171. */
  65172. export class MaterialDefines {
  65173. private _keys;
  65174. private _isDirty;
  65175. /** @hidden */
  65176. _renderId: number;
  65177. /** @hidden */
  65178. _areLightsDirty: boolean;
  65179. /** @hidden */
  65180. _areAttributesDirty: boolean;
  65181. /** @hidden */
  65182. _areTexturesDirty: boolean;
  65183. /** @hidden */
  65184. _areFresnelDirty: boolean;
  65185. /** @hidden */
  65186. _areMiscDirty: boolean;
  65187. /** @hidden */
  65188. _areImageProcessingDirty: boolean;
  65189. /** @hidden */
  65190. _normals: boolean;
  65191. /** @hidden */
  65192. _uvs: boolean;
  65193. /** @hidden */
  65194. _needNormals: boolean;
  65195. /** @hidden */
  65196. _needUVs: boolean;
  65197. /**
  65198. * Specifies if the material needs to be re-calculated
  65199. */
  65200. readonly isDirty: boolean;
  65201. /**
  65202. * Marks the material to indicate that it has been re-calculated
  65203. */
  65204. markAsProcessed(): void;
  65205. /**
  65206. * Marks the material to indicate that it needs to be re-calculated
  65207. */
  65208. markAsUnprocessed(): void;
  65209. /**
  65210. * Marks the material to indicate all of its defines need to be re-calculated
  65211. */
  65212. markAllAsDirty(): void;
  65213. /**
  65214. * Marks the material to indicate that image processing needs to be re-calculated
  65215. */
  65216. markAsImageProcessingDirty(): void;
  65217. /**
  65218. * Marks the material to indicate the lights need to be re-calculated
  65219. */
  65220. markAsLightDirty(): void;
  65221. /**
  65222. * Marks the attribute state as changed
  65223. */
  65224. markAsAttributesDirty(): void;
  65225. /**
  65226. * Marks the texture state as changed
  65227. */
  65228. markAsTexturesDirty(): void;
  65229. /**
  65230. * Marks the fresnel state as changed
  65231. */
  65232. markAsFresnelDirty(): void;
  65233. /**
  65234. * Marks the misc state as changed
  65235. */
  65236. markAsMiscDirty(): void;
  65237. /**
  65238. * Rebuilds the material defines
  65239. */
  65240. rebuild(): void;
  65241. /**
  65242. * Specifies if two material defines are equal
  65243. * @param other - A material define instance to compare to
  65244. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65245. */
  65246. isEqual(other: MaterialDefines): boolean;
  65247. /**
  65248. * Clones this instance's defines to another instance
  65249. * @param other - material defines to clone values to
  65250. */
  65251. cloneTo(other: MaterialDefines): void;
  65252. /**
  65253. * Resets the material define values
  65254. */
  65255. reset(): void;
  65256. /**
  65257. * Converts the material define values to a string
  65258. * @returns - String of material define information
  65259. */
  65260. toString(): string;
  65261. }
  65262. }
  65263. declare module BABYLON {
  65264. /**
  65265. * Class used to store and describe the pipeline context associated with an effect
  65266. */
  65267. export interface IPipelineContext {
  65268. /**
  65269. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65270. */
  65271. isAsync: boolean;
  65272. /**
  65273. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65274. */
  65275. isReady: boolean;
  65276. /** @hidden */
  65277. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65278. }
  65279. }
  65280. declare module BABYLON {
  65281. /**
  65282. * Class used to store gfx data (like WebGLBuffer)
  65283. */
  65284. export class DataBuffer {
  65285. /**
  65286. * Gets or sets the number of objects referencing this buffer
  65287. */
  65288. references: number;
  65289. /** Gets or sets the size of the underlying buffer */
  65290. capacity: number;
  65291. /**
  65292. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65293. */
  65294. is32Bits: boolean;
  65295. /**
  65296. * Gets the underlying buffer
  65297. */
  65298. readonly underlyingResource: any;
  65299. }
  65300. }
  65301. declare module BABYLON {
  65302. /**
  65303. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65304. */
  65305. export class PerformanceMonitor {
  65306. private _enabled;
  65307. private _rollingFrameTime;
  65308. private _lastFrameTimeMs;
  65309. /**
  65310. * constructor
  65311. * @param frameSampleSize The number of samples required to saturate the sliding window
  65312. */
  65313. constructor(frameSampleSize?: number);
  65314. /**
  65315. * Samples current frame
  65316. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65317. */
  65318. sampleFrame(timeMs?: number): void;
  65319. /**
  65320. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65321. */
  65322. readonly averageFrameTime: number;
  65323. /**
  65324. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65325. */
  65326. readonly averageFrameTimeVariance: number;
  65327. /**
  65328. * Returns the frame time of the most recent frame
  65329. */
  65330. readonly instantaneousFrameTime: number;
  65331. /**
  65332. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65333. */
  65334. readonly averageFPS: number;
  65335. /**
  65336. * Returns the average framerate in frames per second using the most recent frame time
  65337. */
  65338. readonly instantaneousFPS: number;
  65339. /**
  65340. * Returns true if enough samples have been taken to completely fill the sliding window
  65341. */
  65342. readonly isSaturated: boolean;
  65343. /**
  65344. * Enables contributions to the sliding window sample set
  65345. */
  65346. enable(): void;
  65347. /**
  65348. * Disables contributions to the sliding window sample set
  65349. * Samples will not be interpolated over the disabled period
  65350. */
  65351. disable(): void;
  65352. /**
  65353. * Returns true if sampling is enabled
  65354. */
  65355. readonly isEnabled: boolean;
  65356. /**
  65357. * Resets performance monitor
  65358. */
  65359. reset(): void;
  65360. }
  65361. /**
  65362. * RollingAverage
  65363. *
  65364. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65365. */
  65366. export class RollingAverage {
  65367. /**
  65368. * Current average
  65369. */
  65370. average: number;
  65371. /**
  65372. * Current variance
  65373. */
  65374. variance: number;
  65375. protected _samples: Array<number>;
  65376. protected _sampleCount: number;
  65377. protected _pos: number;
  65378. protected _m2: number;
  65379. /**
  65380. * constructor
  65381. * @param length The number of samples required to saturate the sliding window
  65382. */
  65383. constructor(length: number);
  65384. /**
  65385. * Adds a sample to the sample set
  65386. * @param v The sample value
  65387. */
  65388. add(v: number): void;
  65389. /**
  65390. * Returns previously added values or null if outside of history or outside the sliding window domain
  65391. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65392. * @return Value previously recorded with add() or null if outside of range
  65393. */
  65394. history(i: number): number;
  65395. /**
  65396. * Returns true if enough samples have been taken to completely fill the sliding window
  65397. * @return true if sample-set saturated
  65398. */
  65399. isSaturated(): boolean;
  65400. /**
  65401. * Resets the rolling average (equivalent to 0 samples taken so far)
  65402. */
  65403. reset(): void;
  65404. /**
  65405. * Wraps a value around the sample range boundaries
  65406. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65407. * @return Wrapped position in sample range
  65408. */
  65409. protected _wrapPosition(i: number): number;
  65410. }
  65411. }
  65412. declare module BABYLON {
  65413. /**
  65414. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65415. * The underlying implementation relies on an associative array to ensure the best performances.
  65416. * The value can be anything including 'null' but except 'undefined'
  65417. */
  65418. export class StringDictionary<T> {
  65419. /**
  65420. * This will clear this dictionary and copy the content from the 'source' one.
  65421. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65422. * @param source the dictionary to take the content from and copy to this dictionary
  65423. */
  65424. copyFrom(source: StringDictionary<T>): void;
  65425. /**
  65426. * Get a value based from its key
  65427. * @param key the given key to get the matching value from
  65428. * @return the value if found, otherwise undefined is returned
  65429. */
  65430. get(key: string): T | undefined;
  65431. /**
  65432. * Get a value from its key or add it if it doesn't exist.
  65433. * This method will ensure you that a given key/data will be present in the dictionary.
  65434. * @param key the given key to get the matching value from
  65435. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65436. * The factory will only be invoked if there's no data for the given key.
  65437. * @return the value corresponding to the key.
  65438. */
  65439. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65440. /**
  65441. * Get a value from its key if present in the dictionary otherwise add it
  65442. * @param key the key to get the value from
  65443. * @param val if there's no such key/value pair in the dictionary add it with this value
  65444. * @return the value corresponding to the key
  65445. */
  65446. getOrAdd(key: string, val: T): T;
  65447. /**
  65448. * Check if there's a given key in the dictionary
  65449. * @param key the key to check for
  65450. * @return true if the key is present, false otherwise
  65451. */
  65452. contains(key: string): boolean;
  65453. /**
  65454. * Add a new key and its corresponding value
  65455. * @param key the key to add
  65456. * @param value the value corresponding to the key
  65457. * @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
  65458. */
  65459. add(key: string, value: T): boolean;
  65460. /**
  65461. * Update a specific value associated to a key
  65462. * @param key defines the key to use
  65463. * @param value defines the value to store
  65464. * @returns true if the value was updated (or false if the key was not found)
  65465. */
  65466. set(key: string, value: T): boolean;
  65467. /**
  65468. * Get the element of the given key and remove it from the dictionary
  65469. * @param key defines the key to search
  65470. * @returns the value associated with the key or null if not found
  65471. */
  65472. getAndRemove(key: string): Nullable<T>;
  65473. /**
  65474. * Remove a key/value from the dictionary.
  65475. * @param key the key to remove
  65476. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65477. */
  65478. remove(key: string): boolean;
  65479. /**
  65480. * Clear the whole content of the dictionary
  65481. */
  65482. clear(): void;
  65483. /**
  65484. * Gets the current count
  65485. */
  65486. readonly count: number;
  65487. /**
  65488. * Execute a callback on each key/val of the dictionary.
  65489. * Note that you can remove any element in this dictionary in the callback implementation
  65490. * @param callback the callback to execute on a given key/value pair
  65491. */
  65492. forEach(callback: (key: string, val: T) => void): void;
  65493. /**
  65494. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65495. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65496. * Note that you can remove any element in this dictionary in the callback implementation
  65497. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65498. * @returns the first item
  65499. */
  65500. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65501. private _count;
  65502. private _data;
  65503. }
  65504. }
  65505. declare module BABYLON {
  65506. /**
  65507. * Helper class that provides a small promise polyfill
  65508. */
  65509. export class PromisePolyfill {
  65510. /**
  65511. * Static function used to check if the polyfill is required
  65512. * If this is the case then the function will inject the polyfill to window.Promise
  65513. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65514. */
  65515. static Apply(force?: boolean): void;
  65516. }
  65517. }
  65518. declare module BABYLON {
  65519. /**
  65520. * Class used to store data that will be store in GPU memory
  65521. */
  65522. export class Buffer {
  65523. private _engine;
  65524. private _buffer;
  65525. /** @hidden */
  65526. _data: Nullable<DataArray>;
  65527. private _updatable;
  65528. private _instanced;
  65529. /**
  65530. * Gets the byte stride.
  65531. */
  65532. readonly byteStride: number;
  65533. /**
  65534. * Constructor
  65535. * @param engine the engine
  65536. * @param data the data to use for this buffer
  65537. * @param updatable whether the data is updatable
  65538. * @param stride the stride (optional)
  65539. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65540. * @param instanced whether the buffer is instanced (optional)
  65541. * @param useBytes set to true if the stride in in bytes (optional)
  65542. */
  65543. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65544. /**
  65545. * Create a new VertexBuffer based on the current buffer
  65546. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65547. * @param offset defines offset in the buffer (0 by default)
  65548. * @param size defines the size in floats of attributes (position is 3 for instance)
  65549. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65550. * @param instanced defines if the vertex buffer contains indexed data
  65551. * @param useBytes defines if the offset and stride are in bytes
  65552. * @returns the new vertex buffer
  65553. */
  65554. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65555. /**
  65556. * Gets a boolean indicating if the Buffer is updatable?
  65557. * @returns true if the buffer is updatable
  65558. */
  65559. isUpdatable(): boolean;
  65560. /**
  65561. * Gets current buffer's data
  65562. * @returns a DataArray or null
  65563. */
  65564. getData(): Nullable<DataArray>;
  65565. /**
  65566. * Gets underlying native buffer
  65567. * @returns underlying native buffer
  65568. */
  65569. getBuffer(): Nullable<DataBuffer>;
  65570. /**
  65571. * Gets the stride in float32 units (i.e. byte stride / 4).
  65572. * May not be an integer if the byte stride is not divisible by 4.
  65573. * DEPRECATED. Use byteStride instead.
  65574. * @returns the stride in float32 units
  65575. */
  65576. getStrideSize(): number;
  65577. /**
  65578. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65579. * @param data defines the data to store
  65580. */
  65581. create(data?: Nullable<DataArray>): void;
  65582. /** @hidden */
  65583. _rebuild(): void;
  65584. /**
  65585. * Update current buffer data
  65586. * @param data defines the data to store
  65587. */
  65588. update(data: DataArray): void;
  65589. /**
  65590. * Updates the data directly.
  65591. * @param data the new data
  65592. * @param offset the new offset
  65593. * @param vertexCount the vertex count (optional)
  65594. * @param useBytes set to true if the offset is in bytes
  65595. */
  65596. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65597. /**
  65598. * Release all resources
  65599. */
  65600. dispose(): void;
  65601. }
  65602. /**
  65603. * Specialized buffer used to store vertex data
  65604. */
  65605. export class VertexBuffer {
  65606. /** @hidden */
  65607. _buffer: Buffer;
  65608. private _kind;
  65609. private _size;
  65610. private _ownsBuffer;
  65611. private _instanced;
  65612. private _instanceDivisor;
  65613. /**
  65614. * The byte type.
  65615. */
  65616. static readonly BYTE: number;
  65617. /**
  65618. * The unsigned byte type.
  65619. */
  65620. static readonly UNSIGNED_BYTE: number;
  65621. /**
  65622. * The short type.
  65623. */
  65624. static readonly SHORT: number;
  65625. /**
  65626. * The unsigned short type.
  65627. */
  65628. static readonly UNSIGNED_SHORT: number;
  65629. /**
  65630. * The integer type.
  65631. */
  65632. static readonly INT: number;
  65633. /**
  65634. * The unsigned integer type.
  65635. */
  65636. static readonly UNSIGNED_INT: number;
  65637. /**
  65638. * The float type.
  65639. */
  65640. static readonly FLOAT: number;
  65641. /**
  65642. * Gets or sets the instance divisor when in instanced mode
  65643. */
  65644. instanceDivisor: number;
  65645. /**
  65646. * Gets the byte stride.
  65647. */
  65648. readonly byteStride: number;
  65649. /**
  65650. * Gets the byte offset.
  65651. */
  65652. readonly byteOffset: number;
  65653. /**
  65654. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65655. */
  65656. readonly normalized: boolean;
  65657. /**
  65658. * Gets the data type of each component in the array.
  65659. */
  65660. readonly type: number;
  65661. /**
  65662. * Constructor
  65663. * @param engine the engine
  65664. * @param data the data to use for this vertex buffer
  65665. * @param kind the vertex buffer kind
  65666. * @param updatable whether the data is updatable
  65667. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65668. * @param stride the stride (optional)
  65669. * @param instanced whether the buffer is instanced (optional)
  65670. * @param offset the offset of the data (optional)
  65671. * @param size the number of components (optional)
  65672. * @param type the type of the component (optional)
  65673. * @param normalized whether the data contains normalized data (optional)
  65674. * @param useBytes set to true if stride and offset are in bytes (optional)
  65675. */
  65676. 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);
  65677. /** @hidden */
  65678. _rebuild(): void;
  65679. /**
  65680. * Returns the kind of the VertexBuffer (string)
  65681. * @returns a string
  65682. */
  65683. getKind(): string;
  65684. /**
  65685. * Gets a boolean indicating if the VertexBuffer is updatable?
  65686. * @returns true if the buffer is updatable
  65687. */
  65688. isUpdatable(): boolean;
  65689. /**
  65690. * Gets current buffer's data
  65691. * @returns a DataArray or null
  65692. */
  65693. getData(): Nullable<DataArray>;
  65694. /**
  65695. * Gets underlying native buffer
  65696. * @returns underlying native buffer
  65697. */
  65698. getBuffer(): Nullable<DataBuffer>;
  65699. /**
  65700. * Gets the stride in float32 units (i.e. byte stride / 4).
  65701. * May not be an integer if the byte stride is not divisible by 4.
  65702. * DEPRECATED. Use byteStride instead.
  65703. * @returns the stride in float32 units
  65704. */
  65705. getStrideSize(): number;
  65706. /**
  65707. * Returns the offset as a multiple of the type byte length.
  65708. * DEPRECATED. Use byteOffset instead.
  65709. * @returns the offset in bytes
  65710. */
  65711. getOffset(): number;
  65712. /**
  65713. * Returns the number of components per vertex attribute (integer)
  65714. * @returns the size in float
  65715. */
  65716. getSize(): number;
  65717. /**
  65718. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65719. * @returns true if this buffer is instanced
  65720. */
  65721. getIsInstanced(): boolean;
  65722. /**
  65723. * Returns the instancing divisor, zero for non-instanced (integer).
  65724. * @returns a number
  65725. */
  65726. getInstanceDivisor(): number;
  65727. /**
  65728. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65729. * @param data defines the data to store
  65730. */
  65731. create(data?: DataArray): void;
  65732. /**
  65733. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65734. * This function will create a new buffer if the current one is not updatable
  65735. * @param data defines the data to store
  65736. */
  65737. update(data: DataArray): void;
  65738. /**
  65739. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65740. * Returns the directly updated WebGLBuffer.
  65741. * @param data the new data
  65742. * @param offset the new offset
  65743. * @param useBytes set to true if the offset is in bytes
  65744. */
  65745. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65746. /**
  65747. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65748. */
  65749. dispose(): void;
  65750. /**
  65751. * Enumerates each value of this vertex buffer as numbers.
  65752. * @param count the number of values to enumerate
  65753. * @param callback the callback function called for each value
  65754. */
  65755. forEach(count: number, callback: (value: number, index: number) => void): void;
  65756. /**
  65757. * Positions
  65758. */
  65759. static readonly PositionKind: string;
  65760. /**
  65761. * Normals
  65762. */
  65763. static readonly NormalKind: string;
  65764. /**
  65765. * Tangents
  65766. */
  65767. static readonly TangentKind: string;
  65768. /**
  65769. * Texture coordinates
  65770. */
  65771. static readonly UVKind: string;
  65772. /**
  65773. * Texture coordinates 2
  65774. */
  65775. static readonly UV2Kind: string;
  65776. /**
  65777. * Texture coordinates 3
  65778. */
  65779. static readonly UV3Kind: string;
  65780. /**
  65781. * Texture coordinates 4
  65782. */
  65783. static readonly UV4Kind: string;
  65784. /**
  65785. * Texture coordinates 5
  65786. */
  65787. static readonly UV5Kind: string;
  65788. /**
  65789. * Texture coordinates 6
  65790. */
  65791. static readonly UV6Kind: string;
  65792. /**
  65793. * Colors
  65794. */
  65795. static readonly ColorKind: string;
  65796. /**
  65797. * Matrix indices (for bones)
  65798. */
  65799. static readonly MatricesIndicesKind: string;
  65800. /**
  65801. * Matrix weights (for bones)
  65802. */
  65803. static readonly MatricesWeightsKind: string;
  65804. /**
  65805. * Additional matrix indices (for bones)
  65806. */
  65807. static readonly MatricesIndicesExtraKind: string;
  65808. /**
  65809. * Additional matrix weights (for bones)
  65810. */
  65811. static readonly MatricesWeightsExtraKind: string;
  65812. /**
  65813. * Deduces the stride given a kind.
  65814. * @param kind The kind string to deduce
  65815. * @returns The deduced stride
  65816. */
  65817. static DeduceStride(kind: string): number;
  65818. /**
  65819. * Gets the byte length of the given type.
  65820. * @param type the type
  65821. * @returns the number of bytes
  65822. */
  65823. static GetTypeByteLength(type: number): number;
  65824. /**
  65825. * Enumerates each value of the given parameters as numbers.
  65826. * @param data the data to enumerate
  65827. * @param byteOffset the byte offset of the data
  65828. * @param byteStride the byte stride of the data
  65829. * @param componentCount the number of components per element
  65830. * @param componentType the type of the component
  65831. * @param count the total number of components
  65832. * @param normalized whether the data is normalized
  65833. * @param callback the callback function called for each value
  65834. */
  65835. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65836. private static _GetFloatValue;
  65837. }
  65838. }
  65839. declare module BABYLON {
  65840. /**
  65841. * Class representing spherical harmonics coefficients to the 3rd degree
  65842. */
  65843. export class SphericalHarmonics {
  65844. /**
  65845. * Defines whether or not the harmonics have been prescaled for rendering.
  65846. */
  65847. preScaled: boolean;
  65848. /**
  65849. * The l0,0 coefficients of the spherical harmonics
  65850. */
  65851. l00: Vector3;
  65852. /**
  65853. * The l1,-1 coefficients of the spherical harmonics
  65854. */
  65855. l1_1: Vector3;
  65856. /**
  65857. * The l1,0 coefficients of the spherical harmonics
  65858. */
  65859. l10: Vector3;
  65860. /**
  65861. * The l1,1 coefficients of the spherical harmonics
  65862. */
  65863. l11: Vector3;
  65864. /**
  65865. * The l2,-2 coefficients of the spherical harmonics
  65866. */
  65867. l2_2: Vector3;
  65868. /**
  65869. * The l2,-1 coefficients of the spherical harmonics
  65870. */
  65871. l2_1: Vector3;
  65872. /**
  65873. * The l2,0 coefficients of the spherical harmonics
  65874. */
  65875. l20: Vector3;
  65876. /**
  65877. * The l2,1 coefficients of the spherical harmonics
  65878. */
  65879. l21: Vector3;
  65880. /**
  65881. * The l2,2 coefficients of the spherical harmonics
  65882. */
  65883. l22: Vector3;
  65884. /**
  65885. * Adds a light to the spherical harmonics
  65886. * @param direction the direction of the light
  65887. * @param color the color of the light
  65888. * @param deltaSolidAngle the delta solid angle of the light
  65889. */
  65890. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65891. /**
  65892. * Scales the spherical harmonics by the given amount
  65893. * @param scale the amount to scale
  65894. */
  65895. scaleInPlace(scale: number): void;
  65896. /**
  65897. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65898. *
  65899. * ```
  65900. * E_lm = A_l * L_lm
  65901. * ```
  65902. *
  65903. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65904. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65905. * the scaling factors are given in equation 9.
  65906. */
  65907. convertIncidentRadianceToIrradiance(): void;
  65908. /**
  65909. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65910. *
  65911. * ```
  65912. * L = (1/pi) * E * rho
  65913. * ```
  65914. *
  65915. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65916. */
  65917. convertIrradianceToLambertianRadiance(): void;
  65918. /**
  65919. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65920. * required operations at run time.
  65921. *
  65922. * This is simply done by scaling back the SH with Ylm constants parameter.
  65923. * The trigonometric part being applied by the shader at run time.
  65924. */
  65925. preScaleForRendering(): void;
  65926. /**
  65927. * Constructs a spherical harmonics from an array.
  65928. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65929. * @returns the spherical harmonics
  65930. */
  65931. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65932. /**
  65933. * Gets the spherical harmonics from polynomial
  65934. * @param polynomial the spherical polynomial
  65935. * @returns the spherical harmonics
  65936. */
  65937. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65938. }
  65939. /**
  65940. * Class representing spherical polynomial coefficients to the 3rd degree
  65941. */
  65942. export class SphericalPolynomial {
  65943. private _harmonics;
  65944. /**
  65945. * The spherical harmonics used to create the polynomials.
  65946. */
  65947. readonly preScaledHarmonics: SphericalHarmonics;
  65948. /**
  65949. * The x coefficients of the spherical polynomial
  65950. */
  65951. x: Vector3;
  65952. /**
  65953. * The y coefficients of the spherical polynomial
  65954. */
  65955. y: Vector3;
  65956. /**
  65957. * The z coefficients of the spherical polynomial
  65958. */
  65959. z: Vector3;
  65960. /**
  65961. * The xx coefficients of the spherical polynomial
  65962. */
  65963. xx: Vector3;
  65964. /**
  65965. * The yy coefficients of the spherical polynomial
  65966. */
  65967. yy: Vector3;
  65968. /**
  65969. * The zz coefficients of the spherical polynomial
  65970. */
  65971. zz: Vector3;
  65972. /**
  65973. * The xy coefficients of the spherical polynomial
  65974. */
  65975. xy: Vector3;
  65976. /**
  65977. * The yz coefficients of the spherical polynomial
  65978. */
  65979. yz: Vector3;
  65980. /**
  65981. * The zx coefficients of the spherical polynomial
  65982. */
  65983. zx: Vector3;
  65984. /**
  65985. * Adds an ambient color to the spherical polynomial
  65986. * @param color the color to add
  65987. */
  65988. addAmbient(color: Color3): void;
  65989. /**
  65990. * Scales the spherical polynomial by the given amount
  65991. * @param scale the amount to scale
  65992. */
  65993. scaleInPlace(scale: number): void;
  65994. /**
  65995. * Gets the spherical polynomial from harmonics
  65996. * @param harmonics the spherical harmonics
  65997. * @returns the spherical polynomial
  65998. */
  65999. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  66000. /**
  66001. * Constructs a spherical polynomial from an array.
  66002. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  66003. * @returns the spherical polynomial
  66004. */
  66005. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  66006. }
  66007. }
  66008. declare module BABYLON {
  66009. /**
  66010. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  66011. */
  66012. export interface CubeMapInfo {
  66013. /**
  66014. * The pixel array for the front face.
  66015. * This is stored in format, left to right, up to down format.
  66016. */
  66017. front: Nullable<ArrayBufferView>;
  66018. /**
  66019. * The pixel array for the back face.
  66020. * This is stored in format, left to right, up to down format.
  66021. */
  66022. back: Nullable<ArrayBufferView>;
  66023. /**
  66024. * The pixel array for the left face.
  66025. * This is stored in format, left to right, up to down format.
  66026. */
  66027. left: Nullable<ArrayBufferView>;
  66028. /**
  66029. * The pixel array for the right face.
  66030. * This is stored in format, left to right, up to down format.
  66031. */
  66032. right: Nullable<ArrayBufferView>;
  66033. /**
  66034. * The pixel array for the up face.
  66035. * This is stored in format, left to right, up to down format.
  66036. */
  66037. up: Nullable<ArrayBufferView>;
  66038. /**
  66039. * The pixel array for the down face.
  66040. * This is stored in format, left to right, up to down format.
  66041. */
  66042. down: Nullable<ArrayBufferView>;
  66043. /**
  66044. * The size of the cubemap stored.
  66045. *
  66046. * Each faces will be size * size pixels.
  66047. */
  66048. size: number;
  66049. /**
  66050. * The format of the texture.
  66051. *
  66052. * RGBA, RGB.
  66053. */
  66054. format: number;
  66055. /**
  66056. * The type of the texture data.
  66057. *
  66058. * UNSIGNED_INT, FLOAT.
  66059. */
  66060. type: number;
  66061. /**
  66062. * Specifies whether the texture is in gamma space.
  66063. */
  66064. gammaSpace: boolean;
  66065. }
  66066. /**
  66067. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  66068. */
  66069. export class PanoramaToCubeMapTools {
  66070. private static FACE_FRONT;
  66071. private static FACE_BACK;
  66072. private static FACE_RIGHT;
  66073. private static FACE_LEFT;
  66074. private static FACE_DOWN;
  66075. private static FACE_UP;
  66076. /**
  66077. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  66078. *
  66079. * @param float32Array The source data.
  66080. * @param inputWidth The width of the input panorama.
  66081. * @param inputHeight The height of the input panorama.
  66082. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  66083. * @return The cubemap data
  66084. */
  66085. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  66086. private static CreateCubemapTexture;
  66087. private static CalcProjectionSpherical;
  66088. }
  66089. }
  66090. declare module BABYLON {
  66091. /**
  66092. * Helper class dealing with the extraction of spherical polynomial dataArray
  66093. * from a cube map.
  66094. */
  66095. export class CubeMapToSphericalPolynomialTools {
  66096. private static FileFaces;
  66097. /**
  66098. * Converts a texture to the according Spherical Polynomial data.
  66099. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66100. *
  66101. * @param texture The texture to extract the information from.
  66102. * @return The Spherical Polynomial data.
  66103. */
  66104. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  66105. /**
  66106. * Converts a cubemap to the according Spherical Polynomial data.
  66107. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66108. *
  66109. * @param cubeInfo The Cube map to extract the information from.
  66110. * @return The Spherical Polynomial data.
  66111. */
  66112. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  66113. }
  66114. }
  66115. declare module BABYLON {
  66116. /**
  66117. * The engine store class is responsible to hold all the instances of Engine and Scene created
  66118. * during the life time of the application.
  66119. */
  66120. export class EngineStore {
  66121. /** Gets the list of created engines */
  66122. static Instances: Engine[];
  66123. /** @hidden */
  66124. static _LastCreatedScene: Nullable<Scene>;
  66125. /**
  66126. * Gets the latest created engine
  66127. */
  66128. static readonly LastCreatedEngine: Nullable<Engine>;
  66129. /**
  66130. * Gets the latest created scene
  66131. */
  66132. static readonly LastCreatedScene: Nullable<Scene>;
  66133. }
  66134. }
  66135. declare module BABYLON {
  66136. /**
  66137. * Define options used to create a render target texture
  66138. */
  66139. export class RenderTargetCreationOptions {
  66140. /**
  66141. * Specifies is mipmaps must be generated
  66142. */
  66143. generateMipMaps?: boolean;
  66144. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66145. generateDepthBuffer?: boolean;
  66146. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66147. generateStencilBuffer?: boolean;
  66148. /** Defines texture type (int by default) */
  66149. type?: number;
  66150. /** Defines sampling mode (trilinear by default) */
  66151. samplingMode?: number;
  66152. /** Defines format (RGBA by default) */
  66153. format?: number;
  66154. }
  66155. }
  66156. declare module BABYLON {
  66157. /**
  66158. * @hidden
  66159. **/
  66160. export class _AlphaState {
  66161. private _isAlphaBlendDirty;
  66162. private _isBlendFunctionParametersDirty;
  66163. private _isBlendEquationParametersDirty;
  66164. private _isBlendConstantsDirty;
  66165. private _alphaBlend;
  66166. private _blendFunctionParameters;
  66167. private _blendEquationParameters;
  66168. private _blendConstants;
  66169. /**
  66170. * Initializes the state.
  66171. */
  66172. constructor();
  66173. readonly isDirty: boolean;
  66174. alphaBlend: boolean;
  66175. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66176. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66177. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66178. reset(): void;
  66179. apply(gl: WebGLRenderingContext): void;
  66180. }
  66181. }
  66182. declare module BABYLON {
  66183. /**
  66184. * @hidden
  66185. **/
  66186. export class _DepthCullingState {
  66187. private _isDepthTestDirty;
  66188. private _isDepthMaskDirty;
  66189. private _isDepthFuncDirty;
  66190. private _isCullFaceDirty;
  66191. private _isCullDirty;
  66192. private _isZOffsetDirty;
  66193. private _isFrontFaceDirty;
  66194. private _depthTest;
  66195. private _depthMask;
  66196. private _depthFunc;
  66197. private _cull;
  66198. private _cullFace;
  66199. private _zOffset;
  66200. private _frontFace;
  66201. /**
  66202. * Initializes the state.
  66203. */
  66204. constructor();
  66205. readonly isDirty: boolean;
  66206. zOffset: number;
  66207. cullFace: Nullable<number>;
  66208. cull: Nullable<boolean>;
  66209. depthFunc: Nullable<number>;
  66210. depthMask: boolean;
  66211. depthTest: boolean;
  66212. frontFace: Nullable<number>;
  66213. reset(): void;
  66214. apply(gl: WebGLRenderingContext): void;
  66215. }
  66216. }
  66217. declare module BABYLON {
  66218. /**
  66219. * @hidden
  66220. **/
  66221. export class _StencilState {
  66222. /** 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 */
  66223. static readonly ALWAYS: number;
  66224. /** Passed to stencilOperation to specify that stencil value must be kept */
  66225. static readonly KEEP: number;
  66226. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66227. static readonly REPLACE: number;
  66228. private _isStencilTestDirty;
  66229. private _isStencilMaskDirty;
  66230. private _isStencilFuncDirty;
  66231. private _isStencilOpDirty;
  66232. private _stencilTest;
  66233. private _stencilMask;
  66234. private _stencilFunc;
  66235. private _stencilFuncRef;
  66236. private _stencilFuncMask;
  66237. private _stencilOpStencilFail;
  66238. private _stencilOpDepthFail;
  66239. private _stencilOpStencilDepthPass;
  66240. readonly isDirty: boolean;
  66241. stencilFunc: number;
  66242. stencilFuncRef: number;
  66243. stencilFuncMask: number;
  66244. stencilOpStencilFail: number;
  66245. stencilOpDepthFail: number;
  66246. stencilOpStencilDepthPass: number;
  66247. stencilMask: number;
  66248. stencilTest: boolean;
  66249. constructor();
  66250. reset(): void;
  66251. apply(gl: WebGLRenderingContext): void;
  66252. }
  66253. }
  66254. declare module BABYLON {
  66255. /**
  66256. * @hidden
  66257. **/
  66258. export class _TimeToken {
  66259. _startTimeQuery: Nullable<WebGLQuery>;
  66260. _endTimeQuery: Nullable<WebGLQuery>;
  66261. _timeElapsedQuery: Nullable<WebGLQuery>;
  66262. _timeElapsedQueryEnded: boolean;
  66263. }
  66264. }
  66265. declare module BABYLON {
  66266. /**
  66267. * Class used to store data associated with WebGL texture data for the engine
  66268. * This class should not be used directly
  66269. */
  66270. export class InternalTexture {
  66271. /** hidden */
  66272. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66273. /**
  66274. * The source of the texture data is unknown
  66275. */
  66276. static DATASOURCE_UNKNOWN: number;
  66277. /**
  66278. * Texture data comes from an URL
  66279. */
  66280. static DATASOURCE_URL: number;
  66281. /**
  66282. * Texture data is only used for temporary storage
  66283. */
  66284. static DATASOURCE_TEMP: number;
  66285. /**
  66286. * Texture data comes from raw data (ArrayBuffer)
  66287. */
  66288. static DATASOURCE_RAW: number;
  66289. /**
  66290. * Texture content is dynamic (video or dynamic texture)
  66291. */
  66292. static DATASOURCE_DYNAMIC: number;
  66293. /**
  66294. * Texture content is generated by rendering to it
  66295. */
  66296. static DATASOURCE_RENDERTARGET: number;
  66297. /**
  66298. * Texture content is part of a multi render target process
  66299. */
  66300. static DATASOURCE_MULTIRENDERTARGET: number;
  66301. /**
  66302. * Texture data comes from a cube data file
  66303. */
  66304. static DATASOURCE_CUBE: number;
  66305. /**
  66306. * Texture data comes from a raw cube data
  66307. */
  66308. static DATASOURCE_CUBERAW: number;
  66309. /**
  66310. * Texture data come from a prefiltered cube data file
  66311. */
  66312. static DATASOURCE_CUBEPREFILTERED: number;
  66313. /**
  66314. * Texture content is raw 3D data
  66315. */
  66316. static DATASOURCE_RAW3D: number;
  66317. /**
  66318. * Texture content is a depth texture
  66319. */
  66320. static DATASOURCE_DEPTHTEXTURE: number;
  66321. /**
  66322. * Texture data comes from a raw cube data encoded with RGBD
  66323. */
  66324. static DATASOURCE_CUBERAW_RGBD: number;
  66325. /**
  66326. * Defines if the texture is ready
  66327. */
  66328. isReady: boolean;
  66329. /**
  66330. * Defines if the texture is a cube texture
  66331. */
  66332. isCube: boolean;
  66333. /**
  66334. * Defines if the texture contains 3D data
  66335. */
  66336. is3D: boolean;
  66337. /**
  66338. * Defines if the texture contains multiview data
  66339. */
  66340. isMultiview: boolean;
  66341. /**
  66342. * Gets the URL used to load this texture
  66343. */
  66344. url: string;
  66345. /**
  66346. * Gets the sampling mode of the texture
  66347. */
  66348. samplingMode: number;
  66349. /**
  66350. * Gets a boolean indicating if the texture needs mipmaps generation
  66351. */
  66352. generateMipMaps: boolean;
  66353. /**
  66354. * Gets the number of samples used by the texture (WebGL2+ only)
  66355. */
  66356. samples: number;
  66357. /**
  66358. * Gets the type of the texture (int, float...)
  66359. */
  66360. type: number;
  66361. /**
  66362. * Gets the format of the texture (RGB, RGBA...)
  66363. */
  66364. format: number;
  66365. /**
  66366. * Observable called when the texture is loaded
  66367. */
  66368. onLoadedObservable: Observable<InternalTexture>;
  66369. /**
  66370. * Gets the width of the texture
  66371. */
  66372. width: number;
  66373. /**
  66374. * Gets the height of the texture
  66375. */
  66376. height: number;
  66377. /**
  66378. * Gets the depth of the texture
  66379. */
  66380. depth: number;
  66381. /**
  66382. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66383. */
  66384. baseWidth: number;
  66385. /**
  66386. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66387. */
  66388. baseHeight: number;
  66389. /**
  66390. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66391. */
  66392. baseDepth: number;
  66393. /**
  66394. * Gets a boolean indicating if the texture is inverted on Y axis
  66395. */
  66396. invertY: boolean;
  66397. /** @hidden */
  66398. _invertVScale: boolean;
  66399. /** @hidden */
  66400. _associatedChannel: number;
  66401. /** @hidden */
  66402. _dataSource: number;
  66403. /** @hidden */
  66404. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66405. /** @hidden */
  66406. _bufferView: Nullable<ArrayBufferView>;
  66407. /** @hidden */
  66408. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66409. /** @hidden */
  66410. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66411. /** @hidden */
  66412. _size: number;
  66413. /** @hidden */
  66414. _extension: string;
  66415. /** @hidden */
  66416. _files: Nullable<string[]>;
  66417. /** @hidden */
  66418. _workingCanvas: Nullable<HTMLCanvasElement>;
  66419. /** @hidden */
  66420. _workingContext: Nullable<CanvasRenderingContext2D>;
  66421. /** @hidden */
  66422. _framebuffer: Nullable<WebGLFramebuffer>;
  66423. /** @hidden */
  66424. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66425. /** @hidden */
  66426. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66427. /** @hidden */
  66428. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66429. /** @hidden */
  66430. _attachments: Nullable<number[]>;
  66431. /** @hidden */
  66432. _cachedCoordinatesMode: Nullable<number>;
  66433. /** @hidden */
  66434. _cachedWrapU: Nullable<number>;
  66435. /** @hidden */
  66436. _cachedWrapV: Nullable<number>;
  66437. /** @hidden */
  66438. _cachedWrapR: Nullable<number>;
  66439. /** @hidden */
  66440. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66441. /** @hidden */
  66442. _isDisabled: boolean;
  66443. /** @hidden */
  66444. _compression: Nullable<string>;
  66445. /** @hidden */
  66446. _generateStencilBuffer: boolean;
  66447. /** @hidden */
  66448. _generateDepthBuffer: boolean;
  66449. /** @hidden */
  66450. _comparisonFunction: number;
  66451. /** @hidden */
  66452. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66453. /** @hidden */
  66454. _lodGenerationScale: number;
  66455. /** @hidden */
  66456. _lodGenerationOffset: number;
  66457. /** @hidden */
  66458. _colorTextureArray: Nullable<WebGLTexture>;
  66459. /** @hidden */
  66460. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66461. /** @hidden */
  66462. _lodTextureHigh: Nullable<BaseTexture>;
  66463. /** @hidden */
  66464. _lodTextureMid: Nullable<BaseTexture>;
  66465. /** @hidden */
  66466. _lodTextureLow: Nullable<BaseTexture>;
  66467. /** @hidden */
  66468. _isRGBD: boolean;
  66469. /** @hidden */
  66470. _webGLTexture: Nullable<WebGLTexture>;
  66471. /** @hidden */
  66472. _references: number;
  66473. private _engine;
  66474. /**
  66475. * Gets the Engine the texture belongs to.
  66476. * @returns The babylon engine
  66477. */
  66478. getEngine(): Engine;
  66479. /**
  66480. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66481. */
  66482. readonly dataSource: number;
  66483. /**
  66484. * Creates a new InternalTexture
  66485. * @param engine defines the engine to use
  66486. * @param dataSource defines the type of data that will be used
  66487. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66488. */
  66489. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66490. /**
  66491. * Increments the number of references (ie. the number of Texture that point to it)
  66492. */
  66493. incrementReferences(): void;
  66494. /**
  66495. * Change the size of the texture (not the size of the content)
  66496. * @param width defines the new width
  66497. * @param height defines the new height
  66498. * @param depth defines the new depth (1 by default)
  66499. */
  66500. updateSize(width: int, height: int, depth?: int): void;
  66501. /** @hidden */
  66502. _rebuild(): void;
  66503. /** @hidden */
  66504. _swapAndDie(target: InternalTexture): void;
  66505. /**
  66506. * Dispose the current allocated resources
  66507. */
  66508. dispose(): void;
  66509. }
  66510. }
  66511. declare module BABYLON {
  66512. /**
  66513. * This represents the main contract an easing function should follow.
  66514. * Easing functions are used throughout the animation system.
  66515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66516. */
  66517. export interface IEasingFunction {
  66518. /**
  66519. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66520. * of the easing function.
  66521. * The link below provides some of the most common examples of easing functions.
  66522. * @see https://easings.net/
  66523. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66524. * @returns the corresponding value on the curve defined by the easing function
  66525. */
  66526. ease(gradient: number): number;
  66527. }
  66528. /**
  66529. * Base class used for every default easing function.
  66530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66531. */
  66532. export class EasingFunction implements IEasingFunction {
  66533. /**
  66534. * Interpolation follows the mathematical formula associated with the easing function.
  66535. */
  66536. static readonly EASINGMODE_EASEIN: number;
  66537. /**
  66538. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66539. */
  66540. static readonly EASINGMODE_EASEOUT: number;
  66541. /**
  66542. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66543. */
  66544. static readonly EASINGMODE_EASEINOUT: number;
  66545. private _easingMode;
  66546. /**
  66547. * Sets the easing mode of the current function.
  66548. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66549. */
  66550. setEasingMode(easingMode: number): void;
  66551. /**
  66552. * Gets the current easing mode.
  66553. * @returns the easing mode
  66554. */
  66555. getEasingMode(): number;
  66556. /**
  66557. * @hidden
  66558. */
  66559. easeInCore(gradient: number): number;
  66560. /**
  66561. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66562. * of the easing function.
  66563. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66564. * @returns the corresponding value on the curve defined by the easing function
  66565. */
  66566. ease(gradient: number): number;
  66567. }
  66568. /**
  66569. * Easing function with a circle shape (see link below).
  66570. * @see https://easings.net/#easeInCirc
  66571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66572. */
  66573. export class CircleEase extends EasingFunction implements IEasingFunction {
  66574. /** @hidden */
  66575. easeInCore(gradient: number): number;
  66576. }
  66577. /**
  66578. * Easing function with a ease back shape (see link below).
  66579. * @see https://easings.net/#easeInBack
  66580. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66581. */
  66582. export class BackEase extends EasingFunction implements IEasingFunction {
  66583. /** Defines the amplitude of the function */
  66584. amplitude: number;
  66585. /**
  66586. * Instantiates a back ease easing
  66587. * @see https://easings.net/#easeInBack
  66588. * @param amplitude Defines the amplitude of the function
  66589. */
  66590. constructor(
  66591. /** Defines the amplitude of the function */
  66592. amplitude?: number);
  66593. /** @hidden */
  66594. easeInCore(gradient: number): number;
  66595. }
  66596. /**
  66597. * Easing function with a bouncing shape (see link below).
  66598. * @see https://easings.net/#easeInBounce
  66599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66600. */
  66601. export class BounceEase extends EasingFunction implements IEasingFunction {
  66602. /** Defines the number of bounces */
  66603. bounces: number;
  66604. /** Defines the amplitude of the bounce */
  66605. bounciness: number;
  66606. /**
  66607. * Instantiates a bounce easing
  66608. * @see https://easings.net/#easeInBounce
  66609. * @param bounces Defines the number of bounces
  66610. * @param bounciness Defines the amplitude of the bounce
  66611. */
  66612. constructor(
  66613. /** Defines the number of bounces */
  66614. bounces?: number,
  66615. /** Defines the amplitude of the bounce */
  66616. bounciness?: number);
  66617. /** @hidden */
  66618. easeInCore(gradient: number): number;
  66619. }
  66620. /**
  66621. * Easing function with a power of 3 shape (see link below).
  66622. * @see https://easings.net/#easeInCubic
  66623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66624. */
  66625. export class CubicEase extends EasingFunction implements IEasingFunction {
  66626. /** @hidden */
  66627. easeInCore(gradient: number): number;
  66628. }
  66629. /**
  66630. * Easing function with an elastic shape (see link below).
  66631. * @see https://easings.net/#easeInElastic
  66632. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66633. */
  66634. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66635. /** Defines the number of oscillations*/
  66636. oscillations: number;
  66637. /** Defines the amplitude of the oscillations*/
  66638. springiness: number;
  66639. /**
  66640. * Instantiates an elastic easing function
  66641. * @see https://easings.net/#easeInElastic
  66642. * @param oscillations Defines the number of oscillations
  66643. * @param springiness Defines the amplitude of the oscillations
  66644. */
  66645. constructor(
  66646. /** Defines the number of oscillations*/
  66647. oscillations?: number,
  66648. /** Defines the amplitude of the oscillations*/
  66649. springiness?: number);
  66650. /** @hidden */
  66651. easeInCore(gradient: number): number;
  66652. }
  66653. /**
  66654. * Easing function with an exponential shape (see link below).
  66655. * @see https://easings.net/#easeInExpo
  66656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66657. */
  66658. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66659. /** Defines the exponent of the function */
  66660. exponent: number;
  66661. /**
  66662. * Instantiates an exponential easing function
  66663. * @see https://easings.net/#easeInExpo
  66664. * @param exponent Defines the exponent of the function
  66665. */
  66666. constructor(
  66667. /** Defines the exponent of the function */
  66668. exponent?: number);
  66669. /** @hidden */
  66670. easeInCore(gradient: number): number;
  66671. }
  66672. /**
  66673. * Easing function with a power shape (see link below).
  66674. * @see https://easings.net/#easeInQuad
  66675. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66676. */
  66677. export class PowerEase extends EasingFunction implements IEasingFunction {
  66678. /** Defines the power of the function */
  66679. power: number;
  66680. /**
  66681. * Instantiates an power base easing function
  66682. * @see https://easings.net/#easeInQuad
  66683. * @param power Defines the power of the function
  66684. */
  66685. constructor(
  66686. /** Defines the power of the function */
  66687. power?: number);
  66688. /** @hidden */
  66689. easeInCore(gradient: number): number;
  66690. }
  66691. /**
  66692. * Easing function with a power of 2 shape (see link below).
  66693. * @see https://easings.net/#easeInQuad
  66694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66695. */
  66696. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66697. /** @hidden */
  66698. easeInCore(gradient: number): number;
  66699. }
  66700. /**
  66701. * Easing function with a power of 4 shape (see link below).
  66702. * @see https://easings.net/#easeInQuart
  66703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66704. */
  66705. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66706. /** @hidden */
  66707. easeInCore(gradient: number): number;
  66708. }
  66709. /**
  66710. * Easing function with a power of 5 shape (see link below).
  66711. * @see https://easings.net/#easeInQuint
  66712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66713. */
  66714. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66715. /** @hidden */
  66716. easeInCore(gradient: number): number;
  66717. }
  66718. /**
  66719. * Easing function with a sin shape (see link below).
  66720. * @see https://easings.net/#easeInSine
  66721. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66722. */
  66723. export class SineEase extends EasingFunction implements IEasingFunction {
  66724. /** @hidden */
  66725. easeInCore(gradient: number): number;
  66726. }
  66727. /**
  66728. * Easing function with a bezier shape (see link below).
  66729. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66730. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66731. */
  66732. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66733. /** Defines the x component of the start tangent in the bezier curve */
  66734. x1: number;
  66735. /** Defines the y component of the start tangent in the bezier curve */
  66736. y1: number;
  66737. /** Defines the x component of the end tangent in the bezier curve */
  66738. x2: number;
  66739. /** Defines the y component of the end tangent in the bezier curve */
  66740. y2: number;
  66741. /**
  66742. * Instantiates a bezier function
  66743. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66744. * @param x1 Defines the x component of the start tangent in the bezier curve
  66745. * @param y1 Defines the y component of the start tangent in the bezier curve
  66746. * @param x2 Defines the x component of the end tangent in the bezier curve
  66747. * @param y2 Defines the y component of the end tangent in the bezier curve
  66748. */
  66749. constructor(
  66750. /** Defines the x component of the start tangent in the bezier curve */
  66751. x1?: number,
  66752. /** Defines the y component of the start tangent in the bezier curve */
  66753. y1?: number,
  66754. /** Defines the x component of the end tangent in the bezier curve */
  66755. x2?: number,
  66756. /** Defines the y component of the end tangent in the bezier curve */
  66757. y2?: number);
  66758. /** @hidden */
  66759. easeInCore(gradient: number): number;
  66760. }
  66761. }
  66762. declare module BABYLON {
  66763. /**
  66764. * Defines an interface which represents an animation key frame
  66765. */
  66766. export interface IAnimationKey {
  66767. /**
  66768. * Frame of the key frame
  66769. */
  66770. frame: number;
  66771. /**
  66772. * Value at the specifies key frame
  66773. */
  66774. value: any;
  66775. /**
  66776. * The input tangent for the cubic hermite spline
  66777. */
  66778. inTangent?: any;
  66779. /**
  66780. * The output tangent for the cubic hermite spline
  66781. */
  66782. outTangent?: any;
  66783. /**
  66784. * The animation interpolation type
  66785. */
  66786. interpolation?: AnimationKeyInterpolation;
  66787. }
  66788. /**
  66789. * Enum for the animation key frame interpolation type
  66790. */
  66791. export enum AnimationKeyInterpolation {
  66792. /**
  66793. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66794. */
  66795. STEP = 1
  66796. }
  66797. }
  66798. declare module BABYLON {
  66799. /**
  66800. * Represents the range of an animation
  66801. */
  66802. export class AnimationRange {
  66803. /**The name of the animation range**/
  66804. name: string;
  66805. /**The starting frame of the animation */
  66806. from: number;
  66807. /**The ending frame of the animation*/
  66808. to: number;
  66809. /**
  66810. * Initializes the range of an animation
  66811. * @param name The name of the animation range
  66812. * @param from The starting frame of the animation
  66813. * @param to The ending frame of the animation
  66814. */
  66815. constructor(
  66816. /**The name of the animation range**/
  66817. name: string,
  66818. /**The starting frame of the animation */
  66819. from: number,
  66820. /**The ending frame of the animation*/
  66821. to: number);
  66822. /**
  66823. * Makes a copy of the animation range
  66824. * @returns A copy of the animation range
  66825. */
  66826. clone(): AnimationRange;
  66827. }
  66828. }
  66829. declare module BABYLON {
  66830. /**
  66831. * Composed of a frame, and an action function
  66832. */
  66833. export class AnimationEvent {
  66834. /** The frame for which the event is triggered **/
  66835. frame: number;
  66836. /** The event to perform when triggered **/
  66837. action: (currentFrame: number) => void;
  66838. /** Specifies if the event should be triggered only once**/
  66839. onlyOnce?: boolean | undefined;
  66840. /**
  66841. * Specifies if the animation event is done
  66842. */
  66843. isDone: boolean;
  66844. /**
  66845. * Initializes the animation event
  66846. * @param frame The frame for which the event is triggered
  66847. * @param action The event to perform when triggered
  66848. * @param onlyOnce Specifies if the event should be triggered only once
  66849. */
  66850. constructor(
  66851. /** The frame for which the event is triggered **/
  66852. frame: number,
  66853. /** The event to perform when triggered **/
  66854. action: (currentFrame: number) => void,
  66855. /** Specifies if the event should be triggered only once**/
  66856. onlyOnce?: boolean | undefined);
  66857. /** @hidden */
  66858. _clone(): AnimationEvent;
  66859. }
  66860. }
  66861. declare module BABYLON {
  66862. /**
  66863. * Interface used to define a behavior
  66864. */
  66865. export interface Behavior<T> {
  66866. /** gets or sets behavior's name */
  66867. name: string;
  66868. /**
  66869. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66870. */
  66871. init(): void;
  66872. /**
  66873. * Called when the behavior is attached to a target
  66874. * @param target defines the target where the behavior is attached to
  66875. */
  66876. attach(target: T): void;
  66877. /**
  66878. * Called when the behavior is detached from its target
  66879. */
  66880. detach(): void;
  66881. }
  66882. /**
  66883. * Interface implemented by classes supporting behaviors
  66884. */
  66885. export interface IBehaviorAware<T> {
  66886. /**
  66887. * Attach a behavior
  66888. * @param behavior defines the behavior to attach
  66889. * @returns the current host
  66890. */
  66891. addBehavior(behavior: Behavior<T>): T;
  66892. /**
  66893. * Remove a behavior from the current object
  66894. * @param behavior defines the behavior to detach
  66895. * @returns the current host
  66896. */
  66897. removeBehavior(behavior: Behavior<T>): T;
  66898. /**
  66899. * Gets a behavior using its name to search
  66900. * @param name defines the name to search
  66901. * @returns the behavior or null if not found
  66902. */
  66903. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66904. }
  66905. }
  66906. declare module BABYLON {
  66907. /**
  66908. * @hidden
  66909. */
  66910. export class IntersectionInfo {
  66911. bu: Nullable<number>;
  66912. bv: Nullable<number>;
  66913. distance: number;
  66914. faceId: number;
  66915. subMeshId: number;
  66916. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66917. }
  66918. }
  66919. declare module BABYLON {
  66920. /**
  66921. * Class used to store bounding sphere information
  66922. */
  66923. export class BoundingSphere {
  66924. /**
  66925. * Gets the center of the bounding sphere in local space
  66926. */
  66927. readonly center: Vector3;
  66928. /**
  66929. * Radius of the bounding sphere in local space
  66930. */
  66931. radius: number;
  66932. /**
  66933. * Gets the center of the bounding sphere in world space
  66934. */
  66935. readonly centerWorld: Vector3;
  66936. /**
  66937. * Radius of the bounding sphere in world space
  66938. */
  66939. radiusWorld: number;
  66940. /**
  66941. * Gets the minimum vector in local space
  66942. */
  66943. readonly minimum: Vector3;
  66944. /**
  66945. * Gets the maximum vector in local space
  66946. */
  66947. readonly maximum: Vector3;
  66948. private _worldMatrix;
  66949. private static readonly TmpVector3;
  66950. /**
  66951. * Creates a new bounding sphere
  66952. * @param min defines the minimum vector (in local space)
  66953. * @param max defines the maximum vector (in local space)
  66954. * @param worldMatrix defines the new world matrix
  66955. */
  66956. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66957. /**
  66958. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66959. * @param min defines the new minimum vector (in local space)
  66960. * @param max defines the new maximum vector (in local space)
  66961. * @param worldMatrix defines the new world matrix
  66962. */
  66963. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66964. /**
  66965. * Scale the current bounding sphere by applying a scale factor
  66966. * @param factor defines the scale factor to apply
  66967. * @returns the current bounding box
  66968. */
  66969. scale(factor: number): BoundingSphere;
  66970. /**
  66971. * Gets the world matrix of the bounding box
  66972. * @returns a matrix
  66973. */
  66974. getWorldMatrix(): DeepImmutable<Matrix>;
  66975. /** @hidden */
  66976. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66977. /**
  66978. * Tests if the bounding sphere is intersecting the frustum planes
  66979. * @param frustumPlanes defines the frustum planes to test
  66980. * @returns true if there is an intersection
  66981. */
  66982. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66983. /**
  66984. * Tests if the bounding sphere center is in between the frustum planes.
  66985. * Used for optimistic fast inclusion.
  66986. * @param frustumPlanes defines the frustum planes to test
  66987. * @returns true if the sphere center is in between the frustum planes
  66988. */
  66989. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66990. /**
  66991. * Tests if a point is inside the bounding sphere
  66992. * @param point defines the point to test
  66993. * @returns true if the point is inside the bounding sphere
  66994. */
  66995. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66996. /**
  66997. * Checks if two sphere intersct
  66998. * @param sphere0 sphere 0
  66999. * @param sphere1 sphere 1
  67000. * @returns true if the speres intersect
  67001. */
  67002. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  67003. }
  67004. }
  67005. declare module BABYLON {
  67006. /**
  67007. * Class used to store bounding box information
  67008. */
  67009. export class BoundingBox implements ICullable {
  67010. /**
  67011. * Gets the 8 vectors representing the bounding box in local space
  67012. */
  67013. readonly vectors: Vector3[];
  67014. /**
  67015. * Gets the center of the bounding box in local space
  67016. */
  67017. readonly center: Vector3;
  67018. /**
  67019. * Gets the center of the bounding box in world space
  67020. */
  67021. readonly centerWorld: Vector3;
  67022. /**
  67023. * Gets the extend size in local space
  67024. */
  67025. readonly extendSize: Vector3;
  67026. /**
  67027. * Gets the extend size in world space
  67028. */
  67029. readonly extendSizeWorld: Vector3;
  67030. /**
  67031. * Gets the OBB (object bounding box) directions
  67032. */
  67033. readonly directions: Vector3[];
  67034. /**
  67035. * Gets the 8 vectors representing the bounding box in world space
  67036. */
  67037. readonly vectorsWorld: Vector3[];
  67038. /**
  67039. * Gets the minimum vector in world space
  67040. */
  67041. readonly minimumWorld: Vector3;
  67042. /**
  67043. * Gets the maximum vector in world space
  67044. */
  67045. readonly maximumWorld: Vector3;
  67046. /**
  67047. * Gets the minimum vector in local space
  67048. */
  67049. readonly minimum: Vector3;
  67050. /**
  67051. * Gets the maximum vector in local space
  67052. */
  67053. readonly maximum: Vector3;
  67054. private _worldMatrix;
  67055. private static readonly TmpVector3;
  67056. /**
  67057. * @hidden
  67058. */
  67059. _tag: number;
  67060. /**
  67061. * Creates a new bounding box
  67062. * @param min defines the minimum vector (in local space)
  67063. * @param max defines the maximum vector (in local space)
  67064. * @param worldMatrix defines the new world matrix
  67065. */
  67066. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67067. /**
  67068. * Recreates the entire bounding box from scratch as if we call the constructor in place
  67069. * @param min defines the new minimum vector (in local space)
  67070. * @param max defines the new maximum vector (in local space)
  67071. * @param worldMatrix defines the new world matrix
  67072. */
  67073. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67074. /**
  67075. * Scale the current bounding box by applying a scale factor
  67076. * @param factor defines the scale factor to apply
  67077. * @returns the current bounding box
  67078. */
  67079. scale(factor: number): BoundingBox;
  67080. /**
  67081. * Gets the world matrix of the bounding box
  67082. * @returns a matrix
  67083. */
  67084. getWorldMatrix(): DeepImmutable<Matrix>;
  67085. /** @hidden */
  67086. _update(world: DeepImmutable<Matrix>): void;
  67087. /**
  67088. * Tests if the bounding box is intersecting the frustum planes
  67089. * @param frustumPlanes defines the frustum planes to test
  67090. * @returns true if there is an intersection
  67091. */
  67092. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67093. /**
  67094. * Tests if the bounding box is entirely inside the frustum planes
  67095. * @param frustumPlanes defines the frustum planes to test
  67096. * @returns true if there is an inclusion
  67097. */
  67098. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67099. /**
  67100. * Tests if a point is inside the bounding box
  67101. * @param point defines the point to test
  67102. * @returns true if the point is inside the bounding box
  67103. */
  67104. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67105. /**
  67106. * Tests if the bounding box intersects with a bounding sphere
  67107. * @param sphere defines the sphere to test
  67108. * @returns true if there is an intersection
  67109. */
  67110. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  67111. /**
  67112. * Tests if the bounding box intersects with a box defined by a min and max vectors
  67113. * @param min defines the min vector to use
  67114. * @param max defines the max vector to use
  67115. * @returns true if there is an intersection
  67116. */
  67117. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  67118. /**
  67119. * Tests if two bounding boxes are intersections
  67120. * @param box0 defines the first box to test
  67121. * @param box1 defines the second box to test
  67122. * @returns true if there is an intersection
  67123. */
  67124. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67125. /**
  67126. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67127. * @param minPoint defines the minimum vector of the bounding box
  67128. * @param maxPoint defines the maximum vector of the bounding box
  67129. * @param sphereCenter defines the sphere center
  67130. * @param sphereRadius defines the sphere radius
  67131. * @returns true if there is an intersection
  67132. */
  67133. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67134. /**
  67135. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67136. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67137. * @param frustumPlanes defines the frustum planes to test
  67138. * @return true if there is an inclusion
  67139. */
  67140. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67141. /**
  67142. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67143. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67144. * @param frustumPlanes defines the frustum planes to test
  67145. * @return true if there is an intersection
  67146. */
  67147. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67148. }
  67149. }
  67150. declare module BABYLON {
  67151. /** @hidden */
  67152. export class Collider {
  67153. /** Define if a collision was found */
  67154. collisionFound: boolean;
  67155. /**
  67156. * Define last intersection point in local space
  67157. */
  67158. intersectionPoint: Vector3;
  67159. /**
  67160. * Define last collided mesh
  67161. */
  67162. collidedMesh: Nullable<AbstractMesh>;
  67163. private _collisionPoint;
  67164. private _planeIntersectionPoint;
  67165. private _tempVector;
  67166. private _tempVector2;
  67167. private _tempVector3;
  67168. private _tempVector4;
  67169. private _edge;
  67170. private _baseToVertex;
  67171. private _destinationPoint;
  67172. private _slidePlaneNormal;
  67173. private _displacementVector;
  67174. /** @hidden */
  67175. _radius: Vector3;
  67176. /** @hidden */
  67177. _retry: number;
  67178. private _velocity;
  67179. private _basePoint;
  67180. private _epsilon;
  67181. /** @hidden */
  67182. _velocityWorldLength: number;
  67183. /** @hidden */
  67184. _basePointWorld: Vector3;
  67185. private _velocityWorld;
  67186. private _normalizedVelocity;
  67187. /** @hidden */
  67188. _initialVelocity: Vector3;
  67189. /** @hidden */
  67190. _initialPosition: Vector3;
  67191. private _nearestDistance;
  67192. private _collisionMask;
  67193. collisionMask: number;
  67194. /**
  67195. * Gets the plane normal used to compute the sliding response (in local space)
  67196. */
  67197. readonly slidePlaneNormal: Vector3;
  67198. /** @hidden */
  67199. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67200. /** @hidden */
  67201. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67202. /** @hidden */
  67203. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67204. /** @hidden */
  67205. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67206. /** @hidden */
  67207. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67208. /** @hidden */
  67209. _getResponse(pos: Vector3, vel: Vector3): void;
  67210. }
  67211. }
  67212. declare module BABYLON {
  67213. /**
  67214. * Interface for cullable objects
  67215. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67216. */
  67217. export interface ICullable {
  67218. /**
  67219. * Checks if the object or part of the object is in the frustum
  67220. * @param frustumPlanes Camera near/planes
  67221. * @returns true if the object is in frustum otherwise false
  67222. */
  67223. isInFrustum(frustumPlanes: Plane[]): boolean;
  67224. /**
  67225. * Checks if a cullable object (mesh...) is in the camera frustum
  67226. * Unlike isInFrustum this cheks the full bounding box
  67227. * @param frustumPlanes Camera near/planes
  67228. * @returns true if the object is in frustum otherwise false
  67229. */
  67230. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67231. }
  67232. /**
  67233. * Info for a bounding data of a mesh
  67234. */
  67235. export class BoundingInfo implements ICullable {
  67236. /**
  67237. * Bounding box for the mesh
  67238. */
  67239. readonly boundingBox: BoundingBox;
  67240. /**
  67241. * Bounding sphere for the mesh
  67242. */
  67243. readonly boundingSphere: BoundingSphere;
  67244. private _isLocked;
  67245. private static readonly TmpVector3;
  67246. /**
  67247. * Constructs bounding info
  67248. * @param minimum min vector of the bounding box/sphere
  67249. * @param maximum max vector of the bounding box/sphere
  67250. * @param worldMatrix defines the new world matrix
  67251. */
  67252. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67253. /**
  67254. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67255. * @param min defines the new minimum vector (in local space)
  67256. * @param max defines the new maximum vector (in local space)
  67257. * @param worldMatrix defines the new world matrix
  67258. */
  67259. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67260. /**
  67261. * min vector of the bounding box/sphere
  67262. */
  67263. readonly minimum: Vector3;
  67264. /**
  67265. * max vector of the bounding box/sphere
  67266. */
  67267. readonly maximum: Vector3;
  67268. /**
  67269. * If the info is locked and won't be updated to avoid perf overhead
  67270. */
  67271. isLocked: boolean;
  67272. /**
  67273. * Updates the bounding sphere and box
  67274. * @param world world matrix to be used to update
  67275. */
  67276. update(world: DeepImmutable<Matrix>): void;
  67277. /**
  67278. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67279. * @param center New center of the bounding info
  67280. * @param extend New extend of the bounding info
  67281. * @returns the current bounding info
  67282. */
  67283. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67284. /**
  67285. * Scale the current bounding info by applying a scale factor
  67286. * @param factor defines the scale factor to apply
  67287. * @returns the current bounding info
  67288. */
  67289. scale(factor: number): BoundingInfo;
  67290. /**
  67291. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67292. * @param frustumPlanes defines the frustum to test
  67293. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67294. * @returns true if the bounding info is in the frustum planes
  67295. */
  67296. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67297. /**
  67298. * Gets the world distance between the min and max points of the bounding box
  67299. */
  67300. readonly diagonalLength: number;
  67301. /**
  67302. * Checks if a cullable object (mesh...) is in the camera frustum
  67303. * Unlike isInFrustum this cheks the full bounding box
  67304. * @param frustumPlanes Camera near/planes
  67305. * @returns true if the object is in frustum otherwise false
  67306. */
  67307. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67308. /** @hidden */
  67309. _checkCollision(collider: Collider): boolean;
  67310. /**
  67311. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67312. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67313. * @param point the point to check intersection with
  67314. * @returns if the point intersects
  67315. */
  67316. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67317. /**
  67318. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67319. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67320. * @param boundingInfo the bounding info to check intersection with
  67321. * @param precise if the intersection should be done using OBB
  67322. * @returns if the bounding info intersects
  67323. */
  67324. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67325. }
  67326. }
  67327. declare module BABYLON {
  67328. /**
  67329. * Defines an array and its length.
  67330. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67331. */
  67332. export interface ISmartArrayLike<T> {
  67333. /**
  67334. * The data of the array.
  67335. */
  67336. data: Array<T>;
  67337. /**
  67338. * The active length of the array.
  67339. */
  67340. length: number;
  67341. }
  67342. /**
  67343. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67344. */
  67345. export class SmartArray<T> implements ISmartArrayLike<T> {
  67346. /**
  67347. * The full set of data from the array.
  67348. */
  67349. data: Array<T>;
  67350. /**
  67351. * The active length of the array.
  67352. */
  67353. length: number;
  67354. protected _id: number;
  67355. /**
  67356. * Instantiates a Smart Array.
  67357. * @param capacity defines the default capacity of the array.
  67358. */
  67359. constructor(capacity: number);
  67360. /**
  67361. * Pushes a value at the end of the active data.
  67362. * @param value defines the object to push in the array.
  67363. */
  67364. push(value: T): void;
  67365. /**
  67366. * Iterates over the active data and apply the lambda to them.
  67367. * @param func defines the action to apply on each value.
  67368. */
  67369. forEach(func: (content: T) => void): void;
  67370. /**
  67371. * Sorts the full sets of data.
  67372. * @param compareFn defines the comparison function to apply.
  67373. */
  67374. sort(compareFn: (a: T, b: T) => number): void;
  67375. /**
  67376. * Resets the active data to an empty array.
  67377. */
  67378. reset(): void;
  67379. /**
  67380. * Releases all the data from the array as well as the array.
  67381. */
  67382. dispose(): void;
  67383. /**
  67384. * Concats the active data with a given array.
  67385. * @param array defines the data to concatenate with.
  67386. */
  67387. concat(array: any): void;
  67388. /**
  67389. * Returns the position of a value in the active data.
  67390. * @param value defines the value to find the index for
  67391. * @returns the index if found in the active data otherwise -1
  67392. */
  67393. indexOf(value: T): number;
  67394. /**
  67395. * Returns whether an element is part of the active data.
  67396. * @param value defines the value to look for
  67397. * @returns true if found in the active data otherwise false
  67398. */
  67399. contains(value: T): boolean;
  67400. private static _GlobalId;
  67401. }
  67402. /**
  67403. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67404. * The data in this array can only be present once
  67405. */
  67406. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67407. private _duplicateId;
  67408. /**
  67409. * Pushes a value at the end of the active data.
  67410. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67411. * @param value defines the object to push in the array.
  67412. */
  67413. push(value: T): void;
  67414. /**
  67415. * Pushes a value at the end of the active data.
  67416. * If the data is already present, it won t be added again
  67417. * @param value defines the object to push in the array.
  67418. * @returns true if added false if it was already present
  67419. */
  67420. pushNoDuplicate(value: T): boolean;
  67421. /**
  67422. * Resets the active data to an empty array.
  67423. */
  67424. reset(): void;
  67425. /**
  67426. * Concats the active data with a given array.
  67427. * This ensures no dupplicate will be present in the result.
  67428. * @param array defines the data to concatenate with.
  67429. */
  67430. concatWithNoDuplicate(array: any): void;
  67431. }
  67432. }
  67433. declare module BABYLON {
  67434. /**
  67435. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67436. * separate meshes. This can be use to improve performances.
  67437. * @see http://doc.babylonjs.com/how_to/multi_materials
  67438. */
  67439. export class MultiMaterial extends Material {
  67440. private _subMaterials;
  67441. /**
  67442. * Gets or Sets the list of Materials used within the multi material.
  67443. * They need to be ordered according to the submeshes order in the associated mesh
  67444. */
  67445. subMaterials: Nullable<Material>[];
  67446. /**
  67447. * Function used to align with Node.getChildren()
  67448. * @returns the list of Materials used within the multi material
  67449. */
  67450. getChildren(): Nullable<Material>[];
  67451. /**
  67452. * Instantiates a new Multi Material
  67453. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67454. * separate meshes. This can be use to improve performances.
  67455. * @see http://doc.babylonjs.com/how_to/multi_materials
  67456. * @param name Define the name in the scene
  67457. * @param scene Define the scene the material belongs to
  67458. */
  67459. constructor(name: string, scene: Scene);
  67460. private _hookArray;
  67461. /**
  67462. * Get one of the submaterial by its index in the submaterials array
  67463. * @param index The index to look the sub material at
  67464. * @returns The Material if the index has been defined
  67465. */
  67466. getSubMaterial(index: number): Nullable<Material>;
  67467. /**
  67468. * Get the list of active textures for the whole sub materials list.
  67469. * @returns All the textures that will be used during the rendering
  67470. */
  67471. getActiveTextures(): BaseTexture[];
  67472. /**
  67473. * Gets the current class name of the material e.g. "MultiMaterial"
  67474. * Mainly use in serialization.
  67475. * @returns the class name
  67476. */
  67477. getClassName(): string;
  67478. /**
  67479. * Checks if the material is ready to render the requested sub mesh
  67480. * @param mesh Define the mesh the submesh belongs to
  67481. * @param subMesh Define the sub mesh to look readyness for
  67482. * @param useInstances Define whether or not the material is used with instances
  67483. * @returns true if ready, otherwise false
  67484. */
  67485. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67486. /**
  67487. * Clones the current material and its related sub materials
  67488. * @param name Define the name of the newly cloned material
  67489. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67490. * @returns the cloned material
  67491. */
  67492. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67493. /**
  67494. * Serializes the materials into a JSON representation.
  67495. * @returns the JSON representation
  67496. */
  67497. serialize(): any;
  67498. /**
  67499. * Dispose the material and release its associated resources
  67500. * @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)
  67501. * @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)
  67502. * @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)
  67503. */
  67504. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67505. /**
  67506. * Creates a MultiMaterial from parsed MultiMaterial data.
  67507. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67508. * @param scene defines the hosting scene
  67509. * @returns a new MultiMaterial
  67510. */
  67511. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67512. }
  67513. }
  67514. declare module BABYLON {
  67515. /**
  67516. * Class used to represent data loading progression
  67517. */
  67518. export class SceneLoaderFlags {
  67519. private static _ForceFullSceneLoadingForIncremental;
  67520. private static _ShowLoadingScreen;
  67521. private static _CleanBoneMatrixWeights;
  67522. private static _loggingLevel;
  67523. /**
  67524. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67525. */
  67526. static ForceFullSceneLoadingForIncremental: boolean;
  67527. /**
  67528. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67529. */
  67530. static ShowLoadingScreen: boolean;
  67531. /**
  67532. * Defines the current logging level (while loading the scene)
  67533. * @ignorenaming
  67534. */
  67535. static loggingLevel: number;
  67536. /**
  67537. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67538. */
  67539. static CleanBoneMatrixWeights: boolean;
  67540. }
  67541. }
  67542. declare module BABYLON {
  67543. /**
  67544. * 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.
  67545. * @see https://doc.babylonjs.com/how_to/transformnode
  67546. */
  67547. export class TransformNode extends Node {
  67548. /**
  67549. * Object will not rotate to face the camera
  67550. */
  67551. static BILLBOARDMODE_NONE: number;
  67552. /**
  67553. * Object will rotate to face the camera but only on the x axis
  67554. */
  67555. static BILLBOARDMODE_X: number;
  67556. /**
  67557. * Object will rotate to face the camera but only on the y axis
  67558. */
  67559. static BILLBOARDMODE_Y: number;
  67560. /**
  67561. * Object will rotate to face the camera but only on the z axis
  67562. */
  67563. static BILLBOARDMODE_Z: number;
  67564. /**
  67565. * Object will rotate to face the camera
  67566. */
  67567. static BILLBOARDMODE_ALL: number;
  67568. private _forward;
  67569. private _forwardInverted;
  67570. private _up;
  67571. private _right;
  67572. private _rightInverted;
  67573. private _position;
  67574. private _rotation;
  67575. private _rotationQuaternion;
  67576. protected _scaling: Vector3;
  67577. protected _isDirty: boolean;
  67578. private _transformToBoneReferal;
  67579. private _billboardMode;
  67580. /**
  67581. * Gets or sets the billboard mode. Default is 0.
  67582. *
  67583. * | Value | Type | Description |
  67584. * | --- | --- | --- |
  67585. * | 0 | BILLBOARDMODE_NONE | |
  67586. * | 1 | BILLBOARDMODE_X | |
  67587. * | 2 | BILLBOARDMODE_Y | |
  67588. * | 4 | BILLBOARDMODE_Z | |
  67589. * | 7 | BILLBOARDMODE_ALL | |
  67590. *
  67591. */
  67592. billboardMode: number;
  67593. private _preserveParentRotationForBillboard;
  67594. /**
  67595. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67596. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67597. */
  67598. preserveParentRotationForBillboard: boolean;
  67599. /**
  67600. * 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
  67601. */
  67602. scalingDeterminant: number;
  67603. private _infiniteDistance;
  67604. /**
  67605. * Gets or sets the distance of the object to max, often used by skybox
  67606. */
  67607. infiniteDistance: boolean;
  67608. /**
  67609. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67610. * By default the system will update normals to compensate
  67611. */
  67612. ignoreNonUniformScaling: boolean;
  67613. /**
  67614. * 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
  67615. */
  67616. reIntegrateRotationIntoRotationQuaternion: boolean;
  67617. /** @hidden */
  67618. _poseMatrix: Nullable<Matrix>;
  67619. /** @hidden */
  67620. _localMatrix: Matrix;
  67621. private _usePivotMatrix;
  67622. private _absolutePosition;
  67623. private _pivotMatrix;
  67624. private _pivotMatrixInverse;
  67625. protected _postMultiplyPivotMatrix: boolean;
  67626. protected _isWorldMatrixFrozen: boolean;
  67627. /** @hidden */
  67628. _indexInSceneTransformNodesArray: number;
  67629. /**
  67630. * An event triggered after the world matrix is updated
  67631. */
  67632. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67633. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67634. /**
  67635. * Gets a string identifying the name of the class
  67636. * @returns "TransformNode" string
  67637. */
  67638. getClassName(): string;
  67639. /**
  67640. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67641. */
  67642. position: Vector3;
  67643. /**
  67644. * 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)).
  67645. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67646. */
  67647. rotation: Vector3;
  67648. /**
  67649. * 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)).
  67650. */
  67651. scaling: Vector3;
  67652. /**
  67653. * 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).
  67654. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67655. */
  67656. rotationQuaternion: Nullable<Quaternion>;
  67657. /**
  67658. * The forward direction of that transform in world space.
  67659. */
  67660. readonly forward: Vector3;
  67661. /**
  67662. * The up direction of that transform in world space.
  67663. */
  67664. readonly up: Vector3;
  67665. /**
  67666. * The right direction of that transform in world space.
  67667. */
  67668. readonly right: Vector3;
  67669. /**
  67670. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67671. * @param matrix the matrix to copy the pose from
  67672. * @returns this TransformNode.
  67673. */
  67674. updatePoseMatrix(matrix: Matrix): TransformNode;
  67675. /**
  67676. * Returns the mesh Pose matrix.
  67677. * @returns the pose matrix
  67678. */
  67679. getPoseMatrix(): Matrix;
  67680. /** @hidden */
  67681. _isSynchronized(): boolean;
  67682. /** @hidden */
  67683. _initCache(): void;
  67684. /**
  67685. * Flag the transform node as dirty (Forcing it to update everything)
  67686. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67687. * @returns this transform node
  67688. */
  67689. markAsDirty(property: string): TransformNode;
  67690. /**
  67691. * Returns the current mesh absolute position.
  67692. * Returns a Vector3.
  67693. */
  67694. readonly absolutePosition: Vector3;
  67695. /**
  67696. * Sets a new matrix to apply before all other transformation
  67697. * @param matrix defines the transform matrix
  67698. * @returns the current TransformNode
  67699. */
  67700. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67701. /**
  67702. * Sets a new pivot matrix to the current node
  67703. * @param matrix defines the new pivot matrix to use
  67704. * @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
  67705. * @returns the current TransformNode
  67706. */
  67707. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67708. /**
  67709. * Returns the mesh pivot matrix.
  67710. * Default : Identity.
  67711. * @returns the matrix
  67712. */
  67713. getPivotMatrix(): Matrix;
  67714. /**
  67715. * Prevents the World matrix to be computed any longer.
  67716. * @returns the TransformNode.
  67717. */
  67718. freezeWorldMatrix(): TransformNode;
  67719. /**
  67720. * Allows back the World matrix computation.
  67721. * @returns the TransformNode.
  67722. */
  67723. unfreezeWorldMatrix(): this;
  67724. /**
  67725. * True if the World matrix has been frozen.
  67726. */
  67727. readonly isWorldMatrixFrozen: boolean;
  67728. /**
  67729. * Retuns the mesh absolute position in the World.
  67730. * @returns a Vector3.
  67731. */
  67732. getAbsolutePosition(): Vector3;
  67733. /**
  67734. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67735. * @param absolutePosition the absolute position to set
  67736. * @returns the TransformNode.
  67737. */
  67738. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67739. /**
  67740. * Sets the mesh position in its local space.
  67741. * @param vector3 the position to set in localspace
  67742. * @returns the TransformNode.
  67743. */
  67744. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67745. /**
  67746. * Returns the mesh position in the local space from the current World matrix values.
  67747. * @returns a new Vector3.
  67748. */
  67749. getPositionExpressedInLocalSpace(): Vector3;
  67750. /**
  67751. * Translates the mesh along the passed Vector3 in its local space.
  67752. * @param vector3 the distance to translate in localspace
  67753. * @returns the TransformNode.
  67754. */
  67755. locallyTranslate(vector3: Vector3): TransformNode;
  67756. private static _lookAtVectorCache;
  67757. /**
  67758. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67759. * @param targetPoint the position (must be in same space as current mesh) to look at
  67760. * @param yawCor optional yaw (y-axis) correction in radians
  67761. * @param pitchCor optional pitch (x-axis) correction in radians
  67762. * @param rollCor optional roll (z-axis) correction in radians
  67763. * @param space the choosen space of the target
  67764. * @returns the TransformNode.
  67765. */
  67766. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67767. /**
  67768. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67769. * This Vector3 is expressed in the World space.
  67770. * @param localAxis axis to rotate
  67771. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67772. */
  67773. getDirection(localAxis: Vector3): Vector3;
  67774. /**
  67775. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67776. * localAxis is expressed in the mesh local space.
  67777. * result is computed in the Wordl space from the mesh World matrix.
  67778. * @param localAxis axis to rotate
  67779. * @param result the resulting transformnode
  67780. * @returns this TransformNode.
  67781. */
  67782. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67783. /**
  67784. * Sets this transform node rotation to the given local axis.
  67785. * @param localAxis the axis in local space
  67786. * @param yawCor optional yaw (y-axis) correction in radians
  67787. * @param pitchCor optional pitch (x-axis) correction in radians
  67788. * @param rollCor optional roll (z-axis) correction in radians
  67789. * @returns this TransformNode
  67790. */
  67791. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67792. /**
  67793. * Sets a new pivot point to the current node
  67794. * @param point defines the new pivot point to use
  67795. * @param space defines if the point is in world or local space (local by default)
  67796. * @returns the current TransformNode
  67797. */
  67798. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67799. /**
  67800. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67801. * @returns the pivot point
  67802. */
  67803. getPivotPoint(): Vector3;
  67804. /**
  67805. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67806. * @param result the vector3 to store the result
  67807. * @returns this TransformNode.
  67808. */
  67809. getPivotPointToRef(result: Vector3): TransformNode;
  67810. /**
  67811. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67812. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67813. */
  67814. getAbsolutePivotPoint(): Vector3;
  67815. /**
  67816. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67817. * @param result vector3 to store the result
  67818. * @returns this TransformNode.
  67819. */
  67820. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67821. /**
  67822. * Defines the passed node as the parent of the current node.
  67823. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67824. * @see https://doc.babylonjs.com/how_to/parenting
  67825. * @param node the node ot set as the parent
  67826. * @returns this TransformNode.
  67827. */
  67828. setParent(node: Nullable<Node>): TransformNode;
  67829. private _nonUniformScaling;
  67830. /**
  67831. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67832. */
  67833. readonly nonUniformScaling: boolean;
  67834. /** @hidden */
  67835. _updateNonUniformScalingState(value: boolean): boolean;
  67836. /**
  67837. * Attach the current TransformNode to another TransformNode associated with a bone
  67838. * @param bone Bone affecting the TransformNode
  67839. * @param affectedTransformNode TransformNode associated with the bone
  67840. * @returns this object
  67841. */
  67842. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67843. /**
  67844. * Detach the transform node if its associated with a bone
  67845. * @returns this object
  67846. */
  67847. detachFromBone(): TransformNode;
  67848. private static _rotationAxisCache;
  67849. /**
  67850. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67851. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67852. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67853. * The passed axis is also normalized.
  67854. * @param axis the axis to rotate around
  67855. * @param amount the amount to rotate in radians
  67856. * @param space Space to rotate in (Default: local)
  67857. * @returns the TransformNode.
  67858. */
  67859. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67860. /**
  67861. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67862. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67863. * The passed axis is also normalized. .
  67864. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67865. * @param point the point to rotate around
  67866. * @param axis the axis to rotate around
  67867. * @param amount the amount to rotate in radians
  67868. * @returns the TransformNode
  67869. */
  67870. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67871. /**
  67872. * Translates the mesh along the axis vector for the passed distance in the given space.
  67873. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67874. * @param axis the axis to translate in
  67875. * @param distance the distance to translate
  67876. * @param space Space to rotate in (Default: local)
  67877. * @returns the TransformNode.
  67878. */
  67879. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67880. /**
  67881. * Adds a rotation step to the mesh current rotation.
  67882. * x, y, z are Euler angles expressed in radians.
  67883. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67884. * This means this rotation is made in the mesh local space only.
  67885. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67886. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67887. * ```javascript
  67888. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67889. * ```
  67890. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67891. * 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.
  67892. * @param x Rotation to add
  67893. * @param y Rotation to add
  67894. * @param z Rotation to add
  67895. * @returns the TransformNode.
  67896. */
  67897. addRotation(x: number, y: number, z: number): TransformNode;
  67898. /**
  67899. * @hidden
  67900. */
  67901. protected _getEffectiveParent(): Nullable<Node>;
  67902. /**
  67903. * Computes the world matrix of the node
  67904. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67905. * @returns the world matrix
  67906. */
  67907. computeWorldMatrix(force?: boolean): Matrix;
  67908. protected _afterComputeWorldMatrix(): void;
  67909. /**
  67910. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67911. * @param func callback function to add
  67912. *
  67913. * @returns the TransformNode.
  67914. */
  67915. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67916. /**
  67917. * Removes a registered callback function.
  67918. * @param func callback function to remove
  67919. * @returns the TransformNode.
  67920. */
  67921. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67922. /**
  67923. * Gets the position of the current mesh in camera space
  67924. * @param camera defines the camera to use
  67925. * @returns a position
  67926. */
  67927. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67928. /**
  67929. * Returns the distance from the mesh to the active camera
  67930. * @param camera defines the camera to use
  67931. * @returns the distance
  67932. */
  67933. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67934. /**
  67935. * Clone the current transform node
  67936. * @param name Name of the new clone
  67937. * @param newParent New parent for the clone
  67938. * @param doNotCloneChildren Do not clone children hierarchy
  67939. * @returns the new transform node
  67940. */
  67941. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67942. /**
  67943. * Serializes the objects information.
  67944. * @param currentSerializationObject defines the object to serialize in
  67945. * @returns the serialized object
  67946. */
  67947. serialize(currentSerializationObject?: any): any;
  67948. /**
  67949. * Returns a new TransformNode object parsed from the source provided.
  67950. * @param parsedTransformNode is the source.
  67951. * @param scene the scne the object belongs to
  67952. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67953. * @returns a new TransformNode object parsed from the source provided.
  67954. */
  67955. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67956. /**
  67957. * Get all child-transformNodes of this node
  67958. * @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
  67959. * @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
  67960. * @returns an array of TransformNode
  67961. */
  67962. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67963. /**
  67964. * Releases resources associated with this transform node.
  67965. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67966. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67967. */
  67968. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67969. }
  67970. }
  67971. declare module BABYLON {
  67972. /**
  67973. * Class used to override all child animations of a given target
  67974. */
  67975. export class AnimationPropertiesOverride {
  67976. /**
  67977. * Gets or sets a value indicating if animation blending must be used
  67978. */
  67979. enableBlending: boolean;
  67980. /**
  67981. * Gets or sets the blending speed to use when enableBlending is true
  67982. */
  67983. blendingSpeed: number;
  67984. /**
  67985. * Gets or sets the default loop mode to use
  67986. */
  67987. loopMode: number;
  67988. }
  67989. }
  67990. declare module BABYLON {
  67991. /**
  67992. * Class used to store bone information
  67993. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67994. */
  67995. export class Bone extends Node {
  67996. /**
  67997. * defines the bone name
  67998. */
  67999. name: string;
  68000. private static _tmpVecs;
  68001. private static _tmpQuat;
  68002. private static _tmpMats;
  68003. /**
  68004. * Gets the list of child bones
  68005. */
  68006. children: Bone[];
  68007. /** Gets the animations associated with this bone */
  68008. animations: Animation[];
  68009. /**
  68010. * Gets or sets bone length
  68011. */
  68012. length: number;
  68013. /**
  68014. * @hidden Internal only
  68015. * Set this value to map this bone to a different index in the transform matrices
  68016. * Set this value to -1 to exclude the bone from the transform matrices
  68017. */
  68018. _index: Nullable<number>;
  68019. private _skeleton;
  68020. private _localMatrix;
  68021. private _restPose;
  68022. private _baseMatrix;
  68023. private _absoluteTransform;
  68024. private _invertedAbsoluteTransform;
  68025. private _parent;
  68026. private _scalingDeterminant;
  68027. private _worldTransform;
  68028. private _localScaling;
  68029. private _localRotation;
  68030. private _localPosition;
  68031. private _needToDecompose;
  68032. private _needToCompose;
  68033. /** @hidden */
  68034. _linkedTransformNode: Nullable<TransformNode>;
  68035. /** @hidden */
  68036. _waitingTransformNodeId: Nullable<string>;
  68037. /** @hidden */
  68038. /** @hidden */
  68039. _matrix: Matrix;
  68040. /**
  68041. * Create a new bone
  68042. * @param name defines the bone name
  68043. * @param skeleton defines the parent skeleton
  68044. * @param parentBone defines the parent (can be null if the bone is the root)
  68045. * @param localMatrix defines the local matrix
  68046. * @param restPose defines the rest pose matrix
  68047. * @param baseMatrix defines the base matrix
  68048. * @param index defines index of the bone in the hiearchy
  68049. */
  68050. constructor(
  68051. /**
  68052. * defines the bone name
  68053. */
  68054. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  68055. /**
  68056. * Gets the current object class name.
  68057. * @return the class name
  68058. */
  68059. getClassName(): string;
  68060. /**
  68061. * Gets the parent skeleton
  68062. * @returns a skeleton
  68063. */
  68064. getSkeleton(): Skeleton;
  68065. /**
  68066. * Gets parent bone
  68067. * @returns a bone or null if the bone is the root of the bone hierarchy
  68068. */
  68069. getParent(): Nullable<Bone>;
  68070. /**
  68071. * Returns an array containing the root bones
  68072. * @returns an array containing the root bones
  68073. */
  68074. getChildren(): Array<Bone>;
  68075. /**
  68076. * Sets the parent bone
  68077. * @param parent defines the parent (can be null if the bone is the root)
  68078. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68079. */
  68080. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  68081. /**
  68082. * Gets the local matrix
  68083. * @returns a matrix
  68084. */
  68085. getLocalMatrix(): Matrix;
  68086. /**
  68087. * Gets the base matrix (initial matrix which remains unchanged)
  68088. * @returns a matrix
  68089. */
  68090. getBaseMatrix(): Matrix;
  68091. /**
  68092. * Gets the rest pose matrix
  68093. * @returns a matrix
  68094. */
  68095. getRestPose(): Matrix;
  68096. /**
  68097. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  68098. */
  68099. getWorldMatrix(): Matrix;
  68100. /**
  68101. * Sets the local matrix to rest pose matrix
  68102. */
  68103. returnToRest(): void;
  68104. /**
  68105. * Gets the inverse of the absolute transform matrix.
  68106. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  68107. * @returns a matrix
  68108. */
  68109. getInvertedAbsoluteTransform(): Matrix;
  68110. /**
  68111. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  68112. * @returns a matrix
  68113. */
  68114. getAbsoluteTransform(): Matrix;
  68115. /**
  68116. * Links with the given transform node.
  68117. * The local matrix of this bone is copied from the transform node every frame.
  68118. * @param transformNode defines the transform node to link to
  68119. */
  68120. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  68121. /** Gets or sets current position (in local space) */
  68122. position: Vector3;
  68123. /** Gets or sets current rotation (in local space) */
  68124. rotation: Vector3;
  68125. /** Gets or sets current rotation quaternion (in local space) */
  68126. rotationQuaternion: Quaternion;
  68127. /** Gets or sets current scaling (in local space) */
  68128. scaling: Vector3;
  68129. /**
  68130. * Gets the animation properties override
  68131. */
  68132. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68133. private _decompose;
  68134. private _compose;
  68135. /**
  68136. * Update the base and local matrices
  68137. * @param matrix defines the new base or local matrix
  68138. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68139. * @param updateLocalMatrix defines if the local matrix should be updated
  68140. */
  68141. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68142. /** @hidden */
  68143. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68144. /**
  68145. * Flag the bone as dirty (Forcing it to update everything)
  68146. */
  68147. markAsDirty(): void;
  68148. private _markAsDirtyAndCompose;
  68149. private _markAsDirtyAndDecompose;
  68150. /**
  68151. * Translate the bone in local or world space
  68152. * @param vec The amount to translate the bone
  68153. * @param space The space that the translation is in
  68154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68155. */
  68156. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68157. /**
  68158. * Set the postion of the bone in local or world space
  68159. * @param position The position to set the bone
  68160. * @param space The space that the position is in
  68161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68162. */
  68163. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68164. /**
  68165. * Set the absolute position of the bone (world space)
  68166. * @param position The position to set the bone
  68167. * @param mesh The mesh that this bone is attached to
  68168. */
  68169. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68170. /**
  68171. * Scale the bone on the x, y and z axes (in local space)
  68172. * @param x The amount to scale the bone on the x axis
  68173. * @param y The amount to scale the bone on the y axis
  68174. * @param z The amount to scale the bone on the z axis
  68175. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68176. */
  68177. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68178. /**
  68179. * Set the bone scaling in local space
  68180. * @param scale defines the scaling vector
  68181. */
  68182. setScale(scale: Vector3): void;
  68183. /**
  68184. * Gets the current scaling in local space
  68185. * @returns the current scaling vector
  68186. */
  68187. getScale(): Vector3;
  68188. /**
  68189. * Gets the current scaling in local space and stores it in a target vector
  68190. * @param result defines the target vector
  68191. */
  68192. getScaleToRef(result: Vector3): void;
  68193. /**
  68194. * Set the yaw, pitch, and roll of the bone in local or world space
  68195. * @param yaw The rotation of the bone on the y axis
  68196. * @param pitch The rotation of the bone on the x axis
  68197. * @param roll The rotation of the bone on the z axis
  68198. * @param space The space that the axes of rotation are in
  68199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68200. */
  68201. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68202. /**
  68203. * Add a rotation to the bone on an axis in local or world space
  68204. * @param axis The axis to rotate the bone on
  68205. * @param amount The amount to rotate the bone
  68206. * @param space The space that the axis is in
  68207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68208. */
  68209. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68210. /**
  68211. * Set the rotation of the bone to a particular axis angle in local or world space
  68212. * @param axis The axis to rotate the bone on
  68213. * @param angle The angle that the bone should be rotated to
  68214. * @param space The space that the axis is in
  68215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68216. */
  68217. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68218. /**
  68219. * Set the euler rotation of the bone in local of world space
  68220. * @param rotation The euler rotation that the bone should be set to
  68221. * @param space The space that the rotation is in
  68222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68223. */
  68224. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68225. /**
  68226. * Set the quaternion rotation of the bone in local of world space
  68227. * @param quat The quaternion rotation that the bone should be set to
  68228. * @param space The space that the rotation is in
  68229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68230. */
  68231. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68232. /**
  68233. * Set the rotation matrix of the bone in local of world space
  68234. * @param rotMat The rotation matrix that the bone should be set to
  68235. * @param space The space that the rotation is in
  68236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68237. */
  68238. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68239. private _rotateWithMatrix;
  68240. private _getNegativeRotationToRef;
  68241. /**
  68242. * Get the position of the bone in local or world space
  68243. * @param space The space that the returned position is in
  68244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68245. * @returns The position of the bone
  68246. */
  68247. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68248. /**
  68249. * Copy the position of the bone to a vector3 in local or world space
  68250. * @param space The space that the returned position is in
  68251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68252. * @param result The vector3 to copy the position to
  68253. */
  68254. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68255. /**
  68256. * Get the absolute position of the bone (world space)
  68257. * @param mesh The mesh that this bone is attached to
  68258. * @returns The absolute position of the bone
  68259. */
  68260. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68261. /**
  68262. * Copy the absolute position of the bone (world space) to the result param
  68263. * @param mesh The mesh that this bone is attached to
  68264. * @param result The vector3 to copy the absolute position to
  68265. */
  68266. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68267. /**
  68268. * Compute the absolute transforms of this bone and its children
  68269. */
  68270. computeAbsoluteTransforms(): void;
  68271. /**
  68272. * Get the world direction from an axis that is in the local space of the bone
  68273. * @param localAxis The local direction that is used to compute the world direction
  68274. * @param mesh The mesh that this bone is attached to
  68275. * @returns The world direction
  68276. */
  68277. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68278. /**
  68279. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68280. * @param localAxis The local direction that is used to compute the world direction
  68281. * @param mesh The mesh that this bone is attached to
  68282. * @param result The vector3 that the world direction will be copied to
  68283. */
  68284. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68285. /**
  68286. * Get the euler rotation of the bone in local or world space
  68287. * @param space The space that the rotation should be in
  68288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68289. * @returns The euler rotation
  68290. */
  68291. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68292. /**
  68293. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68294. * @param space The space that the rotation should be in
  68295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68296. * @param result The vector3 that the rotation should be copied to
  68297. */
  68298. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68299. /**
  68300. * Get the quaternion rotation of the bone in either local or world space
  68301. * @param space The space that the rotation should be in
  68302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68303. * @returns The quaternion rotation
  68304. */
  68305. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68306. /**
  68307. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68308. * @param space The space that the rotation should be in
  68309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68310. * @param result The quaternion that the rotation should be copied to
  68311. */
  68312. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68313. /**
  68314. * Get the rotation matrix of the bone in local or world space
  68315. * @param space The space that the rotation should be in
  68316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68317. * @returns The rotation matrix
  68318. */
  68319. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68320. /**
  68321. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68322. * @param space The space that the rotation should be in
  68323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68324. * @param result The quaternion that the rotation should be copied to
  68325. */
  68326. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68327. /**
  68328. * Get the world position of a point that is in the local space of the bone
  68329. * @param position The local position
  68330. * @param mesh The mesh that this bone is attached to
  68331. * @returns The world position
  68332. */
  68333. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68334. /**
  68335. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68336. * @param position The local position
  68337. * @param mesh The mesh that this bone is attached to
  68338. * @param result The vector3 that the world position should be copied to
  68339. */
  68340. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68341. /**
  68342. * Get the local position of a point that is in world space
  68343. * @param position The world position
  68344. * @param mesh The mesh that this bone is attached to
  68345. * @returns The local position
  68346. */
  68347. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68348. /**
  68349. * Get the local position of a point that is in world space and copy it to the result param
  68350. * @param position The world position
  68351. * @param mesh The mesh that this bone is attached to
  68352. * @param result The vector3 that the local position should be copied to
  68353. */
  68354. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68355. }
  68356. }
  68357. declare module BABYLON {
  68358. /**
  68359. * Enum that determines the text-wrapping mode to use.
  68360. */
  68361. export enum InspectableType {
  68362. /**
  68363. * Checkbox for booleans
  68364. */
  68365. Checkbox = 0,
  68366. /**
  68367. * Sliders for numbers
  68368. */
  68369. Slider = 1,
  68370. /**
  68371. * Vector3
  68372. */
  68373. Vector3 = 2,
  68374. /**
  68375. * Quaternions
  68376. */
  68377. Quaternion = 3,
  68378. /**
  68379. * Color3
  68380. */
  68381. Color3 = 4
  68382. }
  68383. /**
  68384. * Interface used to define custom inspectable properties.
  68385. * This interface is used by the inspector to display custom property grids
  68386. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68387. */
  68388. export interface IInspectable {
  68389. /**
  68390. * Gets the label to display
  68391. */
  68392. label: string;
  68393. /**
  68394. * Gets the name of the property to edit
  68395. */
  68396. propertyName: string;
  68397. /**
  68398. * Gets the type of the editor to use
  68399. */
  68400. type: InspectableType;
  68401. /**
  68402. * Gets the minimum value of the property when using in "slider" mode
  68403. */
  68404. min?: number;
  68405. /**
  68406. * Gets the maximum value of the property when using in "slider" mode
  68407. */
  68408. max?: number;
  68409. /**
  68410. * Gets the setp to use when using in "slider" mode
  68411. */
  68412. step?: number;
  68413. }
  68414. }
  68415. declare module BABYLON {
  68416. /**
  68417. * This represents the required contract to create a new type of texture loader.
  68418. */
  68419. export interface IInternalTextureLoader {
  68420. /**
  68421. * Defines wether the loader supports cascade loading the different faces.
  68422. */
  68423. supportCascades: boolean;
  68424. /**
  68425. * This returns if the loader support the current file information.
  68426. * @param extension defines the file extension of the file being loaded
  68427. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68428. * @param fallback defines the fallback internal texture if any
  68429. * @param isBase64 defines whether the texture is encoded as a base64
  68430. * @param isBuffer defines whether the texture data are stored as a buffer
  68431. * @returns true if the loader can load the specified file
  68432. */
  68433. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68434. /**
  68435. * Transform the url before loading if required.
  68436. * @param rootUrl the url of the texture
  68437. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68438. * @returns the transformed texture
  68439. */
  68440. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68441. /**
  68442. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68443. * @param rootUrl the url of the texture
  68444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68445. * @returns the fallback texture
  68446. */
  68447. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68448. /**
  68449. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68450. * @param data contains the texture data
  68451. * @param texture defines the BabylonJS internal texture
  68452. * @param createPolynomials will be true if polynomials have been requested
  68453. * @param onLoad defines the callback to trigger once the texture is ready
  68454. * @param onError defines the callback to trigger in case of error
  68455. */
  68456. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68457. /**
  68458. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68459. * @param data contains the texture data
  68460. * @param texture defines the BabylonJS internal texture
  68461. * @param callback defines the method to call once ready to upload
  68462. */
  68463. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68464. }
  68465. }
  68466. declare module BABYLON {
  68467. interface Engine {
  68468. /**
  68469. * Creates a depth stencil cube texture.
  68470. * This is only available in WebGL 2.
  68471. * @param size The size of face edge in the cube texture.
  68472. * @param options The options defining the cube texture.
  68473. * @returns The cube texture
  68474. */
  68475. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68476. /**
  68477. * Creates a cube texture
  68478. * @param rootUrl defines the url where the files to load is located
  68479. * @param scene defines the current scene
  68480. * @param files defines the list of files to load (1 per face)
  68481. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68482. * @param onLoad defines an optional callback raised when the texture is loaded
  68483. * @param onError defines an optional callback raised if there is an issue to load the texture
  68484. * @param format defines the format of the data
  68485. * @param forcedExtension defines the extension to use to pick the right loader
  68486. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68487. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68488. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68489. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68490. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68491. * @returns the cube texture as an InternalTexture
  68492. */
  68493. 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;
  68494. /**
  68495. * Creates a cube texture
  68496. * @param rootUrl defines the url where the files to load is located
  68497. * @param scene defines the current scene
  68498. * @param files defines the list of files to load (1 per face)
  68499. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68500. * @param onLoad defines an optional callback raised when the texture is loaded
  68501. * @param onError defines an optional callback raised if there is an issue to load the texture
  68502. * @param format defines the format of the data
  68503. * @param forcedExtension defines the extension to use to pick the right loader
  68504. * @returns the cube texture as an InternalTexture
  68505. */
  68506. 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;
  68507. /**
  68508. * Creates a cube texture
  68509. * @param rootUrl defines the url where the files to load is located
  68510. * @param scene defines the current scene
  68511. * @param files defines the list of files to load (1 per face)
  68512. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68513. * @param onLoad defines an optional callback raised when the texture is loaded
  68514. * @param onError defines an optional callback raised if there is an issue to load the texture
  68515. * @param format defines the format of the data
  68516. * @param forcedExtension defines the extension to use to pick the right loader
  68517. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68518. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68519. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68520. * @returns the cube texture as an InternalTexture
  68521. */
  68522. 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;
  68523. /** @hidden */
  68524. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68525. /** @hidden */
  68526. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68527. /** @hidden */
  68528. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68529. /** @hidden */
  68530. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68531. }
  68532. }
  68533. declare module BABYLON {
  68534. /**
  68535. * Class for creating a cube texture
  68536. */
  68537. export class CubeTexture extends BaseTexture {
  68538. private _delayedOnLoad;
  68539. /**
  68540. * The url of the texture
  68541. */
  68542. url: string;
  68543. /**
  68544. * Gets or sets the center of the bounding box associated with the cube texture.
  68545. * It must define where the camera used to render the texture was set
  68546. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68547. */
  68548. boundingBoxPosition: Vector3;
  68549. private _boundingBoxSize;
  68550. /**
  68551. * Gets or sets the size of the bounding box associated with the cube texture
  68552. * When defined, the cubemap will switch to local mode
  68553. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68554. * @example https://www.babylonjs-playground.com/#RNASML
  68555. */
  68556. /**
  68557. * Returns the bounding box size
  68558. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68559. */
  68560. boundingBoxSize: Vector3;
  68561. protected _rotationY: number;
  68562. /**
  68563. * Sets texture matrix rotation angle around Y axis in radians.
  68564. */
  68565. /**
  68566. * Gets texture matrix rotation angle around Y axis radians.
  68567. */
  68568. rotationY: number;
  68569. /**
  68570. * Are mip maps generated for this texture or not.
  68571. */
  68572. readonly noMipmap: boolean;
  68573. private _noMipmap;
  68574. private _files;
  68575. private _extensions;
  68576. private _textureMatrix;
  68577. private _format;
  68578. private _createPolynomials;
  68579. /** @hidden */
  68580. _prefiltered: boolean;
  68581. /**
  68582. * Creates a cube texture from an array of image urls
  68583. * @param files defines an array of image urls
  68584. * @param scene defines the hosting scene
  68585. * @param noMipmap specifies if mip maps are not used
  68586. * @returns a cube texture
  68587. */
  68588. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68589. /**
  68590. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68591. * @param url defines the url of the prefiltered texture
  68592. * @param scene defines the scene the texture is attached to
  68593. * @param forcedExtension defines the extension of the file if different from the url
  68594. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68595. * @return the prefiltered texture
  68596. */
  68597. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68598. /**
  68599. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68600. * as prefiltered data.
  68601. * @param rootUrl defines the url of the texture or the root name of the six images
  68602. * @param scene defines the scene the texture is attached to
  68603. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68604. * @param noMipmap defines if mipmaps should be created or not
  68605. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68606. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68607. * @param onError defines a callback triggered in case of error during load
  68608. * @param format defines the internal format to use for the texture once loaded
  68609. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68610. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68611. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68612. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68613. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68614. * @return the cube texture
  68615. */
  68616. 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);
  68617. /**
  68618. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68619. */
  68620. readonly isPrefiltered: boolean;
  68621. /**
  68622. * Get the current class name of the texture useful for serialization or dynamic coding.
  68623. * @returns "CubeTexture"
  68624. */
  68625. getClassName(): string;
  68626. /**
  68627. * Update the url (and optional buffer) of this texture if url was null during construction.
  68628. * @param url the url of the texture
  68629. * @param forcedExtension defines the extension to use
  68630. * @param onLoad callback called when the texture is loaded (defaults to null)
  68631. */
  68632. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68633. /**
  68634. * Delays loading of the cube texture
  68635. * @param forcedExtension defines the extension to use
  68636. */
  68637. delayLoad(forcedExtension?: string): void;
  68638. /**
  68639. * Returns the reflection texture matrix
  68640. * @returns the reflection texture matrix
  68641. */
  68642. getReflectionTextureMatrix(): Matrix;
  68643. /**
  68644. * Sets the reflection texture matrix
  68645. * @param value Reflection texture matrix
  68646. */
  68647. setReflectionTextureMatrix(value: Matrix): void;
  68648. /**
  68649. * Parses text to create a cube texture
  68650. * @param parsedTexture define the serialized text to read from
  68651. * @param scene defines the hosting scene
  68652. * @param rootUrl defines the root url of the cube texture
  68653. * @returns a cube texture
  68654. */
  68655. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68656. /**
  68657. * Makes a clone, or deep copy, of the cube texture
  68658. * @returns a new cube texture
  68659. */
  68660. clone(): CubeTexture;
  68661. }
  68662. }
  68663. declare module BABYLON {
  68664. /** @hidden */
  68665. export var postprocessVertexShader: {
  68666. name: string;
  68667. shader: string;
  68668. };
  68669. }
  68670. declare module BABYLON {
  68671. /**
  68672. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68673. * This is the base of the follow, arc rotate cameras and Free camera
  68674. * @see http://doc.babylonjs.com/features/cameras
  68675. */
  68676. export class TargetCamera extends Camera {
  68677. private static _RigCamTransformMatrix;
  68678. private static _TargetTransformMatrix;
  68679. private static _TargetFocalPoint;
  68680. /**
  68681. * Define the current direction the camera is moving to
  68682. */
  68683. cameraDirection: Vector3;
  68684. /**
  68685. * Define the current rotation the camera is rotating to
  68686. */
  68687. cameraRotation: Vector2;
  68688. /**
  68689. * When set, the up vector of the camera will be updated by the rotation of the camera
  68690. */
  68691. updateUpVectorFromRotation: boolean;
  68692. private _tmpQuaternion;
  68693. /**
  68694. * Define the current rotation of the camera
  68695. */
  68696. rotation: Vector3;
  68697. /**
  68698. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68699. */
  68700. rotationQuaternion: Quaternion;
  68701. /**
  68702. * Define the current speed of the camera
  68703. */
  68704. speed: number;
  68705. /**
  68706. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68707. * around all axis.
  68708. */
  68709. noRotationConstraint: boolean;
  68710. /**
  68711. * Define the current target of the camera as an object or a position.
  68712. */
  68713. lockedTarget: any;
  68714. /** @hidden */
  68715. _currentTarget: Vector3;
  68716. /** @hidden */
  68717. _initialFocalDistance: number;
  68718. /** @hidden */
  68719. _viewMatrix: Matrix;
  68720. /** @hidden */
  68721. _camMatrix: Matrix;
  68722. /** @hidden */
  68723. _cameraTransformMatrix: Matrix;
  68724. /** @hidden */
  68725. _cameraRotationMatrix: Matrix;
  68726. /** @hidden */
  68727. _referencePoint: Vector3;
  68728. /** @hidden */
  68729. _transformedReferencePoint: Vector3;
  68730. protected _globalCurrentTarget: Vector3;
  68731. protected _globalCurrentUpVector: Vector3;
  68732. /** @hidden */
  68733. _reset: () => void;
  68734. private _defaultUp;
  68735. /**
  68736. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68737. * This is the base of the follow, arc rotate cameras and Free camera
  68738. * @see http://doc.babylonjs.com/features/cameras
  68739. * @param name Defines the name of the camera in the scene
  68740. * @param position Defines the start position of the camera in the scene
  68741. * @param scene Defines the scene the camera belongs to
  68742. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68743. */
  68744. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68745. /**
  68746. * Gets the position in front of the camera at a given distance.
  68747. * @param distance The distance from the camera we want the position to be
  68748. * @returns the position
  68749. */
  68750. getFrontPosition(distance: number): Vector3;
  68751. /** @hidden */
  68752. _getLockedTargetPosition(): Nullable<Vector3>;
  68753. private _storedPosition;
  68754. private _storedRotation;
  68755. private _storedRotationQuaternion;
  68756. /**
  68757. * Store current camera state of the camera (fov, position, rotation, etc..)
  68758. * @returns the camera
  68759. */
  68760. storeState(): Camera;
  68761. /**
  68762. * Restored camera state. You must call storeState() first
  68763. * @returns whether it was successful or not
  68764. * @hidden
  68765. */
  68766. _restoreStateValues(): boolean;
  68767. /** @hidden */
  68768. _initCache(): void;
  68769. /** @hidden */
  68770. _updateCache(ignoreParentClass?: boolean): void;
  68771. /** @hidden */
  68772. _isSynchronizedViewMatrix(): boolean;
  68773. /** @hidden */
  68774. _computeLocalCameraSpeed(): number;
  68775. /**
  68776. * Defines the target the camera should look at.
  68777. * This will automatically adapt alpha beta and radius to fit within the new target.
  68778. * @param target Defines the new target as a Vector or a mesh
  68779. */
  68780. setTarget(target: Vector3): void;
  68781. /**
  68782. * Return the current target position of the camera. This value is expressed in local space.
  68783. * @returns the target position
  68784. */
  68785. getTarget(): Vector3;
  68786. /** @hidden */
  68787. _decideIfNeedsToMove(): boolean;
  68788. /** @hidden */
  68789. _updatePosition(): void;
  68790. /** @hidden */
  68791. _checkInputs(): void;
  68792. protected _updateCameraRotationMatrix(): void;
  68793. /**
  68794. * 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)
  68795. * @returns the current camera
  68796. */
  68797. private _rotateUpVectorWithCameraRotationMatrix;
  68798. private _cachedRotationZ;
  68799. private _cachedQuaternionRotationZ;
  68800. /** @hidden */
  68801. _getViewMatrix(): Matrix;
  68802. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68803. /**
  68804. * @hidden
  68805. */
  68806. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68807. /**
  68808. * @hidden
  68809. */
  68810. _updateRigCameras(): void;
  68811. private _getRigCamPositionAndTarget;
  68812. /**
  68813. * Gets the current object class name.
  68814. * @return the class name
  68815. */
  68816. getClassName(): string;
  68817. }
  68818. }
  68819. declare module BABYLON {
  68820. /**
  68821. * @ignore
  68822. * This is a list of all the different input types that are available in the application.
  68823. * Fo instance: ArcRotateCameraGamepadInput...
  68824. */
  68825. export var CameraInputTypes: {};
  68826. /**
  68827. * This is the contract to implement in order to create a new input class.
  68828. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68829. */
  68830. export interface ICameraInput<TCamera extends Camera> {
  68831. /**
  68832. * Defines the camera the input is attached to.
  68833. */
  68834. camera: Nullable<TCamera>;
  68835. /**
  68836. * Gets the class name of the current intput.
  68837. * @returns the class name
  68838. */
  68839. getClassName(): string;
  68840. /**
  68841. * Get the friendly name associated with the input class.
  68842. * @returns the input friendly name
  68843. */
  68844. getSimpleName(): string;
  68845. /**
  68846. * Attach the input controls to a specific dom element to get the input from.
  68847. * @param element Defines the element the controls should be listened from
  68848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68849. */
  68850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68851. /**
  68852. * Detach the current controls from the specified dom element.
  68853. * @param element Defines the element to stop listening the inputs from
  68854. */
  68855. detachControl(element: Nullable<HTMLElement>): void;
  68856. /**
  68857. * Update the current camera state depending on the inputs that have been used this frame.
  68858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68859. */
  68860. checkInputs?: () => void;
  68861. }
  68862. /**
  68863. * Represents a map of input types to input instance or input index to input instance.
  68864. */
  68865. export interface CameraInputsMap<TCamera extends Camera> {
  68866. /**
  68867. * Accessor to the input by input type.
  68868. */
  68869. [name: string]: ICameraInput<TCamera>;
  68870. /**
  68871. * Accessor to the input by input index.
  68872. */
  68873. [idx: number]: ICameraInput<TCamera>;
  68874. }
  68875. /**
  68876. * This represents the input manager used within a camera.
  68877. * It helps dealing with all the different kind of input attached to a camera.
  68878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68879. */
  68880. export class CameraInputsManager<TCamera extends Camera> {
  68881. /**
  68882. * Defines the list of inputs attahed to the camera.
  68883. */
  68884. attached: CameraInputsMap<TCamera>;
  68885. /**
  68886. * Defines the dom element the camera is collecting inputs from.
  68887. * This is null if the controls have not been attached.
  68888. */
  68889. attachedElement: Nullable<HTMLElement>;
  68890. /**
  68891. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68892. */
  68893. noPreventDefault: boolean;
  68894. /**
  68895. * Defined the camera the input manager belongs to.
  68896. */
  68897. camera: TCamera;
  68898. /**
  68899. * Update the current camera state depending on the inputs that have been used this frame.
  68900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68901. */
  68902. checkInputs: () => void;
  68903. /**
  68904. * Instantiate a new Camera Input Manager.
  68905. * @param camera Defines the camera the input manager blongs to
  68906. */
  68907. constructor(camera: TCamera);
  68908. /**
  68909. * Add an input method to a camera
  68910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68911. * @param input camera input method
  68912. */
  68913. add(input: ICameraInput<TCamera>): void;
  68914. /**
  68915. * Remove a specific input method from a camera
  68916. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68917. * @param inputToRemove camera input method
  68918. */
  68919. remove(inputToRemove: ICameraInput<TCamera>): void;
  68920. /**
  68921. * Remove a specific input type from a camera
  68922. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68923. * @param inputType the type of the input to remove
  68924. */
  68925. removeByType(inputType: string): void;
  68926. private _addCheckInputs;
  68927. /**
  68928. * Attach the input controls to the currently attached dom element to listen the events from.
  68929. * @param input Defines the input to attach
  68930. */
  68931. attachInput(input: ICameraInput<TCamera>): void;
  68932. /**
  68933. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68934. * @param element Defines the dom element to collect the events from
  68935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68936. */
  68937. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68938. /**
  68939. * Detach the current manager inputs controls from a specific dom element.
  68940. * @param element Defines the dom element to collect the events from
  68941. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68942. */
  68943. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68944. /**
  68945. * Rebuild the dynamic inputCheck function from the current list of
  68946. * defined inputs in the manager.
  68947. */
  68948. rebuildInputCheck(): void;
  68949. /**
  68950. * Remove all attached input methods from a camera
  68951. */
  68952. clear(): void;
  68953. /**
  68954. * Serialize the current input manager attached to a camera.
  68955. * This ensures than once parsed,
  68956. * the input associated to the camera will be identical to the current ones
  68957. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68958. */
  68959. serialize(serializedCamera: any): void;
  68960. /**
  68961. * Parses an input manager serialized JSON to restore the previous list of inputs
  68962. * and states associated to a camera.
  68963. * @param parsedCamera Defines the JSON to parse
  68964. */
  68965. parse(parsedCamera: any): void;
  68966. }
  68967. }
  68968. declare module BABYLON {
  68969. /**
  68970. * Gather the list of keyboard event types as constants.
  68971. */
  68972. export class KeyboardEventTypes {
  68973. /**
  68974. * The keydown event is fired when a key becomes active (pressed).
  68975. */
  68976. static readonly KEYDOWN: number;
  68977. /**
  68978. * The keyup event is fired when a key has been released.
  68979. */
  68980. static readonly KEYUP: number;
  68981. }
  68982. /**
  68983. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68984. */
  68985. export class KeyboardInfo {
  68986. /**
  68987. * Defines the type of event (KeyboardEventTypes)
  68988. */
  68989. type: number;
  68990. /**
  68991. * Defines the related dom event
  68992. */
  68993. event: KeyboardEvent;
  68994. /**
  68995. * Instantiates a new keyboard info.
  68996. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68997. * @param type Defines the type of event (KeyboardEventTypes)
  68998. * @param event Defines the related dom event
  68999. */
  69000. constructor(
  69001. /**
  69002. * Defines the type of event (KeyboardEventTypes)
  69003. */
  69004. type: number,
  69005. /**
  69006. * Defines the related dom event
  69007. */
  69008. event: KeyboardEvent);
  69009. }
  69010. /**
  69011. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  69012. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  69013. */
  69014. export class KeyboardInfoPre extends KeyboardInfo {
  69015. /**
  69016. * Defines the type of event (KeyboardEventTypes)
  69017. */
  69018. type: number;
  69019. /**
  69020. * Defines the related dom event
  69021. */
  69022. event: KeyboardEvent;
  69023. /**
  69024. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  69025. */
  69026. skipOnPointerObservable: boolean;
  69027. /**
  69028. * Instantiates a new keyboard pre info.
  69029. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  69030. * @param type Defines the type of event (KeyboardEventTypes)
  69031. * @param event Defines the related dom event
  69032. */
  69033. constructor(
  69034. /**
  69035. * Defines the type of event (KeyboardEventTypes)
  69036. */
  69037. type: number,
  69038. /**
  69039. * Defines the related dom event
  69040. */
  69041. event: KeyboardEvent);
  69042. }
  69043. }
  69044. declare module BABYLON {
  69045. /**
  69046. * Manage the keyboard inputs to control the movement of a free camera.
  69047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69048. */
  69049. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  69050. /**
  69051. * Defines the camera the input is attached to.
  69052. */
  69053. camera: FreeCamera;
  69054. /**
  69055. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69056. */
  69057. keysUp: number[];
  69058. /**
  69059. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69060. */
  69061. keysDown: number[];
  69062. /**
  69063. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69064. */
  69065. keysLeft: number[];
  69066. /**
  69067. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69068. */
  69069. keysRight: number[];
  69070. private _keys;
  69071. private _onCanvasBlurObserver;
  69072. private _onKeyboardObserver;
  69073. private _engine;
  69074. private _scene;
  69075. /**
  69076. * Attach the input controls to a specific dom element to get the input from.
  69077. * @param element Defines the element the controls should be listened from
  69078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69079. */
  69080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69081. /**
  69082. * Detach the current controls from the specified dom element.
  69083. * @param element Defines the element to stop listening the inputs from
  69084. */
  69085. detachControl(element: Nullable<HTMLElement>): void;
  69086. /**
  69087. * Update the current camera state depending on the inputs that have been used this frame.
  69088. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69089. */
  69090. checkInputs(): void;
  69091. /**
  69092. * Gets the class name of the current intput.
  69093. * @returns the class name
  69094. */
  69095. getClassName(): string;
  69096. /** @hidden */
  69097. _onLostFocus(): void;
  69098. /**
  69099. * Get the friendly name associated with the input class.
  69100. * @returns the input friendly name
  69101. */
  69102. getSimpleName(): string;
  69103. }
  69104. }
  69105. declare module BABYLON {
  69106. /**
  69107. * Interface describing all the common properties and methods a shadow light needs to implement.
  69108. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  69109. * as well as binding the different shadow properties to the effects.
  69110. */
  69111. export interface IShadowLight extends Light {
  69112. /**
  69113. * The light id in the scene (used in scene.findLighById for instance)
  69114. */
  69115. id: string;
  69116. /**
  69117. * The position the shdow will be casted from.
  69118. */
  69119. position: Vector3;
  69120. /**
  69121. * In 2d mode (needCube being false), the direction used to cast the shadow.
  69122. */
  69123. direction: Vector3;
  69124. /**
  69125. * The transformed position. Position of the light in world space taking parenting in account.
  69126. */
  69127. transformedPosition: Vector3;
  69128. /**
  69129. * The transformed direction. Direction of the light in world space taking parenting in account.
  69130. */
  69131. transformedDirection: Vector3;
  69132. /**
  69133. * The friendly name of the light in the scene.
  69134. */
  69135. name: string;
  69136. /**
  69137. * Defines the shadow projection clipping minimum z value.
  69138. */
  69139. shadowMinZ: number;
  69140. /**
  69141. * Defines the shadow projection clipping maximum z value.
  69142. */
  69143. shadowMaxZ: number;
  69144. /**
  69145. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69146. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69147. */
  69148. computeTransformedInformation(): boolean;
  69149. /**
  69150. * Gets the scene the light belongs to.
  69151. * @returns The scene
  69152. */
  69153. getScene(): Scene;
  69154. /**
  69155. * Callback defining a custom Projection Matrix Builder.
  69156. * This can be used to override the default projection matrix computation.
  69157. */
  69158. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69159. /**
  69160. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69161. * @param matrix The materix to updated with the projection information
  69162. * @param viewMatrix The transform matrix of the light
  69163. * @param renderList The list of mesh to render in the map
  69164. * @returns The current light
  69165. */
  69166. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69167. /**
  69168. * Gets the current depth scale used in ESM.
  69169. * @returns The scale
  69170. */
  69171. getDepthScale(): number;
  69172. /**
  69173. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69174. * @returns true if a cube texture needs to be use
  69175. */
  69176. needCube(): boolean;
  69177. /**
  69178. * Detects if the projection matrix requires to be recomputed this frame.
  69179. * @returns true if it requires to be recomputed otherwise, false.
  69180. */
  69181. needProjectionMatrixCompute(): boolean;
  69182. /**
  69183. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69184. */
  69185. forceProjectionMatrixCompute(): void;
  69186. /**
  69187. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69188. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69189. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69190. */
  69191. getShadowDirection(faceIndex?: number): Vector3;
  69192. /**
  69193. * Gets the minZ used for shadow according to both the scene and the light.
  69194. * @param activeCamera The camera we are returning the min for
  69195. * @returns the depth min z
  69196. */
  69197. getDepthMinZ(activeCamera: Camera): number;
  69198. /**
  69199. * Gets the maxZ used for shadow according to both the scene and the light.
  69200. * @param activeCamera The camera we are returning the max for
  69201. * @returns the depth max z
  69202. */
  69203. getDepthMaxZ(activeCamera: Camera): number;
  69204. }
  69205. /**
  69206. * Base implementation IShadowLight
  69207. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69208. */
  69209. export abstract class ShadowLight extends Light implements IShadowLight {
  69210. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69211. protected _position: Vector3;
  69212. protected _setPosition(value: Vector3): void;
  69213. /**
  69214. * Sets the position the shadow will be casted from. Also use as the light position for both
  69215. * point and spot lights.
  69216. */
  69217. /**
  69218. * Sets the position the shadow will be casted from. Also use as the light position for both
  69219. * point and spot lights.
  69220. */
  69221. position: Vector3;
  69222. protected _direction: Vector3;
  69223. protected _setDirection(value: Vector3): void;
  69224. /**
  69225. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69226. * Also use as the light direction on spot and directional lights.
  69227. */
  69228. /**
  69229. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69230. * Also use as the light direction on spot and directional lights.
  69231. */
  69232. direction: Vector3;
  69233. private _shadowMinZ;
  69234. /**
  69235. * Gets the shadow projection clipping minimum z value.
  69236. */
  69237. /**
  69238. * Sets the shadow projection clipping minimum z value.
  69239. */
  69240. shadowMinZ: number;
  69241. private _shadowMaxZ;
  69242. /**
  69243. * Sets the shadow projection clipping maximum z value.
  69244. */
  69245. /**
  69246. * Gets the shadow projection clipping maximum z value.
  69247. */
  69248. shadowMaxZ: number;
  69249. /**
  69250. * Callback defining a custom Projection Matrix Builder.
  69251. * This can be used to override the default projection matrix computation.
  69252. */
  69253. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69254. /**
  69255. * The transformed position. Position of the light in world space taking parenting in account.
  69256. */
  69257. transformedPosition: Vector3;
  69258. /**
  69259. * The transformed direction. Direction of the light in world space taking parenting in account.
  69260. */
  69261. transformedDirection: Vector3;
  69262. private _needProjectionMatrixCompute;
  69263. /**
  69264. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69265. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69266. */
  69267. computeTransformedInformation(): boolean;
  69268. /**
  69269. * Return the depth scale used for the shadow map.
  69270. * @returns the depth scale.
  69271. */
  69272. getDepthScale(): number;
  69273. /**
  69274. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69275. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69276. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69277. */
  69278. getShadowDirection(faceIndex?: number): Vector3;
  69279. /**
  69280. * Returns the ShadowLight absolute position in the World.
  69281. * @returns the position vector in world space
  69282. */
  69283. getAbsolutePosition(): Vector3;
  69284. /**
  69285. * Sets the ShadowLight direction toward the passed target.
  69286. * @param target The point to target in local space
  69287. * @returns the updated ShadowLight direction
  69288. */
  69289. setDirectionToTarget(target: Vector3): Vector3;
  69290. /**
  69291. * Returns the light rotation in euler definition.
  69292. * @returns the x y z rotation in local space.
  69293. */
  69294. getRotation(): Vector3;
  69295. /**
  69296. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69297. * @returns true if a cube texture needs to be use
  69298. */
  69299. needCube(): boolean;
  69300. /**
  69301. * Detects if the projection matrix requires to be recomputed this frame.
  69302. * @returns true if it requires to be recomputed otherwise, false.
  69303. */
  69304. needProjectionMatrixCompute(): boolean;
  69305. /**
  69306. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69307. */
  69308. forceProjectionMatrixCompute(): void;
  69309. /** @hidden */
  69310. _initCache(): void;
  69311. /** @hidden */
  69312. _isSynchronized(): boolean;
  69313. /**
  69314. * Computes the world matrix of the node
  69315. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69316. * @returns the world matrix
  69317. */
  69318. computeWorldMatrix(force?: boolean): Matrix;
  69319. /**
  69320. * Gets the minZ used for shadow according to both the scene and the light.
  69321. * @param activeCamera The camera we are returning the min for
  69322. * @returns the depth min z
  69323. */
  69324. getDepthMinZ(activeCamera: Camera): number;
  69325. /**
  69326. * Gets the maxZ used for shadow according to both the scene and the light.
  69327. * @param activeCamera The camera we are returning the max for
  69328. * @returns the depth max z
  69329. */
  69330. getDepthMaxZ(activeCamera: Camera): number;
  69331. /**
  69332. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69333. * @param matrix The materix to updated with the projection information
  69334. * @param viewMatrix The transform matrix of the light
  69335. * @param renderList The list of mesh to render in the map
  69336. * @returns The current light
  69337. */
  69338. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69339. }
  69340. }
  69341. declare module BABYLON {
  69342. /**
  69343. * "Static Class" containing the most commonly used helper while dealing with material for
  69344. * rendering purpose.
  69345. *
  69346. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69347. *
  69348. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69349. */
  69350. export class MaterialHelper {
  69351. /**
  69352. * Bind the current view position to an effect.
  69353. * @param effect The effect to be bound
  69354. * @param scene The scene the eyes position is used from
  69355. */
  69356. static BindEyePosition(effect: Effect, scene: Scene): void;
  69357. /**
  69358. * Helps preparing the defines values about the UVs in used in the effect.
  69359. * UVs are shared as much as we can accross channels in the shaders.
  69360. * @param texture The texture we are preparing the UVs for
  69361. * @param defines The defines to update
  69362. * @param key The channel key "diffuse", "specular"... used in the shader
  69363. */
  69364. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69365. /**
  69366. * Binds a texture matrix value to its corrsponding uniform
  69367. * @param texture The texture to bind the matrix for
  69368. * @param uniformBuffer The uniform buffer receivin the data
  69369. * @param key The channel key "diffuse", "specular"... used in the shader
  69370. */
  69371. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69372. /**
  69373. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69374. * @param mesh defines the current mesh
  69375. * @param scene defines the current scene
  69376. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69377. * @param pointsCloud defines if point cloud rendering has to be turned on
  69378. * @param fogEnabled defines if fog has to be turned on
  69379. * @param alphaTest defines if alpha testing has to be turned on
  69380. * @param defines defines the current list of defines
  69381. */
  69382. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69383. /**
  69384. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69385. * @param scene defines the current scene
  69386. * @param engine defines the current engine
  69387. * @param defines specifies the list of active defines
  69388. * @param useInstances defines if instances have to be turned on
  69389. * @param useClipPlane defines if clip plane have to be turned on
  69390. */
  69391. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69392. /**
  69393. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69394. * @param mesh The mesh containing the geometry data we will draw
  69395. * @param defines The defines to update
  69396. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69397. * @param useBones Precise whether bones should be used or not (override mesh info)
  69398. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69399. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69400. * @returns false if defines are considered not dirty and have not been checked
  69401. */
  69402. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69403. /**
  69404. * Prepares the defines related to multiview
  69405. * @param scene The scene we are intending to draw
  69406. * @param defines The defines to update
  69407. */
  69408. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69409. /**
  69410. * Prepares the defines related to the light information passed in parameter
  69411. * @param scene The scene we are intending to draw
  69412. * @param mesh The mesh the effect is compiling for
  69413. * @param defines The defines to update
  69414. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69415. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69416. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69417. * @returns true if normals will be required for the rest of the effect
  69418. */
  69419. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69420. /**
  69421. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69422. * that won t be acctive due to defines being turned off.
  69423. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69424. * @param samplersList The samplers list
  69425. * @param defines The defines helping in the list generation
  69426. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69427. */
  69428. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69429. /**
  69430. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69431. * @param defines The defines to update while falling back
  69432. * @param fallbacks The authorized effect fallbacks
  69433. * @param maxSimultaneousLights The maximum number of lights allowed
  69434. * @param rank the current rank of the Effect
  69435. * @returns The newly affected rank
  69436. */
  69437. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69438. /**
  69439. * Prepares the list of attributes required for morph targets according to the effect defines.
  69440. * @param attribs The current list of supported attribs
  69441. * @param mesh The mesh to prepare the morph targets attributes for
  69442. * @param defines The current Defines of the effect
  69443. */
  69444. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69445. /**
  69446. * Prepares the list of attributes required for bones according to the effect defines.
  69447. * @param attribs The current list of supported attribs
  69448. * @param mesh The mesh to prepare the bones attributes for
  69449. * @param defines The current Defines of the effect
  69450. * @param fallbacks The current efffect fallback strategy
  69451. */
  69452. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69453. /**
  69454. * Prepares the list of attributes required for instances according to the effect defines.
  69455. * @param attribs The current list of supported attribs
  69456. * @param defines The current Defines of the effect
  69457. */
  69458. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69459. /**
  69460. * Binds the light shadow information to the effect for the given mesh.
  69461. * @param light The light containing the generator
  69462. * @param scene The scene the lights belongs to
  69463. * @param mesh The mesh we are binding the information to render
  69464. * @param lightIndex The light index in the effect used to render the mesh
  69465. * @param effect The effect we are binding the data to
  69466. */
  69467. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69468. /**
  69469. * Binds the light information to the effect.
  69470. * @param light The light containing the generator
  69471. * @param effect The effect we are binding the data to
  69472. * @param lightIndex The light index in the effect used to render
  69473. */
  69474. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69475. /**
  69476. * Binds the lights information from the scene to the effect for the given mesh.
  69477. * @param scene The scene the lights belongs to
  69478. * @param mesh The mesh we are binding the information to render
  69479. * @param effect The effect we are binding the data to
  69480. * @param defines The generated defines for the effect
  69481. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69482. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69483. */
  69484. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69485. private static _tempFogColor;
  69486. /**
  69487. * Binds the fog information from the scene to the effect for the given mesh.
  69488. * @param scene The scene the lights belongs to
  69489. * @param mesh The mesh we are binding the information to render
  69490. * @param effect The effect we are binding the data to
  69491. * @param linearSpace Defines if the fog effect is applied in linear space
  69492. */
  69493. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69494. /**
  69495. * Binds the bones information from the mesh to the effect.
  69496. * @param mesh The mesh we are binding the information to render
  69497. * @param effect The effect we are binding the data to
  69498. */
  69499. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69500. /**
  69501. * Binds the morph targets information from the mesh to the effect.
  69502. * @param abstractMesh The mesh we are binding the information to render
  69503. * @param effect The effect we are binding the data to
  69504. */
  69505. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69506. /**
  69507. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69508. * @param defines The generated defines used in the effect
  69509. * @param effect The effect we are binding the data to
  69510. * @param scene The scene we are willing to render with logarithmic scale for
  69511. */
  69512. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69513. /**
  69514. * Binds the clip plane information from the scene to the effect.
  69515. * @param scene The scene the clip plane information are extracted from
  69516. * @param effect The effect we are binding the data to
  69517. */
  69518. static BindClipPlane(effect: Effect, scene: Scene): void;
  69519. }
  69520. }
  69521. declare module BABYLON {
  69522. /** @hidden */
  69523. export var kernelBlurVaryingDeclaration: {
  69524. name: string;
  69525. shader: string;
  69526. };
  69527. }
  69528. declare module BABYLON {
  69529. /** @hidden */
  69530. export var kernelBlurFragment: {
  69531. name: string;
  69532. shader: string;
  69533. };
  69534. }
  69535. declare module BABYLON {
  69536. /** @hidden */
  69537. export var kernelBlurFragment2: {
  69538. name: string;
  69539. shader: string;
  69540. };
  69541. }
  69542. declare module BABYLON {
  69543. /** @hidden */
  69544. export var kernelBlurPixelShader: {
  69545. name: string;
  69546. shader: string;
  69547. };
  69548. }
  69549. declare module BABYLON {
  69550. /** @hidden */
  69551. export var kernelBlurVertex: {
  69552. name: string;
  69553. shader: string;
  69554. };
  69555. }
  69556. declare module BABYLON {
  69557. /** @hidden */
  69558. export var kernelBlurVertexShader: {
  69559. name: string;
  69560. shader: string;
  69561. };
  69562. }
  69563. declare module BABYLON {
  69564. /**
  69565. * The Blur Post Process which blurs an image based on a kernel and direction.
  69566. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69567. */
  69568. export class BlurPostProcess extends PostProcess {
  69569. /** The direction in which to blur the image. */
  69570. direction: Vector2;
  69571. private blockCompilation;
  69572. protected _kernel: number;
  69573. protected _idealKernel: number;
  69574. protected _packedFloat: boolean;
  69575. private _staticDefines;
  69576. /**
  69577. * Sets the length in pixels of the blur sample region
  69578. */
  69579. /**
  69580. * Gets the length in pixels of the blur sample region
  69581. */
  69582. kernel: number;
  69583. /**
  69584. * Sets wether or not the blur needs to unpack/repack floats
  69585. */
  69586. /**
  69587. * Gets wether or not the blur is unpacking/repacking floats
  69588. */
  69589. packedFloat: boolean;
  69590. /**
  69591. * Creates a new instance BlurPostProcess
  69592. * @param name The name of the effect.
  69593. * @param direction The direction in which to blur the image.
  69594. * @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.
  69595. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69596. * @param camera The camera to apply the render pass to.
  69597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69598. * @param engine The engine which the post process will be applied. (default: current engine)
  69599. * @param reusable If the post process can be reused on the same frame. (default: false)
  69600. * @param textureType Type of textures used when performing the post process. (default: 0)
  69601. * @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)
  69602. */
  69603. constructor(name: string,
  69604. /** The direction in which to blur the image. */
  69605. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69606. /**
  69607. * Updates the effect with the current post process compile time values and recompiles the shader.
  69608. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69609. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69610. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69611. * @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
  69612. * @param onCompiled Called when the shader has been compiled.
  69613. * @param onError Called if there is an error when compiling a shader.
  69614. */
  69615. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69616. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69617. /**
  69618. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69619. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69620. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69621. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69622. * The gaps between physical kernels are compensated for in the weighting of the samples
  69623. * @param idealKernel Ideal blur kernel.
  69624. * @return Nearest best kernel.
  69625. */
  69626. protected _nearestBestKernel(idealKernel: number): number;
  69627. /**
  69628. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69629. * @param x The point on the Gaussian distribution to sample.
  69630. * @return the value of the Gaussian function at x.
  69631. */
  69632. protected _gaussianWeight(x: number): number;
  69633. /**
  69634. * Generates a string that can be used as a floating point number in GLSL.
  69635. * @param x Value to print.
  69636. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69637. * @return GLSL float string.
  69638. */
  69639. protected _glslFloat(x: number, decimalFigures?: number): string;
  69640. }
  69641. }
  69642. declare module BABYLON {
  69643. /** @hidden */
  69644. export var shadowMapPixelShader: {
  69645. name: string;
  69646. shader: string;
  69647. };
  69648. }
  69649. declare module BABYLON {
  69650. /** @hidden */
  69651. export var bonesDeclaration: {
  69652. name: string;
  69653. shader: string;
  69654. };
  69655. }
  69656. declare module BABYLON {
  69657. /** @hidden */
  69658. export var morphTargetsVertexGlobalDeclaration: {
  69659. name: string;
  69660. shader: string;
  69661. };
  69662. }
  69663. declare module BABYLON {
  69664. /** @hidden */
  69665. export var morphTargetsVertexDeclaration: {
  69666. name: string;
  69667. shader: string;
  69668. };
  69669. }
  69670. declare module BABYLON {
  69671. /** @hidden */
  69672. export var instancesDeclaration: {
  69673. name: string;
  69674. shader: string;
  69675. };
  69676. }
  69677. declare module BABYLON {
  69678. /** @hidden */
  69679. export var helperFunctions: {
  69680. name: string;
  69681. shader: string;
  69682. };
  69683. }
  69684. declare module BABYLON {
  69685. /** @hidden */
  69686. export var morphTargetsVertex: {
  69687. name: string;
  69688. shader: string;
  69689. };
  69690. }
  69691. declare module BABYLON {
  69692. /** @hidden */
  69693. export var instancesVertex: {
  69694. name: string;
  69695. shader: string;
  69696. };
  69697. }
  69698. declare module BABYLON {
  69699. /** @hidden */
  69700. export var bonesVertex: {
  69701. name: string;
  69702. shader: string;
  69703. };
  69704. }
  69705. declare module BABYLON {
  69706. /** @hidden */
  69707. export var shadowMapVertexShader: {
  69708. name: string;
  69709. shader: string;
  69710. };
  69711. }
  69712. declare module BABYLON {
  69713. /** @hidden */
  69714. export var depthBoxBlurPixelShader: {
  69715. name: string;
  69716. shader: string;
  69717. };
  69718. }
  69719. declare module BABYLON {
  69720. /**
  69721. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69722. */
  69723. export interface ICustomShaderOptions {
  69724. /**
  69725. * Gets or sets the custom shader name to use
  69726. */
  69727. shaderName: string;
  69728. /**
  69729. * The list of attribute names used in the shader
  69730. */
  69731. attributes?: string[];
  69732. /**
  69733. * The list of unifrom names used in the shader
  69734. */
  69735. uniforms?: string[];
  69736. /**
  69737. * The list of sampler names used in the shader
  69738. */
  69739. samplers?: string[];
  69740. /**
  69741. * The list of defines used in the shader
  69742. */
  69743. defines?: string[];
  69744. }
  69745. /**
  69746. * Interface to implement to create a shadow generator compatible with BJS.
  69747. */
  69748. export interface IShadowGenerator {
  69749. /**
  69750. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69751. * @returns The render target texture if present otherwise, null
  69752. */
  69753. getShadowMap(): Nullable<RenderTargetTexture>;
  69754. /**
  69755. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69756. * @returns The render target texture if the shadow map is present otherwise, null
  69757. */
  69758. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69759. /**
  69760. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69761. * @param subMesh The submesh we want to render in the shadow map
  69762. * @param useInstances Defines wether will draw in the map using instances
  69763. * @returns true if ready otherwise, false
  69764. */
  69765. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69766. /**
  69767. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69768. * @param defines Defines of the material we want to update
  69769. * @param lightIndex Index of the light in the enabled light list of the material
  69770. */
  69771. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69772. /**
  69773. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69774. * defined in the generator but impacting the effect).
  69775. * It implies the unifroms available on the materials are the standard BJS ones.
  69776. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69777. * @param effect The effect we are binfing the information for
  69778. */
  69779. bindShadowLight(lightIndex: string, effect: Effect): void;
  69780. /**
  69781. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69782. * (eq to shadow prjection matrix * light transform matrix)
  69783. * @returns The transform matrix used to create the shadow map
  69784. */
  69785. getTransformMatrix(): Matrix;
  69786. /**
  69787. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69788. * Cube and 2D textures for instance.
  69789. */
  69790. recreateShadowMap(): void;
  69791. /**
  69792. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69793. * @param onCompiled Callback triggered at the and of the effects compilation
  69794. * @param options Sets of optional options forcing the compilation with different modes
  69795. */
  69796. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69797. useInstances: boolean;
  69798. }>): void;
  69799. /**
  69800. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69801. * @param options Sets of optional options forcing the compilation with different modes
  69802. * @returns A promise that resolves when the compilation completes
  69803. */
  69804. forceCompilationAsync(options?: Partial<{
  69805. useInstances: boolean;
  69806. }>): Promise<void>;
  69807. /**
  69808. * Serializes the shadow generator setup to a json object.
  69809. * @returns The serialized JSON object
  69810. */
  69811. serialize(): any;
  69812. /**
  69813. * Disposes the Shadow map and related Textures and effects.
  69814. */
  69815. dispose(): void;
  69816. }
  69817. /**
  69818. * Default implementation IShadowGenerator.
  69819. * This is the main object responsible of generating shadows in the framework.
  69820. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69821. */
  69822. export class ShadowGenerator implements IShadowGenerator {
  69823. /**
  69824. * Shadow generator mode None: no filtering applied.
  69825. */
  69826. static readonly FILTER_NONE: number;
  69827. /**
  69828. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69829. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69830. */
  69831. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69832. /**
  69833. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69834. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69835. */
  69836. static readonly FILTER_POISSONSAMPLING: number;
  69837. /**
  69838. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69839. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69840. */
  69841. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69842. /**
  69843. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69844. * edge artifacts on steep falloff.
  69845. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69846. */
  69847. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69848. /**
  69849. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69850. * edge artifacts on steep falloff.
  69851. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69852. */
  69853. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69854. /**
  69855. * Shadow generator mode PCF: Percentage Closer Filtering
  69856. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69857. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69858. */
  69859. static readonly FILTER_PCF: number;
  69860. /**
  69861. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69862. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69863. * Contact Hardening
  69864. */
  69865. static readonly FILTER_PCSS: number;
  69866. /**
  69867. * Reserved for PCF and PCSS
  69868. * Highest Quality.
  69869. *
  69870. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69871. *
  69872. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69873. */
  69874. static readonly QUALITY_HIGH: number;
  69875. /**
  69876. * Reserved for PCF and PCSS
  69877. * Good tradeoff for quality/perf cross devices
  69878. *
  69879. * Execute PCF on a 3*3 kernel.
  69880. *
  69881. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69882. */
  69883. static readonly QUALITY_MEDIUM: number;
  69884. /**
  69885. * Reserved for PCF and PCSS
  69886. * The lowest quality but the fastest.
  69887. *
  69888. * Execute PCF on a 1*1 kernel.
  69889. *
  69890. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69891. */
  69892. static readonly QUALITY_LOW: number;
  69893. /** Gets or sets the custom shader name to use */
  69894. customShaderOptions: ICustomShaderOptions;
  69895. /**
  69896. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69897. */
  69898. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69899. /**
  69900. * Observable triggered before a mesh is rendered in the shadow map.
  69901. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69902. */
  69903. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69904. private _bias;
  69905. /**
  69906. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69907. */
  69908. /**
  69909. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69910. */
  69911. bias: number;
  69912. private _normalBias;
  69913. /**
  69914. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69915. */
  69916. /**
  69917. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69918. */
  69919. normalBias: number;
  69920. private _blurBoxOffset;
  69921. /**
  69922. * Gets the blur box offset: offset applied during the blur pass.
  69923. * Only useful if useKernelBlur = false
  69924. */
  69925. /**
  69926. * Sets the blur box offset: offset applied during the blur pass.
  69927. * Only useful if useKernelBlur = false
  69928. */
  69929. blurBoxOffset: number;
  69930. private _blurScale;
  69931. /**
  69932. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69933. * 2 means half of the size.
  69934. */
  69935. /**
  69936. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69937. * 2 means half of the size.
  69938. */
  69939. blurScale: number;
  69940. private _blurKernel;
  69941. /**
  69942. * Gets the blur kernel: kernel size of the blur pass.
  69943. * Only useful if useKernelBlur = true
  69944. */
  69945. /**
  69946. * Sets the blur kernel: kernel size of the blur pass.
  69947. * Only useful if useKernelBlur = true
  69948. */
  69949. blurKernel: number;
  69950. private _useKernelBlur;
  69951. /**
  69952. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69953. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69954. */
  69955. /**
  69956. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69957. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69958. */
  69959. useKernelBlur: boolean;
  69960. private _depthScale;
  69961. /**
  69962. * Gets the depth scale used in ESM mode.
  69963. */
  69964. /**
  69965. * Sets the depth scale used in ESM mode.
  69966. * This can override the scale stored on the light.
  69967. */
  69968. depthScale: number;
  69969. private _filter;
  69970. /**
  69971. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69972. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69973. */
  69974. /**
  69975. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69976. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69977. */
  69978. filter: number;
  69979. /**
  69980. * Gets if the current filter is set to Poisson Sampling.
  69981. */
  69982. /**
  69983. * Sets the current filter to Poisson Sampling.
  69984. */
  69985. usePoissonSampling: boolean;
  69986. /**
  69987. * Gets if the current filter is set to ESM.
  69988. */
  69989. /**
  69990. * Sets the current filter is to ESM.
  69991. */
  69992. useExponentialShadowMap: boolean;
  69993. /**
  69994. * Gets if the current filter is set to filtered ESM.
  69995. */
  69996. /**
  69997. * Gets if the current filter is set to filtered ESM.
  69998. */
  69999. useBlurExponentialShadowMap: boolean;
  70000. /**
  70001. * Gets if the current filter is set to "close ESM" (using the inverse of the
  70002. * exponential to prevent steep falloff artifacts).
  70003. */
  70004. /**
  70005. * Sets the current filter to "close ESM" (using the inverse of the
  70006. * exponential to prevent steep falloff artifacts).
  70007. */
  70008. useCloseExponentialShadowMap: boolean;
  70009. /**
  70010. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  70011. * exponential to prevent steep falloff artifacts).
  70012. */
  70013. /**
  70014. * Sets the current filter to filtered "close ESM" (using the inverse of the
  70015. * exponential to prevent steep falloff artifacts).
  70016. */
  70017. useBlurCloseExponentialShadowMap: boolean;
  70018. /**
  70019. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  70020. */
  70021. /**
  70022. * Sets the current filter to "PCF" (percentage closer filtering).
  70023. */
  70024. usePercentageCloserFiltering: boolean;
  70025. private _filteringQuality;
  70026. /**
  70027. * Gets the PCF or PCSS Quality.
  70028. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  70029. */
  70030. /**
  70031. * Sets the PCF or PCSS Quality.
  70032. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  70033. */
  70034. filteringQuality: number;
  70035. /**
  70036. * Gets if the current filter is set to "PCSS" (contact hardening).
  70037. */
  70038. /**
  70039. * Sets the current filter to "PCSS" (contact hardening).
  70040. */
  70041. useContactHardeningShadow: boolean;
  70042. private _contactHardeningLightSizeUVRatio;
  70043. /**
  70044. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  70045. * Using a ratio helps keeping shape stability independently of the map size.
  70046. *
  70047. * It does not account for the light projection as it was having too much
  70048. * instability during the light setup or during light position changes.
  70049. *
  70050. * Only valid if useContactHardeningShadow is true.
  70051. */
  70052. /**
  70053. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  70054. * Using a ratio helps keeping shape stability independently of the map size.
  70055. *
  70056. * It does not account for the light projection as it was having too much
  70057. * instability during the light setup or during light position changes.
  70058. *
  70059. * Only valid if useContactHardeningShadow is true.
  70060. */
  70061. contactHardeningLightSizeUVRatio: number;
  70062. private _darkness;
  70063. /**
  70064. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  70065. * 0 means strongest and 1 would means no shadow.
  70066. * @returns the darkness.
  70067. */
  70068. getDarkness(): number;
  70069. /**
  70070. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  70071. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  70072. * @returns the shadow generator allowing fluent coding.
  70073. */
  70074. setDarkness(darkness: number): ShadowGenerator;
  70075. private _transparencyShadow;
  70076. /**
  70077. * Sets the ability to have transparent shadow (boolean).
  70078. * @param transparent True if transparent else False
  70079. * @returns the shadow generator allowing fluent coding
  70080. */
  70081. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  70082. private _shadowMap;
  70083. private _shadowMap2;
  70084. /**
  70085. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  70086. * @returns The render target texture if present otherwise, null
  70087. */
  70088. getShadowMap(): Nullable<RenderTargetTexture>;
  70089. /**
  70090. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  70091. * @returns The render target texture if the shadow map is present otherwise, null
  70092. */
  70093. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  70094. /**
  70095. * Helper function to add a mesh and its descendants to the list of shadow casters.
  70096. * @param mesh Mesh to add
  70097. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  70098. * @returns the Shadow Generator itself
  70099. */
  70100. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  70101. /**
  70102. * Helper function to remove a mesh and its descendants from the list of shadow casters
  70103. * @param mesh Mesh to remove
  70104. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  70105. * @returns the Shadow Generator itself
  70106. */
  70107. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  70108. /**
  70109. * Controls the extent to which the shadows fade out at the edge of the frustum
  70110. * Used only by directionals and spots
  70111. */
  70112. frustumEdgeFalloff: number;
  70113. private _light;
  70114. /**
  70115. * Returns the associated light object.
  70116. * @returns the light generating the shadow
  70117. */
  70118. getLight(): IShadowLight;
  70119. /**
  70120. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  70121. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  70122. * It might on the other hand introduce peter panning.
  70123. */
  70124. forceBackFacesOnly: boolean;
  70125. private _scene;
  70126. private _lightDirection;
  70127. private _effect;
  70128. private _viewMatrix;
  70129. private _projectionMatrix;
  70130. private _transformMatrix;
  70131. private _cachedPosition;
  70132. private _cachedDirection;
  70133. private _cachedDefines;
  70134. private _currentRenderID;
  70135. private _boxBlurPostprocess;
  70136. private _kernelBlurXPostprocess;
  70137. private _kernelBlurYPostprocess;
  70138. private _blurPostProcesses;
  70139. private _mapSize;
  70140. private _currentFaceIndex;
  70141. private _currentFaceIndexCache;
  70142. private _textureType;
  70143. private _defaultTextureMatrix;
  70144. /** @hidden */
  70145. static _SceneComponentInitialization: (scene: Scene) => void;
  70146. /**
  70147. * Creates a ShadowGenerator object.
  70148. * A ShadowGenerator is the required tool to use the shadows.
  70149. * Each light casting shadows needs to use its own ShadowGenerator.
  70150. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70151. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70152. * @param light The light object generating the shadows.
  70153. * @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.
  70154. */
  70155. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70156. private _initializeGenerator;
  70157. private _initializeShadowMap;
  70158. private _initializeBlurRTTAndPostProcesses;
  70159. private _renderForShadowMap;
  70160. private _renderSubMeshForShadowMap;
  70161. private _applyFilterValues;
  70162. /**
  70163. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70164. * @param onCompiled Callback triggered at the and of the effects compilation
  70165. * @param options Sets of optional options forcing the compilation with different modes
  70166. */
  70167. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70168. useInstances: boolean;
  70169. }>): void;
  70170. /**
  70171. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70172. * @param options Sets of optional options forcing the compilation with different modes
  70173. * @returns A promise that resolves when the compilation completes
  70174. */
  70175. forceCompilationAsync(options?: Partial<{
  70176. useInstances: boolean;
  70177. }>): Promise<void>;
  70178. /**
  70179. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70180. * @param subMesh The submesh we want to render in the shadow map
  70181. * @param useInstances Defines wether will draw in the map using instances
  70182. * @returns true if ready otherwise, false
  70183. */
  70184. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70185. /**
  70186. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70187. * @param defines Defines of the material we want to update
  70188. * @param lightIndex Index of the light in the enabled light list of the material
  70189. */
  70190. prepareDefines(defines: any, lightIndex: number): void;
  70191. /**
  70192. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70193. * defined in the generator but impacting the effect).
  70194. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70195. * @param effect The effect we are binfing the information for
  70196. */
  70197. bindShadowLight(lightIndex: string, effect: Effect): void;
  70198. /**
  70199. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70200. * (eq to shadow prjection matrix * light transform matrix)
  70201. * @returns The transform matrix used to create the shadow map
  70202. */
  70203. getTransformMatrix(): Matrix;
  70204. /**
  70205. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70206. * Cube and 2D textures for instance.
  70207. */
  70208. recreateShadowMap(): void;
  70209. private _disposeBlurPostProcesses;
  70210. private _disposeRTTandPostProcesses;
  70211. /**
  70212. * Disposes the ShadowGenerator.
  70213. * Returns nothing.
  70214. */
  70215. dispose(): void;
  70216. /**
  70217. * Serializes the shadow generator setup to a json object.
  70218. * @returns The serialized JSON object
  70219. */
  70220. serialize(): any;
  70221. /**
  70222. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70223. * @param parsedShadowGenerator The JSON object to parse
  70224. * @param scene The scene to create the shadow map for
  70225. * @returns The parsed shadow generator
  70226. */
  70227. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70228. }
  70229. }
  70230. declare module BABYLON {
  70231. /**
  70232. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70233. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70234. * 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.
  70235. */
  70236. export abstract class Light extends Node {
  70237. /**
  70238. * Falloff Default: light is falling off following the material specification:
  70239. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70240. */
  70241. static readonly FALLOFF_DEFAULT: number;
  70242. /**
  70243. * Falloff Physical: light is falling off following the inverse squared distance law.
  70244. */
  70245. static readonly FALLOFF_PHYSICAL: number;
  70246. /**
  70247. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70248. * to enhance interoperability with other engines.
  70249. */
  70250. static readonly FALLOFF_GLTF: number;
  70251. /**
  70252. * Falloff Standard: light is falling off like in the standard material
  70253. * to enhance interoperability with other materials.
  70254. */
  70255. static readonly FALLOFF_STANDARD: number;
  70256. /**
  70257. * If every light affecting the material is in this lightmapMode,
  70258. * material.lightmapTexture adds or multiplies
  70259. * (depends on material.useLightmapAsShadowmap)
  70260. * after every other light calculations.
  70261. */
  70262. static readonly LIGHTMAP_DEFAULT: number;
  70263. /**
  70264. * material.lightmapTexture as only diffuse lighting from this light
  70265. * adds only specular lighting from this light
  70266. * adds dynamic shadows
  70267. */
  70268. static readonly LIGHTMAP_SPECULAR: number;
  70269. /**
  70270. * material.lightmapTexture as only lighting
  70271. * no light calculation from this light
  70272. * only adds dynamic shadows from this light
  70273. */
  70274. static readonly LIGHTMAP_SHADOWSONLY: number;
  70275. /**
  70276. * Each light type uses the default quantity according to its type:
  70277. * point/spot lights use luminous intensity
  70278. * directional lights use illuminance
  70279. */
  70280. static readonly INTENSITYMODE_AUTOMATIC: number;
  70281. /**
  70282. * lumen (lm)
  70283. */
  70284. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70285. /**
  70286. * candela (lm/sr)
  70287. */
  70288. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70289. /**
  70290. * lux (lm/m^2)
  70291. */
  70292. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70293. /**
  70294. * nit (cd/m^2)
  70295. */
  70296. static readonly INTENSITYMODE_LUMINANCE: number;
  70297. /**
  70298. * Light type const id of the point light.
  70299. */
  70300. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70301. /**
  70302. * Light type const id of the directional light.
  70303. */
  70304. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70305. /**
  70306. * Light type const id of the spot light.
  70307. */
  70308. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70309. /**
  70310. * Light type const id of the hemispheric light.
  70311. */
  70312. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70313. /**
  70314. * Diffuse gives the basic color to an object.
  70315. */
  70316. diffuse: Color3;
  70317. /**
  70318. * Specular produces a highlight color on an object.
  70319. * Note: This is note affecting PBR materials.
  70320. */
  70321. specular: Color3;
  70322. /**
  70323. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70324. * falling off base on range or angle.
  70325. * This can be set to any values in Light.FALLOFF_x.
  70326. *
  70327. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70328. * other types of materials.
  70329. */
  70330. falloffType: number;
  70331. /**
  70332. * Strength of the light.
  70333. * Note: By default it is define in the framework own unit.
  70334. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70335. */
  70336. intensity: number;
  70337. private _range;
  70338. protected _inverseSquaredRange: number;
  70339. /**
  70340. * Defines how far from the source the light is impacting in scene units.
  70341. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70342. */
  70343. /**
  70344. * Defines how far from the source the light is impacting in scene units.
  70345. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70346. */
  70347. range: number;
  70348. /**
  70349. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70350. * of light.
  70351. */
  70352. private _photometricScale;
  70353. private _intensityMode;
  70354. /**
  70355. * Gets the photometric scale used to interpret the intensity.
  70356. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70357. */
  70358. /**
  70359. * Sets the photometric scale used to interpret the intensity.
  70360. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70361. */
  70362. intensityMode: number;
  70363. private _radius;
  70364. /**
  70365. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70366. */
  70367. /**
  70368. * sets the light radius used by PBR Materials to simulate soft area lights.
  70369. */
  70370. radius: number;
  70371. private _renderPriority;
  70372. /**
  70373. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70374. * exceeding the number allowed of the materials.
  70375. */
  70376. renderPriority: number;
  70377. private _shadowEnabled;
  70378. /**
  70379. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70380. * the current shadow generator.
  70381. */
  70382. /**
  70383. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70384. * the current shadow generator.
  70385. */
  70386. shadowEnabled: boolean;
  70387. private _includedOnlyMeshes;
  70388. /**
  70389. * Gets the only meshes impacted by this light.
  70390. */
  70391. /**
  70392. * Sets the only meshes impacted by this light.
  70393. */
  70394. includedOnlyMeshes: AbstractMesh[];
  70395. private _excludedMeshes;
  70396. /**
  70397. * Gets the meshes not impacted by this light.
  70398. */
  70399. /**
  70400. * Sets the meshes not impacted by this light.
  70401. */
  70402. excludedMeshes: AbstractMesh[];
  70403. private _excludeWithLayerMask;
  70404. /**
  70405. * Gets the layer id use to find what meshes are not impacted by the light.
  70406. * Inactive if 0
  70407. */
  70408. /**
  70409. * Sets the layer id use to find what meshes are not impacted by the light.
  70410. * Inactive if 0
  70411. */
  70412. excludeWithLayerMask: number;
  70413. private _includeOnlyWithLayerMask;
  70414. /**
  70415. * Gets the layer id use to find what meshes are impacted by the light.
  70416. * Inactive if 0
  70417. */
  70418. /**
  70419. * Sets the layer id use to find what meshes are impacted by the light.
  70420. * Inactive if 0
  70421. */
  70422. includeOnlyWithLayerMask: number;
  70423. private _lightmapMode;
  70424. /**
  70425. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70426. */
  70427. /**
  70428. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70429. */
  70430. lightmapMode: number;
  70431. /**
  70432. * Shadow generator associted to the light.
  70433. * @hidden Internal use only.
  70434. */
  70435. _shadowGenerator: Nullable<IShadowGenerator>;
  70436. /**
  70437. * @hidden Internal use only.
  70438. */
  70439. _excludedMeshesIds: string[];
  70440. /**
  70441. * @hidden Internal use only.
  70442. */
  70443. _includedOnlyMeshesIds: string[];
  70444. /**
  70445. * The current light unifom buffer.
  70446. * @hidden Internal use only.
  70447. */
  70448. _uniformBuffer: UniformBuffer;
  70449. /**
  70450. * Creates a Light object in the scene.
  70451. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70452. * @param name The firendly name of the light
  70453. * @param scene The scene the light belongs too
  70454. */
  70455. constructor(name: string, scene: Scene);
  70456. protected abstract _buildUniformLayout(): void;
  70457. /**
  70458. * Sets the passed Effect "effect" with the Light information.
  70459. * @param effect The effect to update
  70460. * @param lightIndex The index of the light in the effect to update
  70461. * @returns The light
  70462. */
  70463. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70464. /**
  70465. * Returns the string "Light".
  70466. * @returns the class name
  70467. */
  70468. getClassName(): string;
  70469. /** @hidden */
  70470. readonly _isLight: boolean;
  70471. /**
  70472. * Converts the light information to a readable string for debug purpose.
  70473. * @param fullDetails Supports for multiple levels of logging within scene loading
  70474. * @returns the human readable light info
  70475. */
  70476. toString(fullDetails?: boolean): string;
  70477. /** @hidden */
  70478. protected _syncParentEnabledState(): void;
  70479. /**
  70480. * Set the enabled state of this node.
  70481. * @param value - the new enabled state
  70482. */
  70483. setEnabled(value: boolean): void;
  70484. /**
  70485. * Returns the Light associated shadow generator if any.
  70486. * @return the associated shadow generator.
  70487. */
  70488. getShadowGenerator(): Nullable<IShadowGenerator>;
  70489. /**
  70490. * Returns a Vector3, the absolute light position in the World.
  70491. * @returns the world space position of the light
  70492. */
  70493. getAbsolutePosition(): Vector3;
  70494. /**
  70495. * Specifies if the light will affect the passed mesh.
  70496. * @param mesh The mesh to test against the light
  70497. * @return true the mesh is affected otherwise, false.
  70498. */
  70499. canAffectMesh(mesh: AbstractMesh): boolean;
  70500. /**
  70501. * Sort function to order lights for rendering.
  70502. * @param a First Light object to compare to second.
  70503. * @param b Second Light object to compare first.
  70504. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70505. */
  70506. static CompareLightsPriority(a: Light, b: Light): number;
  70507. /**
  70508. * Releases resources associated with this node.
  70509. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70510. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70511. */
  70512. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70513. /**
  70514. * Returns the light type ID (integer).
  70515. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70516. */
  70517. getTypeID(): number;
  70518. /**
  70519. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70520. * @returns the scaled intensity in intensity mode unit
  70521. */
  70522. getScaledIntensity(): number;
  70523. /**
  70524. * Returns a new Light object, named "name", from the current one.
  70525. * @param name The name of the cloned light
  70526. * @returns the new created light
  70527. */
  70528. clone(name: string): Nullable<Light>;
  70529. /**
  70530. * Serializes the current light into a Serialization object.
  70531. * @returns the serialized object.
  70532. */
  70533. serialize(): any;
  70534. /**
  70535. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70536. * This new light is named "name" and added to the passed scene.
  70537. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70538. * @param name The friendly name of the light
  70539. * @param scene The scene the new light will belong to
  70540. * @returns the constructor function
  70541. */
  70542. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70543. /**
  70544. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70545. * @param parsedLight The JSON representation of the light
  70546. * @param scene The scene to create the parsed light in
  70547. * @returns the created light after parsing
  70548. */
  70549. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70550. private _hookArrayForExcluded;
  70551. private _hookArrayForIncludedOnly;
  70552. private _resyncMeshes;
  70553. /**
  70554. * Forces the meshes to update their light related information in their rendering used effects
  70555. * @hidden Internal Use Only
  70556. */
  70557. _markMeshesAsLightDirty(): void;
  70558. /**
  70559. * Recomputes the cached photometric scale if needed.
  70560. */
  70561. private _computePhotometricScale;
  70562. /**
  70563. * Returns the Photometric Scale according to the light type and intensity mode.
  70564. */
  70565. private _getPhotometricScale;
  70566. /**
  70567. * Reorder the light in the scene according to their defined priority.
  70568. * @hidden Internal Use Only
  70569. */
  70570. _reorderLightsInScene(): void;
  70571. /**
  70572. * Prepares the list of defines specific to the light type.
  70573. * @param defines the list of defines
  70574. * @param lightIndex defines the index of the light for the effect
  70575. */
  70576. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70577. }
  70578. }
  70579. declare module BABYLON {
  70580. /**
  70581. * Interface used to define Action
  70582. */
  70583. export interface IAction {
  70584. /**
  70585. * Trigger for the action
  70586. */
  70587. trigger: number;
  70588. /** Options of the trigger */
  70589. triggerOptions: any;
  70590. /**
  70591. * Gets the trigger parameters
  70592. * @returns the trigger parameters
  70593. */
  70594. getTriggerParameter(): any;
  70595. /**
  70596. * Internal only - executes current action event
  70597. * @hidden
  70598. */
  70599. _executeCurrent(evt?: ActionEvent): void;
  70600. /**
  70601. * Serialize placeholder for child classes
  70602. * @param parent of child
  70603. * @returns the serialized object
  70604. */
  70605. serialize(parent: any): any;
  70606. /**
  70607. * Internal only
  70608. * @hidden
  70609. */
  70610. _prepare(): void;
  70611. /**
  70612. * Internal only - manager for action
  70613. * @hidden
  70614. */
  70615. _actionManager: AbstractActionManager;
  70616. }
  70617. /**
  70618. * The action to be carried out following a trigger
  70619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70620. */
  70621. export class Action implements IAction {
  70622. /** the trigger, with or without parameters, for the action */
  70623. triggerOptions: any;
  70624. /**
  70625. * Trigger for the action
  70626. */
  70627. trigger: number;
  70628. /**
  70629. * Internal only - manager for action
  70630. * @hidden
  70631. */
  70632. _actionManager: ActionManager;
  70633. private _nextActiveAction;
  70634. private _child;
  70635. private _condition?;
  70636. private _triggerParameter;
  70637. /**
  70638. * An event triggered prior to action being executed.
  70639. */
  70640. onBeforeExecuteObservable: Observable<Action>;
  70641. /**
  70642. * Creates a new Action
  70643. * @param triggerOptions the trigger, with or without parameters, for the action
  70644. * @param condition an optional determinant of action
  70645. */
  70646. constructor(
  70647. /** the trigger, with or without parameters, for the action */
  70648. triggerOptions: any, condition?: Condition);
  70649. /**
  70650. * Internal only
  70651. * @hidden
  70652. */
  70653. _prepare(): void;
  70654. /**
  70655. * Gets the trigger parameters
  70656. * @returns the trigger parameters
  70657. */
  70658. getTriggerParameter(): any;
  70659. /**
  70660. * Internal only - executes current action event
  70661. * @hidden
  70662. */
  70663. _executeCurrent(evt?: ActionEvent): void;
  70664. /**
  70665. * Execute placeholder for child classes
  70666. * @param evt optional action event
  70667. */
  70668. execute(evt?: ActionEvent): void;
  70669. /**
  70670. * Skips to next active action
  70671. */
  70672. skipToNextActiveAction(): void;
  70673. /**
  70674. * Adds action to chain of actions, may be a DoNothingAction
  70675. * @param action defines the next action to execute
  70676. * @returns The action passed in
  70677. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70678. */
  70679. then(action: Action): Action;
  70680. /**
  70681. * Internal only
  70682. * @hidden
  70683. */
  70684. _getProperty(propertyPath: string): string;
  70685. /**
  70686. * Internal only
  70687. * @hidden
  70688. */
  70689. _getEffectiveTarget(target: any, propertyPath: string): any;
  70690. /**
  70691. * Serialize placeholder for child classes
  70692. * @param parent of child
  70693. * @returns the serialized object
  70694. */
  70695. serialize(parent: any): any;
  70696. /**
  70697. * Internal only called by serialize
  70698. * @hidden
  70699. */
  70700. protected _serialize(serializedAction: any, parent?: any): any;
  70701. /**
  70702. * Internal only
  70703. * @hidden
  70704. */
  70705. static _SerializeValueAsString: (value: any) => string;
  70706. /**
  70707. * Internal only
  70708. * @hidden
  70709. */
  70710. static _GetTargetProperty: (target: Scene | Node) => {
  70711. name: string;
  70712. targetType: string;
  70713. value: string;
  70714. };
  70715. }
  70716. }
  70717. declare module BABYLON {
  70718. /**
  70719. * A Condition applied to an Action
  70720. */
  70721. export class Condition {
  70722. /**
  70723. * Internal only - manager for action
  70724. * @hidden
  70725. */
  70726. _actionManager: ActionManager;
  70727. /**
  70728. * Internal only
  70729. * @hidden
  70730. */
  70731. _evaluationId: number;
  70732. /**
  70733. * Internal only
  70734. * @hidden
  70735. */
  70736. _currentResult: boolean;
  70737. /**
  70738. * Creates a new Condition
  70739. * @param actionManager the manager of the action the condition is applied to
  70740. */
  70741. constructor(actionManager: ActionManager);
  70742. /**
  70743. * Check if the current condition is valid
  70744. * @returns a boolean
  70745. */
  70746. isValid(): boolean;
  70747. /**
  70748. * Internal only
  70749. * @hidden
  70750. */
  70751. _getProperty(propertyPath: string): string;
  70752. /**
  70753. * Internal only
  70754. * @hidden
  70755. */
  70756. _getEffectiveTarget(target: any, propertyPath: string): any;
  70757. /**
  70758. * Serialize placeholder for child classes
  70759. * @returns the serialized object
  70760. */
  70761. serialize(): any;
  70762. /**
  70763. * Internal only
  70764. * @hidden
  70765. */
  70766. protected _serialize(serializedCondition: any): any;
  70767. }
  70768. /**
  70769. * Defines specific conditional operators as extensions of Condition
  70770. */
  70771. export class ValueCondition extends Condition {
  70772. /** path to specify the property of the target the conditional operator uses */
  70773. propertyPath: string;
  70774. /** the value compared by the conditional operator against the current value of the property */
  70775. value: any;
  70776. /** the conditional operator, default ValueCondition.IsEqual */
  70777. operator: number;
  70778. /**
  70779. * Internal only
  70780. * @hidden
  70781. */
  70782. private static _IsEqual;
  70783. /**
  70784. * Internal only
  70785. * @hidden
  70786. */
  70787. private static _IsDifferent;
  70788. /**
  70789. * Internal only
  70790. * @hidden
  70791. */
  70792. private static _IsGreater;
  70793. /**
  70794. * Internal only
  70795. * @hidden
  70796. */
  70797. private static _IsLesser;
  70798. /**
  70799. * returns the number for IsEqual
  70800. */
  70801. static readonly IsEqual: number;
  70802. /**
  70803. * Returns the number for IsDifferent
  70804. */
  70805. static readonly IsDifferent: number;
  70806. /**
  70807. * Returns the number for IsGreater
  70808. */
  70809. static readonly IsGreater: number;
  70810. /**
  70811. * Returns the number for IsLesser
  70812. */
  70813. static readonly IsLesser: number;
  70814. /**
  70815. * Internal only The action manager for the condition
  70816. * @hidden
  70817. */
  70818. _actionManager: ActionManager;
  70819. /**
  70820. * Internal only
  70821. * @hidden
  70822. */
  70823. private _target;
  70824. /**
  70825. * Internal only
  70826. * @hidden
  70827. */
  70828. private _effectiveTarget;
  70829. /**
  70830. * Internal only
  70831. * @hidden
  70832. */
  70833. private _property;
  70834. /**
  70835. * Creates a new ValueCondition
  70836. * @param actionManager manager for the action the condition applies to
  70837. * @param target for the action
  70838. * @param propertyPath path to specify the property of the target the conditional operator uses
  70839. * @param value the value compared by the conditional operator against the current value of the property
  70840. * @param operator the conditional operator, default ValueCondition.IsEqual
  70841. */
  70842. constructor(actionManager: ActionManager, target: any,
  70843. /** path to specify the property of the target the conditional operator uses */
  70844. propertyPath: string,
  70845. /** the value compared by the conditional operator against the current value of the property */
  70846. value: any,
  70847. /** the conditional operator, default ValueCondition.IsEqual */
  70848. operator?: number);
  70849. /**
  70850. * Compares the given value with the property value for the specified conditional operator
  70851. * @returns the result of the comparison
  70852. */
  70853. isValid(): boolean;
  70854. /**
  70855. * Serialize the ValueCondition into a JSON compatible object
  70856. * @returns serialization object
  70857. */
  70858. serialize(): any;
  70859. /**
  70860. * Gets the name of the conditional operator for the ValueCondition
  70861. * @param operator the conditional operator
  70862. * @returns the name
  70863. */
  70864. static GetOperatorName(operator: number): string;
  70865. }
  70866. /**
  70867. * Defines a predicate condition as an extension of Condition
  70868. */
  70869. export class PredicateCondition extends Condition {
  70870. /** defines the predicate function used to validate the condition */
  70871. predicate: () => boolean;
  70872. /**
  70873. * Internal only - manager for action
  70874. * @hidden
  70875. */
  70876. _actionManager: ActionManager;
  70877. /**
  70878. * Creates a new PredicateCondition
  70879. * @param actionManager manager for the action the condition applies to
  70880. * @param predicate defines the predicate function used to validate the condition
  70881. */
  70882. constructor(actionManager: ActionManager,
  70883. /** defines the predicate function used to validate the condition */
  70884. predicate: () => boolean);
  70885. /**
  70886. * @returns the validity of the predicate condition
  70887. */
  70888. isValid(): boolean;
  70889. }
  70890. /**
  70891. * Defines a state condition as an extension of Condition
  70892. */
  70893. export class StateCondition extends Condition {
  70894. /** Value to compare with target state */
  70895. value: string;
  70896. /**
  70897. * Internal only - manager for action
  70898. * @hidden
  70899. */
  70900. _actionManager: ActionManager;
  70901. /**
  70902. * Internal only
  70903. * @hidden
  70904. */
  70905. private _target;
  70906. /**
  70907. * Creates a new StateCondition
  70908. * @param actionManager manager for the action the condition applies to
  70909. * @param target of the condition
  70910. * @param value to compare with target state
  70911. */
  70912. constructor(actionManager: ActionManager, target: any,
  70913. /** Value to compare with target state */
  70914. value: string);
  70915. /**
  70916. * Gets a boolean indicating if the current condition is met
  70917. * @returns the validity of the state
  70918. */
  70919. isValid(): boolean;
  70920. /**
  70921. * Serialize the StateCondition into a JSON compatible object
  70922. * @returns serialization object
  70923. */
  70924. serialize(): any;
  70925. }
  70926. }
  70927. declare module BABYLON {
  70928. /**
  70929. * This defines an action responsible to toggle a boolean once triggered.
  70930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70931. */
  70932. export class SwitchBooleanAction extends Action {
  70933. /**
  70934. * The path to the boolean property in the target object
  70935. */
  70936. propertyPath: string;
  70937. private _target;
  70938. private _effectiveTarget;
  70939. private _property;
  70940. /**
  70941. * Instantiate the action
  70942. * @param triggerOptions defines the trigger options
  70943. * @param target defines the object containing the boolean
  70944. * @param propertyPath defines the path to the boolean property in the target object
  70945. * @param condition defines the trigger related conditions
  70946. */
  70947. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70948. /** @hidden */
  70949. _prepare(): void;
  70950. /**
  70951. * Execute the action toggle the boolean value.
  70952. */
  70953. execute(): void;
  70954. /**
  70955. * Serializes the actions and its related information.
  70956. * @param parent defines the object to serialize in
  70957. * @returns the serialized object
  70958. */
  70959. serialize(parent: any): any;
  70960. }
  70961. /**
  70962. * This defines an action responsible to set a the state field of the target
  70963. * to a desired value once triggered.
  70964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70965. */
  70966. export class SetStateAction extends Action {
  70967. /**
  70968. * The value to store in the state field.
  70969. */
  70970. value: string;
  70971. private _target;
  70972. /**
  70973. * Instantiate the action
  70974. * @param triggerOptions defines the trigger options
  70975. * @param target defines the object containing the state property
  70976. * @param value defines the value to store in the state field
  70977. * @param condition defines the trigger related conditions
  70978. */
  70979. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70980. /**
  70981. * Execute the action and store the value on the target state property.
  70982. */
  70983. execute(): void;
  70984. /**
  70985. * Serializes the actions and its related information.
  70986. * @param parent defines the object to serialize in
  70987. * @returns the serialized object
  70988. */
  70989. serialize(parent: any): any;
  70990. }
  70991. /**
  70992. * This defines an action responsible to set a property of the target
  70993. * to a desired value once triggered.
  70994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70995. */
  70996. export class SetValueAction extends Action {
  70997. /**
  70998. * The path of the property to set in the target.
  70999. */
  71000. propertyPath: string;
  71001. /**
  71002. * The value to set in the property
  71003. */
  71004. value: any;
  71005. private _target;
  71006. private _effectiveTarget;
  71007. private _property;
  71008. /**
  71009. * Instantiate the action
  71010. * @param triggerOptions defines the trigger options
  71011. * @param target defines the object containing the property
  71012. * @param propertyPath defines the path of the property to set in the target
  71013. * @param value defines the value to set in the property
  71014. * @param condition defines the trigger related conditions
  71015. */
  71016. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  71017. /** @hidden */
  71018. _prepare(): void;
  71019. /**
  71020. * Execute the action and set the targetted property to the desired value.
  71021. */
  71022. execute(): void;
  71023. /**
  71024. * Serializes the actions and its related information.
  71025. * @param parent defines the object to serialize in
  71026. * @returns the serialized object
  71027. */
  71028. serialize(parent: any): any;
  71029. }
  71030. /**
  71031. * This defines an action responsible to increment the target value
  71032. * to a desired value once triggered.
  71033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71034. */
  71035. export class IncrementValueAction extends Action {
  71036. /**
  71037. * The path of the property to increment in the target.
  71038. */
  71039. propertyPath: string;
  71040. /**
  71041. * The value we should increment the property by.
  71042. */
  71043. value: any;
  71044. private _target;
  71045. private _effectiveTarget;
  71046. private _property;
  71047. /**
  71048. * Instantiate the action
  71049. * @param triggerOptions defines the trigger options
  71050. * @param target defines the object containing the property
  71051. * @param propertyPath defines the path of the property to increment in the target
  71052. * @param value defines the value value we should increment the property by
  71053. * @param condition defines the trigger related conditions
  71054. */
  71055. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  71056. /** @hidden */
  71057. _prepare(): void;
  71058. /**
  71059. * Execute the action and increment the target of the value amount.
  71060. */
  71061. execute(): void;
  71062. /**
  71063. * Serializes the actions and its related information.
  71064. * @param parent defines the object to serialize in
  71065. * @returns the serialized object
  71066. */
  71067. serialize(parent: any): any;
  71068. }
  71069. /**
  71070. * This defines an action responsible to start an animation once triggered.
  71071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71072. */
  71073. export class PlayAnimationAction extends Action {
  71074. /**
  71075. * Where the animation should start (animation frame)
  71076. */
  71077. from: number;
  71078. /**
  71079. * Where the animation should stop (animation frame)
  71080. */
  71081. to: number;
  71082. /**
  71083. * Define if the animation should loop or stop after the first play.
  71084. */
  71085. loop?: boolean;
  71086. private _target;
  71087. /**
  71088. * Instantiate the action
  71089. * @param triggerOptions defines the trigger options
  71090. * @param target defines the target animation or animation name
  71091. * @param from defines from where the animation should start (animation frame)
  71092. * @param end defines where the animation should stop (animation frame)
  71093. * @param loop defines if the animation should loop or stop after the first play
  71094. * @param condition defines the trigger related conditions
  71095. */
  71096. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  71097. /** @hidden */
  71098. _prepare(): void;
  71099. /**
  71100. * Execute the action and play the animation.
  71101. */
  71102. execute(): void;
  71103. /**
  71104. * Serializes the actions and its related information.
  71105. * @param parent defines the object to serialize in
  71106. * @returns the serialized object
  71107. */
  71108. serialize(parent: any): any;
  71109. }
  71110. /**
  71111. * This defines an action responsible to stop an animation once triggered.
  71112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71113. */
  71114. export class StopAnimationAction extends Action {
  71115. private _target;
  71116. /**
  71117. * Instantiate the action
  71118. * @param triggerOptions defines the trigger options
  71119. * @param target defines the target animation or animation name
  71120. * @param condition defines the trigger related conditions
  71121. */
  71122. constructor(triggerOptions: any, target: any, condition?: Condition);
  71123. /** @hidden */
  71124. _prepare(): void;
  71125. /**
  71126. * Execute the action and stop the animation.
  71127. */
  71128. execute(): void;
  71129. /**
  71130. * Serializes the actions and its related information.
  71131. * @param parent defines the object to serialize in
  71132. * @returns the serialized object
  71133. */
  71134. serialize(parent: any): any;
  71135. }
  71136. /**
  71137. * This defines an action responsible that does nothing once triggered.
  71138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71139. */
  71140. export class DoNothingAction extends Action {
  71141. /**
  71142. * Instantiate the action
  71143. * @param triggerOptions defines the trigger options
  71144. * @param condition defines the trigger related conditions
  71145. */
  71146. constructor(triggerOptions?: any, condition?: Condition);
  71147. /**
  71148. * Execute the action and do nothing.
  71149. */
  71150. execute(): void;
  71151. /**
  71152. * Serializes the actions and its related information.
  71153. * @param parent defines the object to serialize in
  71154. * @returns the serialized object
  71155. */
  71156. serialize(parent: any): any;
  71157. }
  71158. /**
  71159. * This defines an action responsible to trigger several actions once triggered.
  71160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71161. */
  71162. export class CombineAction extends Action {
  71163. /**
  71164. * The list of aggregated animations to run.
  71165. */
  71166. children: Action[];
  71167. /**
  71168. * Instantiate the action
  71169. * @param triggerOptions defines the trigger options
  71170. * @param children defines the list of aggregated animations to run
  71171. * @param condition defines the trigger related conditions
  71172. */
  71173. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71174. /** @hidden */
  71175. _prepare(): void;
  71176. /**
  71177. * Execute the action and executes all the aggregated actions.
  71178. */
  71179. execute(evt: ActionEvent): void;
  71180. /**
  71181. * Serializes the actions and its related information.
  71182. * @param parent defines the object to serialize in
  71183. * @returns the serialized object
  71184. */
  71185. serialize(parent: any): any;
  71186. }
  71187. /**
  71188. * This defines an action responsible to run code (external event) once triggered.
  71189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71190. */
  71191. export class ExecuteCodeAction extends Action {
  71192. /**
  71193. * The callback function to run.
  71194. */
  71195. func: (evt: ActionEvent) => void;
  71196. /**
  71197. * Instantiate the action
  71198. * @param triggerOptions defines the trigger options
  71199. * @param func defines the callback function to run
  71200. * @param condition defines the trigger related conditions
  71201. */
  71202. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71203. /**
  71204. * Execute the action and run the attached code.
  71205. */
  71206. execute(evt: ActionEvent): void;
  71207. }
  71208. /**
  71209. * This defines an action responsible to set the parent property of the target once triggered.
  71210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71211. */
  71212. export class SetParentAction extends Action {
  71213. private _parent;
  71214. private _target;
  71215. /**
  71216. * Instantiate the action
  71217. * @param triggerOptions defines the trigger options
  71218. * @param target defines the target containing the parent property
  71219. * @param parent defines from where the animation should start (animation frame)
  71220. * @param condition defines the trigger related conditions
  71221. */
  71222. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71223. /** @hidden */
  71224. _prepare(): void;
  71225. /**
  71226. * Execute the action and set the parent property.
  71227. */
  71228. execute(): void;
  71229. /**
  71230. * Serializes the actions and its related information.
  71231. * @param parent defines the object to serialize in
  71232. * @returns the serialized object
  71233. */
  71234. serialize(parent: any): any;
  71235. }
  71236. }
  71237. declare module BABYLON {
  71238. /**
  71239. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71240. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71242. */
  71243. export class ActionManager extends AbstractActionManager {
  71244. /**
  71245. * Nothing
  71246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71247. */
  71248. static readonly NothingTrigger: number;
  71249. /**
  71250. * On pick
  71251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71252. */
  71253. static readonly OnPickTrigger: number;
  71254. /**
  71255. * On left pick
  71256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71257. */
  71258. static readonly OnLeftPickTrigger: number;
  71259. /**
  71260. * On right pick
  71261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71262. */
  71263. static readonly OnRightPickTrigger: number;
  71264. /**
  71265. * On center pick
  71266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71267. */
  71268. static readonly OnCenterPickTrigger: number;
  71269. /**
  71270. * On pick down
  71271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71272. */
  71273. static readonly OnPickDownTrigger: number;
  71274. /**
  71275. * On double pick
  71276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71277. */
  71278. static readonly OnDoublePickTrigger: number;
  71279. /**
  71280. * On pick up
  71281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71282. */
  71283. static readonly OnPickUpTrigger: number;
  71284. /**
  71285. * On pick out.
  71286. * This trigger will only be raised if you also declared a OnPickDown
  71287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71288. */
  71289. static readonly OnPickOutTrigger: number;
  71290. /**
  71291. * On long press
  71292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71293. */
  71294. static readonly OnLongPressTrigger: number;
  71295. /**
  71296. * On pointer over
  71297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71298. */
  71299. static readonly OnPointerOverTrigger: number;
  71300. /**
  71301. * On pointer out
  71302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71303. */
  71304. static readonly OnPointerOutTrigger: number;
  71305. /**
  71306. * On every frame
  71307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71308. */
  71309. static readonly OnEveryFrameTrigger: number;
  71310. /**
  71311. * On intersection enter
  71312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71313. */
  71314. static readonly OnIntersectionEnterTrigger: number;
  71315. /**
  71316. * On intersection exit
  71317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71318. */
  71319. static readonly OnIntersectionExitTrigger: number;
  71320. /**
  71321. * On key down
  71322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71323. */
  71324. static readonly OnKeyDownTrigger: number;
  71325. /**
  71326. * On key up
  71327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71328. */
  71329. static readonly OnKeyUpTrigger: number;
  71330. private _scene;
  71331. /**
  71332. * Creates a new action manager
  71333. * @param scene defines the hosting scene
  71334. */
  71335. constructor(scene: Scene);
  71336. /**
  71337. * Releases all associated resources
  71338. */
  71339. dispose(): void;
  71340. /**
  71341. * Gets hosting scene
  71342. * @returns the hosting scene
  71343. */
  71344. getScene(): Scene;
  71345. /**
  71346. * Does this action manager handles actions of any of the given triggers
  71347. * @param triggers defines the triggers to be tested
  71348. * @return a boolean indicating whether one (or more) of the triggers is handled
  71349. */
  71350. hasSpecificTriggers(triggers: number[]): boolean;
  71351. /**
  71352. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71353. * speed.
  71354. * @param triggerA defines the trigger to be tested
  71355. * @param triggerB defines the trigger to be tested
  71356. * @return a boolean indicating whether one (or more) of the triggers is handled
  71357. */
  71358. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71359. /**
  71360. * Does this action manager handles actions of a given trigger
  71361. * @param trigger defines the trigger to be tested
  71362. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71363. * @return whether the trigger is handled
  71364. */
  71365. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71366. /**
  71367. * Does this action manager has pointer triggers
  71368. */
  71369. readonly hasPointerTriggers: boolean;
  71370. /**
  71371. * Does this action manager has pick triggers
  71372. */
  71373. readonly hasPickTriggers: boolean;
  71374. /**
  71375. * Registers an action to this action manager
  71376. * @param action defines the action to be registered
  71377. * @return the action amended (prepared) after registration
  71378. */
  71379. registerAction(action: IAction): Nullable<IAction>;
  71380. /**
  71381. * Unregisters an action to this action manager
  71382. * @param action defines the action to be unregistered
  71383. * @return a boolean indicating whether the action has been unregistered
  71384. */
  71385. unregisterAction(action: IAction): Boolean;
  71386. /**
  71387. * Process a specific trigger
  71388. * @param trigger defines the trigger to process
  71389. * @param evt defines the event details to be processed
  71390. */
  71391. processTrigger(trigger: number, evt?: IActionEvent): void;
  71392. /** @hidden */
  71393. _getEffectiveTarget(target: any, propertyPath: string): any;
  71394. /** @hidden */
  71395. _getProperty(propertyPath: string): string;
  71396. /**
  71397. * Serialize this manager to a JSON object
  71398. * @param name defines the property name to store this manager
  71399. * @returns a JSON representation of this manager
  71400. */
  71401. serialize(name: string): any;
  71402. /**
  71403. * Creates a new ActionManager from a JSON data
  71404. * @param parsedActions defines the JSON data to read from
  71405. * @param object defines the hosting mesh
  71406. * @param scene defines the hosting scene
  71407. */
  71408. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71409. /**
  71410. * Get a trigger name by index
  71411. * @param trigger defines the trigger index
  71412. * @returns a trigger name
  71413. */
  71414. static GetTriggerName(trigger: number): string;
  71415. }
  71416. }
  71417. declare module BABYLON {
  71418. /**
  71419. * Class representing a ray with position and direction
  71420. */
  71421. export class Ray {
  71422. /** origin point */
  71423. origin: Vector3;
  71424. /** direction */
  71425. direction: Vector3;
  71426. /** length of the ray */
  71427. length: number;
  71428. private static readonly TmpVector3;
  71429. private _tmpRay;
  71430. /**
  71431. * Creates a new ray
  71432. * @param origin origin point
  71433. * @param direction direction
  71434. * @param length length of the ray
  71435. */
  71436. constructor(
  71437. /** origin point */
  71438. origin: Vector3,
  71439. /** direction */
  71440. direction: Vector3,
  71441. /** length of the ray */
  71442. length?: number);
  71443. /**
  71444. * Checks if the ray intersects a box
  71445. * @param minimum bound of the box
  71446. * @param maximum bound of the box
  71447. * @param intersectionTreshold extra extend to be added to the box in all direction
  71448. * @returns if the box was hit
  71449. */
  71450. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71451. /**
  71452. * Checks if the ray intersects a box
  71453. * @param box the bounding box to check
  71454. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71455. * @returns if the box was hit
  71456. */
  71457. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71458. /**
  71459. * If the ray hits a sphere
  71460. * @param sphere the bounding sphere to check
  71461. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71462. * @returns true if it hits the sphere
  71463. */
  71464. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71465. /**
  71466. * If the ray hits a triange
  71467. * @param vertex0 triangle vertex
  71468. * @param vertex1 triangle vertex
  71469. * @param vertex2 triangle vertex
  71470. * @returns intersection information if hit
  71471. */
  71472. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71473. /**
  71474. * Checks if ray intersects a plane
  71475. * @param plane the plane to check
  71476. * @returns the distance away it was hit
  71477. */
  71478. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71479. /**
  71480. * Checks if ray intersects a mesh
  71481. * @param mesh the mesh to check
  71482. * @param fastCheck if only the bounding box should checked
  71483. * @returns picking info of the intersecton
  71484. */
  71485. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71486. /**
  71487. * Checks if ray intersects a mesh
  71488. * @param meshes the meshes to check
  71489. * @param fastCheck if only the bounding box should checked
  71490. * @param results array to store result in
  71491. * @returns Array of picking infos
  71492. */
  71493. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71494. private _comparePickingInfo;
  71495. private static smallnum;
  71496. private static rayl;
  71497. /**
  71498. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71499. * @param sega the first point of the segment to test the intersection against
  71500. * @param segb the second point of the segment to test the intersection against
  71501. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71502. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71503. */
  71504. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71505. /**
  71506. * Update the ray from viewport position
  71507. * @param x position
  71508. * @param y y position
  71509. * @param viewportWidth viewport width
  71510. * @param viewportHeight viewport height
  71511. * @param world world matrix
  71512. * @param view view matrix
  71513. * @param projection projection matrix
  71514. * @returns this ray updated
  71515. */
  71516. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71517. /**
  71518. * Creates a ray with origin and direction of 0,0,0
  71519. * @returns the new ray
  71520. */
  71521. static Zero(): Ray;
  71522. /**
  71523. * Creates a new ray from screen space and viewport
  71524. * @param x position
  71525. * @param y y position
  71526. * @param viewportWidth viewport width
  71527. * @param viewportHeight viewport height
  71528. * @param world world matrix
  71529. * @param view view matrix
  71530. * @param projection projection matrix
  71531. * @returns new ray
  71532. */
  71533. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71534. /**
  71535. * 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
  71536. * transformed to the given world matrix.
  71537. * @param origin The origin point
  71538. * @param end The end point
  71539. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71540. * @returns the new ray
  71541. */
  71542. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71543. /**
  71544. * Transforms a ray by a matrix
  71545. * @param ray ray to transform
  71546. * @param matrix matrix to apply
  71547. * @returns the resulting new ray
  71548. */
  71549. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71550. /**
  71551. * Transforms a ray by a matrix
  71552. * @param ray ray to transform
  71553. * @param matrix matrix to apply
  71554. * @param result ray to store result in
  71555. */
  71556. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71557. /**
  71558. * Unproject a ray from screen space to object space
  71559. * @param sourceX defines the screen space x coordinate to use
  71560. * @param sourceY defines the screen space y coordinate to use
  71561. * @param viewportWidth defines the current width of the viewport
  71562. * @param viewportHeight defines the current height of the viewport
  71563. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71564. * @param view defines the view matrix to use
  71565. * @param projection defines the projection matrix to use
  71566. */
  71567. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71568. }
  71569. /**
  71570. * Type used to define predicate used to select faces when a mesh intersection is detected
  71571. */
  71572. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71573. interface Scene {
  71574. /** @hidden */
  71575. _tempPickingRay: Nullable<Ray>;
  71576. /** @hidden */
  71577. _cachedRayForTransform: Ray;
  71578. /** @hidden */
  71579. _pickWithRayInverseMatrix: Matrix;
  71580. /** @hidden */
  71581. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71582. /** @hidden */
  71583. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71584. }
  71585. }
  71586. declare module BABYLON {
  71587. /**
  71588. * Groups all the scene component constants in one place to ease maintenance.
  71589. * @hidden
  71590. */
  71591. export class SceneComponentConstants {
  71592. static readonly NAME_EFFECTLAYER: string;
  71593. static readonly NAME_LAYER: string;
  71594. static readonly NAME_LENSFLARESYSTEM: string;
  71595. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71596. static readonly NAME_PARTICLESYSTEM: string;
  71597. static readonly NAME_GAMEPAD: string;
  71598. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71599. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71600. static readonly NAME_DEPTHRENDERER: string;
  71601. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71602. static readonly NAME_SPRITE: string;
  71603. static readonly NAME_OUTLINERENDERER: string;
  71604. static readonly NAME_PROCEDURALTEXTURE: string;
  71605. static readonly NAME_SHADOWGENERATOR: string;
  71606. static readonly NAME_OCTREE: string;
  71607. static readonly NAME_PHYSICSENGINE: string;
  71608. static readonly NAME_AUDIO: string;
  71609. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71610. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71611. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71612. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71613. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71614. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71615. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71616. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71617. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71618. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71619. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71620. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71621. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71622. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71623. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71624. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71625. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71626. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71627. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71628. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71629. static readonly STEP_AFTERRENDER_AUDIO: number;
  71630. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71631. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71632. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71633. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71634. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71635. static readonly STEP_POINTERMOVE_SPRITE: number;
  71636. static readonly STEP_POINTERDOWN_SPRITE: number;
  71637. static readonly STEP_POINTERUP_SPRITE: number;
  71638. }
  71639. /**
  71640. * This represents a scene component.
  71641. *
  71642. * This is used to decouple the dependency the scene is having on the different workloads like
  71643. * layers, post processes...
  71644. */
  71645. export interface ISceneComponent {
  71646. /**
  71647. * The name of the component. Each component must have a unique name.
  71648. */
  71649. name: string;
  71650. /**
  71651. * The scene the component belongs to.
  71652. */
  71653. scene: Scene;
  71654. /**
  71655. * Register the component to one instance of a scene.
  71656. */
  71657. register(): void;
  71658. /**
  71659. * Rebuilds the elements related to this component in case of
  71660. * context lost for instance.
  71661. */
  71662. rebuild(): void;
  71663. /**
  71664. * Disposes the component and the associated ressources.
  71665. */
  71666. dispose(): void;
  71667. }
  71668. /**
  71669. * This represents a SERIALIZABLE scene component.
  71670. *
  71671. * This extends Scene Component to add Serialization methods on top.
  71672. */
  71673. export interface ISceneSerializableComponent extends ISceneComponent {
  71674. /**
  71675. * Adds all the element from the container to the scene
  71676. * @param container the container holding the elements
  71677. */
  71678. addFromContainer(container: AbstractScene): void;
  71679. /**
  71680. * Removes all the elements in the container from the scene
  71681. * @param container contains the elements to remove
  71682. * @param dispose if the removed element should be disposed (default: false)
  71683. */
  71684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71685. /**
  71686. * Serializes the component data to the specified json object
  71687. * @param serializationObject The object to serialize to
  71688. */
  71689. serialize(serializationObject: any): void;
  71690. }
  71691. /**
  71692. * Strong typing of a Mesh related stage step action
  71693. */
  71694. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71695. /**
  71696. * Strong typing of a Evaluate Sub Mesh related stage step action
  71697. */
  71698. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71699. /**
  71700. * Strong typing of a Active Mesh related stage step action
  71701. */
  71702. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71703. /**
  71704. * Strong typing of a Camera related stage step action
  71705. */
  71706. export type CameraStageAction = (camera: Camera) => void;
  71707. /**
  71708. * Strong typing of a Camera Frame buffer related stage step action
  71709. */
  71710. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71711. /**
  71712. * Strong typing of a Render Target related stage step action
  71713. */
  71714. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71715. /**
  71716. * Strong typing of a RenderingGroup related stage step action
  71717. */
  71718. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71719. /**
  71720. * Strong typing of a Mesh Render related stage step action
  71721. */
  71722. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71723. /**
  71724. * Strong typing of a simple stage step action
  71725. */
  71726. export type SimpleStageAction = () => void;
  71727. /**
  71728. * Strong typing of a render target action.
  71729. */
  71730. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71731. /**
  71732. * Strong typing of a pointer move action.
  71733. */
  71734. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71735. /**
  71736. * Strong typing of a pointer up/down action.
  71737. */
  71738. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71739. /**
  71740. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71741. * @hidden
  71742. */
  71743. export class Stage<T extends Function> extends Array<{
  71744. index: number;
  71745. component: ISceneComponent;
  71746. action: T;
  71747. }> {
  71748. /**
  71749. * Hide ctor from the rest of the world.
  71750. * @param items The items to add.
  71751. */
  71752. private constructor();
  71753. /**
  71754. * Creates a new Stage.
  71755. * @returns A new instance of a Stage
  71756. */
  71757. static Create<T extends Function>(): Stage<T>;
  71758. /**
  71759. * Registers a step in an ordered way in the targeted stage.
  71760. * @param index Defines the position to register the step in
  71761. * @param component Defines the component attached to the step
  71762. * @param action Defines the action to launch during the step
  71763. */
  71764. registerStep(index: number, component: ISceneComponent, action: T): void;
  71765. /**
  71766. * Clears all the steps from the stage.
  71767. */
  71768. clear(): void;
  71769. }
  71770. }
  71771. declare module BABYLON {
  71772. interface Scene {
  71773. /** @hidden */
  71774. _pointerOverSprite: Nullable<Sprite>;
  71775. /** @hidden */
  71776. _pickedDownSprite: Nullable<Sprite>;
  71777. /** @hidden */
  71778. _tempSpritePickingRay: Nullable<Ray>;
  71779. /**
  71780. * All of the sprite managers added to this scene
  71781. * @see http://doc.babylonjs.com/babylon101/sprites
  71782. */
  71783. spriteManagers: Array<ISpriteManager>;
  71784. /**
  71785. * An event triggered when sprites rendering is about to start
  71786. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71787. */
  71788. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71789. /**
  71790. * An event triggered when sprites rendering is done
  71791. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71792. */
  71793. onAfterSpritesRenderingObservable: Observable<Scene>;
  71794. /** @hidden */
  71795. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71796. /** Launch a ray to try to pick a sprite in the scene
  71797. * @param x position on screen
  71798. * @param y position on screen
  71799. * @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
  71800. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71801. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71802. * @returns a PickingInfo
  71803. */
  71804. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71805. /** Use the given ray to pick a sprite in the scene
  71806. * @param ray The ray (in world space) to use to pick meshes
  71807. * @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
  71808. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71809. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71810. * @returns a PickingInfo
  71811. */
  71812. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71813. /**
  71814. * Force the sprite under the pointer
  71815. * @param sprite defines the sprite to use
  71816. */
  71817. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71818. /**
  71819. * Gets the sprite under the pointer
  71820. * @returns a Sprite or null if no sprite is under the pointer
  71821. */
  71822. getPointerOverSprite(): Nullable<Sprite>;
  71823. }
  71824. /**
  71825. * Defines the sprite scene component responsible to manage sprites
  71826. * in a given scene.
  71827. */
  71828. export class SpriteSceneComponent implements ISceneComponent {
  71829. /**
  71830. * The component name helpfull to identify the component in the list of scene components.
  71831. */
  71832. readonly name: string;
  71833. /**
  71834. * The scene the component belongs to.
  71835. */
  71836. scene: Scene;
  71837. /** @hidden */
  71838. private _spritePredicate;
  71839. /**
  71840. * Creates a new instance of the component for the given scene
  71841. * @param scene Defines the scene to register the component in
  71842. */
  71843. constructor(scene: Scene);
  71844. /**
  71845. * Registers the component in a given scene
  71846. */
  71847. register(): void;
  71848. /**
  71849. * Rebuilds the elements related to this component in case of
  71850. * context lost for instance.
  71851. */
  71852. rebuild(): void;
  71853. /**
  71854. * Disposes the component and the associated ressources.
  71855. */
  71856. dispose(): void;
  71857. private _pickSpriteButKeepRay;
  71858. private _pointerMove;
  71859. private _pointerDown;
  71860. private _pointerUp;
  71861. }
  71862. }
  71863. declare module BABYLON {
  71864. /** @hidden */
  71865. export var fogFragmentDeclaration: {
  71866. name: string;
  71867. shader: string;
  71868. };
  71869. }
  71870. declare module BABYLON {
  71871. /** @hidden */
  71872. export var fogFragment: {
  71873. name: string;
  71874. shader: string;
  71875. };
  71876. }
  71877. declare module BABYLON {
  71878. /** @hidden */
  71879. export var spritesPixelShader: {
  71880. name: string;
  71881. shader: string;
  71882. };
  71883. }
  71884. declare module BABYLON {
  71885. /** @hidden */
  71886. export var fogVertexDeclaration: {
  71887. name: string;
  71888. shader: string;
  71889. };
  71890. }
  71891. declare module BABYLON {
  71892. /** @hidden */
  71893. export var spritesVertexShader: {
  71894. name: string;
  71895. shader: string;
  71896. };
  71897. }
  71898. declare module BABYLON {
  71899. /**
  71900. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71901. */
  71902. export interface ISpriteManager extends IDisposable {
  71903. /**
  71904. * Restricts the camera to viewing objects with the same layerMask.
  71905. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71906. */
  71907. layerMask: number;
  71908. /**
  71909. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71910. */
  71911. isPickable: boolean;
  71912. /**
  71913. * Specifies the rendering group id for this mesh (0 by default)
  71914. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71915. */
  71916. renderingGroupId: number;
  71917. /**
  71918. * Defines the list of sprites managed by the manager.
  71919. */
  71920. sprites: Array<Sprite>;
  71921. /**
  71922. * Tests the intersection of a sprite with a specific ray.
  71923. * @param ray The ray we are sending to test the collision
  71924. * @param camera The camera space we are sending rays in
  71925. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71926. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71927. * @returns picking info or null.
  71928. */
  71929. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71930. /**
  71931. * Renders the list of sprites on screen.
  71932. */
  71933. render(): void;
  71934. }
  71935. /**
  71936. * Class used to manage multiple sprites on the same spritesheet
  71937. * @see http://doc.babylonjs.com/babylon101/sprites
  71938. */
  71939. export class SpriteManager implements ISpriteManager {
  71940. /** defines the manager's name */
  71941. name: string;
  71942. /** Gets the list of sprites */
  71943. sprites: Sprite[];
  71944. /** Gets or sets the rendering group id (0 by default) */
  71945. renderingGroupId: number;
  71946. /** Gets or sets camera layer mask */
  71947. layerMask: number;
  71948. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71949. fogEnabled: boolean;
  71950. /** Gets or sets a boolean indicating if the sprites are pickable */
  71951. isPickable: boolean;
  71952. /** Defines the default width of a cell in the spritesheet */
  71953. cellWidth: number;
  71954. /** Defines the default height of a cell in the spritesheet */
  71955. cellHeight: number;
  71956. /**
  71957. * An event triggered when the manager is disposed.
  71958. */
  71959. onDisposeObservable: Observable<SpriteManager>;
  71960. private _onDisposeObserver;
  71961. /**
  71962. * Callback called when the manager is disposed
  71963. */
  71964. onDispose: () => void;
  71965. private _capacity;
  71966. private _spriteTexture;
  71967. private _epsilon;
  71968. private _scene;
  71969. private _vertexData;
  71970. private _buffer;
  71971. private _vertexBuffers;
  71972. private _indexBuffer;
  71973. private _effectBase;
  71974. private _effectFog;
  71975. /**
  71976. * Gets or sets the spritesheet texture
  71977. */
  71978. texture: Texture;
  71979. /**
  71980. * Creates a new sprite manager
  71981. * @param name defines the manager's name
  71982. * @param imgUrl defines the sprite sheet url
  71983. * @param capacity defines the maximum allowed number of sprites
  71984. * @param cellSize defines the size of a sprite cell
  71985. * @param scene defines the hosting scene
  71986. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71987. * @param samplingMode defines the smapling mode to use with spritesheet
  71988. */
  71989. constructor(
  71990. /** defines the manager's name */
  71991. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71992. private _appendSpriteVertex;
  71993. /**
  71994. * Intersects the sprites with a ray
  71995. * @param ray defines the ray to intersect with
  71996. * @param camera defines the current active camera
  71997. * @param predicate defines a predicate used to select candidate sprites
  71998. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71999. * @returns null if no hit or a PickingInfo
  72000. */
  72001. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  72002. /**
  72003. * Render all child sprites
  72004. */
  72005. render(): void;
  72006. /**
  72007. * Release associated resources
  72008. */
  72009. dispose(): void;
  72010. }
  72011. }
  72012. declare module BABYLON {
  72013. /**
  72014. * Class used to represent a sprite
  72015. * @see http://doc.babylonjs.com/babylon101/sprites
  72016. */
  72017. export class Sprite {
  72018. /** defines the name */
  72019. name: string;
  72020. /** Gets or sets the current world position */
  72021. position: Vector3;
  72022. /** Gets or sets the main color */
  72023. color: Color4;
  72024. /** Gets or sets the width */
  72025. width: number;
  72026. /** Gets or sets the height */
  72027. height: number;
  72028. /** Gets or sets rotation angle */
  72029. angle: number;
  72030. /** Gets or sets the cell index in the sprite sheet */
  72031. cellIndex: number;
  72032. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  72033. invertU: number;
  72034. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  72035. invertV: number;
  72036. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  72037. disposeWhenFinishedAnimating: boolean;
  72038. /** Gets the list of attached animations */
  72039. animations: Animation[];
  72040. /** Gets or sets a boolean indicating if the sprite can be picked */
  72041. isPickable: boolean;
  72042. /**
  72043. * Gets or sets the associated action manager
  72044. */
  72045. actionManager: Nullable<ActionManager>;
  72046. private _animationStarted;
  72047. private _loopAnimation;
  72048. private _fromIndex;
  72049. private _toIndex;
  72050. private _delay;
  72051. private _direction;
  72052. private _manager;
  72053. private _time;
  72054. private _onAnimationEnd;
  72055. /**
  72056. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  72057. */
  72058. isVisible: boolean;
  72059. /**
  72060. * Gets or sets the sprite size
  72061. */
  72062. size: number;
  72063. /**
  72064. * Creates a new Sprite
  72065. * @param name defines the name
  72066. * @param manager defines the manager
  72067. */
  72068. constructor(
  72069. /** defines the name */
  72070. name: string, manager: ISpriteManager);
  72071. /**
  72072. * Starts an animation
  72073. * @param from defines the initial key
  72074. * @param to defines the end key
  72075. * @param loop defines if the animation must loop
  72076. * @param delay defines the start delay (in ms)
  72077. * @param onAnimationEnd defines a callback to call when animation ends
  72078. */
  72079. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  72080. /** Stops current animation (if any) */
  72081. stopAnimation(): void;
  72082. /** @hidden */
  72083. _animate(deltaTime: number): void;
  72084. /** Release associated resources */
  72085. dispose(): void;
  72086. }
  72087. }
  72088. declare module BABYLON {
  72089. /**
  72090. * Information about the result of picking within a scene
  72091. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  72092. */
  72093. export class PickingInfo {
  72094. /** @hidden */
  72095. _pickingUnavailable: boolean;
  72096. /**
  72097. * If the pick collided with an object
  72098. */
  72099. hit: boolean;
  72100. /**
  72101. * Distance away where the pick collided
  72102. */
  72103. distance: number;
  72104. /**
  72105. * The location of pick collision
  72106. */
  72107. pickedPoint: Nullable<Vector3>;
  72108. /**
  72109. * The mesh corresponding the the pick collision
  72110. */
  72111. pickedMesh: Nullable<AbstractMesh>;
  72112. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  72113. bu: number;
  72114. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  72115. bv: number;
  72116. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  72117. faceId: number;
  72118. /** Id of the the submesh that was picked */
  72119. subMeshId: number;
  72120. /** If a sprite was picked, this will be the sprite the pick collided with */
  72121. pickedSprite: Nullable<Sprite>;
  72122. /**
  72123. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72124. */
  72125. originMesh: Nullable<AbstractMesh>;
  72126. /**
  72127. * The ray that was used to perform the picking.
  72128. */
  72129. ray: Nullable<Ray>;
  72130. /**
  72131. * Gets the normal correspodning to the face the pick collided with
  72132. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72133. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72134. * @returns The normal correspodning to the face the pick collided with
  72135. */
  72136. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72137. /**
  72138. * Gets the texture coordinates of where the pick occured
  72139. * @returns the vector containing the coordnates of the texture
  72140. */
  72141. getTextureCoordinates(): Nullable<Vector2>;
  72142. }
  72143. }
  72144. declare module BABYLON {
  72145. /**
  72146. * Gather the list of pointer event types as constants.
  72147. */
  72148. export class PointerEventTypes {
  72149. /**
  72150. * 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.
  72151. */
  72152. static readonly POINTERDOWN: number;
  72153. /**
  72154. * The pointerup event is fired when a pointer is no longer active.
  72155. */
  72156. static readonly POINTERUP: number;
  72157. /**
  72158. * The pointermove event is fired when a pointer changes coordinates.
  72159. */
  72160. static readonly POINTERMOVE: number;
  72161. /**
  72162. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72163. */
  72164. static readonly POINTERWHEEL: number;
  72165. /**
  72166. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72167. */
  72168. static readonly POINTERPICK: number;
  72169. /**
  72170. * The pointertap event is fired when a the object has been touched and released without drag.
  72171. */
  72172. static readonly POINTERTAP: number;
  72173. /**
  72174. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72175. */
  72176. static readonly POINTERDOUBLETAP: number;
  72177. }
  72178. /**
  72179. * Base class of pointer info types.
  72180. */
  72181. export class PointerInfoBase {
  72182. /**
  72183. * Defines the type of event (PointerEventTypes)
  72184. */
  72185. type: number;
  72186. /**
  72187. * Defines the related dom event
  72188. */
  72189. event: PointerEvent | MouseWheelEvent;
  72190. /**
  72191. * Instantiates the base class of pointers info.
  72192. * @param type Defines the type of event (PointerEventTypes)
  72193. * @param event Defines the related dom event
  72194. */
  72195. constructor(
  72196. /**
  72197. * Defines the type of event (PointerEventTypes)
  72198. */
  72199. type: number,
  72200. /**
  72201. * Defines the related dom event
  72202. */
  72203. event: PointerEvent | MouseWheelEvent);
  72204. }
  72205. /**
  72206. * This class is used to store pointer related info for the onPrePointerObservable event.
  72207. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72208. */
  72209. export class PointerInfoPre extends PointerInfoBase {
  72210. /**
  72211. * Ray from a pointer if availible (eg. 6dof controller)
  72212. */
  72213. ray: Nullable<Ray>;
  72214. /**
  72215. * Defines the local position of the pointer on the canvas.
  72216. */
  72217. localPosition: Vector2;
  72218. /**
  72219. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72220. */
  72221. skipOnPointerObservable: boolean;
  72222. /**
  72223. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72224. * @param type Defines the type of event (PointerEventTypes)
  72225. * @param event Defines the related dom event
  72226. * @param localX Defines the local x coordinates of the pointer when the event occured
  72227. * @param localY Defines the local y coordinates of the pointer when the event occured
  72228. */
  72229. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72230. }
  72231. /**
  72232. * This type contains all the data related to a pointer event in Babylon.js.
  72233. * 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.
  72234. */
  72235. export class PointerInfo extends PointerInfoBase {
  72236. /**
  72237. * Defines the picking info associated to the info (if any)\
  72238. */
  72239. pickInfo: Nullable<PickingInfo>;
  72240. /**
  72241. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72242. * @param type Defines the type of event (PointerEventTypes)
  72243. * @param event Defines the related dom event
  72244. * @param pickInfo Defines the picking info associated to the info (if any)\
  72245. */
  72246. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72247. /**
  72248. * Defines the picking info associated to the info (if any)\
  72249. */
  72250. pickInfo: Nullable<PickingInfo>);
  72251. }
  72252. /**
  72253. * Data relating to a touch event on the screen.
  72254. */
  72255. export interface PointerTouch {
  72256. /**
  72257. * X coordinate of touch.
  72258. */
  72259. x: number;
  72260. /**
  72261. * Y coordinate of touch.
  72262. */
  72263. y: number;
  72264. /**
  72265. * Id of touch. Unique for each finger.
  72266. */
  72267. pointerId: number;
  72268. /**
  72269. * Event type passed from DOM.
  72270. */
  72271. type: any;
  72272. }
  72273. }
  72274. declare module BABYLON {
  72275. /**
  72276. * Manage the mouse inputs to control the movement of a free camera.
  72277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72278. */
  72279. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72280. /**
  72281. * Define if touch is enabled in the mouse input
  72282. */
  72283. touchEnabled: boolean;
  72284. /**
  72285. * Defines the camera the input is attached to.
  72286. */
  72287. camera: FreeCamera;
  72288. /**
  72289. * Defines the buttons associated with the input to handle camera move.
  72290. */
  72291. buttons: number[];
  72292. /**
  72293. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72294. */
  72295. angularSensibility: number;
  72296. private _pointerInput;
  72297. private _onMouseMove;
  72298. private _observer;
  72299. private previousPosition;
  72300. /**
  72301. * Observable for when a pointer move event occurs containing the move offset
  72302. */
  72303. onPointerMovedObservable: Observable<{
  72304. offsetX: number;
  72305. offsetY: number;
  72306. }>;
  72307. /**
  72308. * @hidden
  72309. * If the camera should be rotated automatically based on pointer movement
  72310. */
  72311. _allowCameraRotation: boolean;
  72312. /**
  72313. * Manage the mouse inputs to control the movement of a free camera.
  72314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72315. * @param touchEnabled Defines if touch is enabled or not
  72316. */
  72317. constructor(
  72318. /**
  72319. * Define if touch is enabled in the mouse input
  72320. */
  72321. touchEnabled?: boolean);
  72322. /**
  72323. * Attach the input controls to a specific dom element to get the input from.
  72324. * @param element Defines the element the controls should be listened from
  72325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72326. */
  72327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72328. /**
  72329. * Called on JS contextmenu event.
  72330. * Override this method to provide functionality.
  72331. */
  72332. protected onContextMenu(evt: PointerEvent): void;
  72333. /**
  72334. * Detach the current controls from the specified dom element.
  72335. * @param element Defines the element to stop listening the inputs from
  72336. */
  72337. detachControl(element: Nullable<HTMLElement>): void;
  72338. /**
  72339. * Gets the class name of the current intput.
  72340. * @returns the class name
  72341. */
  72342. getClassName(): string;
  72343. /**
  72344. * Get the friendly name associated with the input class.
  72345. * @returns the input friendly name
  72346. */
  72347. getSimpleName(): string;
  72348. }
  72349. }
  72350. declare module BABYLON {
  72351. /**
  72352. * Manage the touch inputs to control the movement of a free camera.
  72353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72354. */
  72355. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72356. /**
  72357. * Defines the camera the input is attached to.
  72358. */
  72359. camera: FreeCamera;
  72360. /**
  72361. * Defines the touch sensibility for rotation.
  72362. * The higher the faster.
  72363. */
  72364. touchAngularSensibility: number;
  72365. /**
  72366. * Defines the touch sensibility for move.
  72367. * The higher the faster.
  72368. */
  72369. touchMoveSensibility: number;
  72370. private _offsetX;
  72371. private _offsetY;
  72372. private _pointerPressed;
  72373. private _pointerInput;
  72374. private _observer;
  72375. private _onLostFocus;
  72376. /**
  72377. * Attach the input controls to a specific dom element to get the input from.
  72378. * @param element Defines the element the controls should be listened from
  72379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72380. */
  72381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72382. /**
  72383. * Detach the current controls from the specified dom element.
  72384. * @param element Defines the element to stop listening the inputs from
  72385. */
  72386. detachControl(element: Nullable<HTMLElement>): void;
  72387. /**
  72388. * Update the current camera state depending on the inputs that have been used this frame.
  72389. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72390. */
  72391. checkInputs(): void;
  72392. /**
  72393. * Gets the class name of the current intput.
  72394. * @returns the class name
  72395. */
  72396. getClassName(): string;
  72397. /**
  72398. * Get the friendly name associated with the input class.
  72399. * @returns the input friendly name
  72400. */
  72401. getSimpleName(): string;
  72402. }
  72403. }
  72404. declare module BABYLON {
  72405. /**
  72406. * Default Inputs manager for the FreeCamera.
  72407. * It groups all the default supported inputs for ease of use.
  72408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72409. */
  72410. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72411. /**
  72412. * @hidden
  72413. */
  72414. _mouseInput: Nullable<FreeCameraMouseInput>;
  72415. /**
  72416. * Instantiates a new FreeCameraInputsManager.
  72417. * @param camera Defines the camera the inputs belong to
  72418. */
  72419. constructor(camera: FreeCamera);
  72420. /**
  72421. * Add keyboard input support to the input manager.
  72422. * @returns the current input manager
  72423. */
  72424. addKeyboard(): FreeCameraInputsManager;
  72425. /**
  72426. * Add mouse input support to the input manager.
  72427. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72428. * @returns the current input manager
  72429. */
  72430. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72431. /**
  72432. * Removes the mouse input support from the manager
  72433. * @returns the current input manager
  72434. */
  72435. removeMouse(): FreeCameraInputsManager;
  72436. /**
  72437. * Add touch input support to the input manager.
  72438. * @returns the current input manager
  72439. */
  72440. addTouch(): FreeCameraInputsManager;
  72441. /**
  72442. * Remove all attached input methods from a camera
  72443. */
  72444. clear(): void;
  72445. }
  72446. }
  72447. declare module BABYLON {
  72448. /**
  72449. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72450. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72451. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72452. */
  72453. export class FreeCamera extends TargetCamera {
  72454. /**
  72455. * Define the collision ellipsoid of the camera.
  72456. * This is helpful to simulate a camera body like the player body around the camera
  72457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72458. */
  72459. ellipsoid: Vector3;
  72460. /**
  72461. * Define an offset for the position of the ellipsoid around the camera.
  72462. * This can be helpful to determine the center of the body near the gravity center of the body
  72463. * instead of its head.
  72464. */
  72465. ellipsoidOffset: Vector3;
  72466. /**
  72467. * Enable or disable collisions of the camera with the rest of the scene objects.
  72468. */
  72469. checkCollisions: boolean;
  72470. /**
  72471. * Enable or disable gravity on the camera.
  72472. */
  72473. applyGravity: boolean;
  72474. /**
  72475. * Define the input manager associated to the camera.
  72476. */
  72477. inputs: FreeCameraInputsManager;
  72478. /**
  72479. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72480. * Higher values reduce sensitivity.
  72481. */
  72482. /**
  72483. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72484. * Higher values reduce sensitivity.
  72485. */
  72486. angularSensibility: number;
  72487. /**
  72488. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72489. */
  72490. keysUp: number[];
  72491. /**
  72492. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72493. */
  72494. keysDown: number[];
  72495. /**
  72496. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72497. */
  72498. keysLeft: number[];
  72499. /**
  72500. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72501. */
  72502. keysRight: number[];
  72503. /**
  72504. * Event raised when the camera collide with a mesh in the scene.
  72505. */
  72506. onCollide: (collidedMesh: AbstractMesh) => void;
  72507. private _collider;
  72508. private _needMoveForGravity;
  72509. private _oldPosition;
  72510. private _diffPosition;
  72511. private _newPosition;
  72512. /** @hidden */
  72513. _localDirection: Vector3;
  72514. /** @hidden */
  72515. _transformedDirection: Vector3;
  72516. /**
  72517. * Instantiates a Free Camera.
  72518. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72519. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72520. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72521. * @param name Define the name of the camera in the scene
  72522. * @param position Define the start position of the camera in the scene
  72523. * @param scene Define the scene the camera belongs to
  72524. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72525. */
  72526. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72527. /**
  72528. * Attached controls to the current camera.
  72529. * @param element Defines the element the controls should be listened from
  72530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72531. */
  72532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72533. /**
  72534. * Detach the current controls from the camera.
  72535. * The camera will stop reacting to inputs.
  72536. * @param element Defines the element to stop listening the inputs from
  72537. */
  72538. detachControl(element: HTMLElement): void;
  72539. private _collisionMask;
  72540. /**
  72541. * Define a collision mask to limit the list of object the camera can collide with
  72542. */
  72543. collisionMask: number;
  72544. /** @hidden */
  72545. _collideWithWorld(displacement: Vector3): void;
  72546. private _onCollisionPositionChange;
  72547. /** @hidden */
  72548. _checkInputs(): void;
  72549. /** @hidden */
  72550. _decideIfNeedsToMove(): boolean;
  72551. /** @hidden */
  72552. _updatePosition(): void;
  72553. /**
  72554. * Destroy the camera and release the current resources hold by it.
  72555. */
  72556. dispose(): void;
  72557. /**
  72558. * Gets the current object class name.
  72559. * @return the class name
  72560. */
  72561. getClassName(): string;
  72562. }
  72563. }
  72564. declare module BABYLON {
  72565. /**
  72566. * Represents a gamepad control stick position
  72567. */
  72568. export class StickValues {
  72569. /**
  72570. * The x component of the control stick
  72571. */
  72572. x: number;
  72573. /**
  72574. * The y component of the control stick
  72575. */
  72576. y: number;
  72577. /**
  72578. * Initializes the gamepad x and y control stick values
  72579. * @param x The x component of the gamepad control stick value
  72580. * @param y The y component of the gamepad control stick value
  72581. */
  72582. constructor(
  72583. /**
  72584. * The x component of the control stick
  72585. */
  72586. x: number,
  72587. /**
  72588. * The y component of the control stick
  72589. */
  72590. y: number);
  72591. }
  72592. /**
  72593. * An interface which manages callbacks for gamepad button changes
  72594. */
  72595. export interface GamepadButtonChanges {
  72596. /**
  72597. * Called when a gamepad has been changed
  72598. */
  72599. changed: boolean;
  72600. /**
  72601. * Called when a gamepad press event has been triggered
  72602. */
  72603. pressChanged: boolean;
  72604. /**
  72605. * Called when a touch event has been triggered
  72606. */
  72607. touchChanged: boolean;
  72608. /**
  72609. * Called when a value has changed
  72610. */
  72611. valueChanged: boolean;
  72612. }
  72613. /**
  72614. * Represents a gamepad
  72615. */
  72616. export class Gamepad {
  72617. /**
  72618. * The id of the gamepad
  72619. */
  72620. id: string;
  72621. /**
  72622. * The index of the gamepad
  72623. */
  72624. index: number;
  72625. /**
  72626. * The browser gamepad
  72627. */
  72628. browserGamepad: any;
  72629. /**
  72630. * Specifies what type of gamepad this represents
  72631. */
  72632. type: number;
  72633. private _leftStick;
  72634. private _rightStick;
  72635. /** @hidden */
  72636. _isConnected: boolean;
  72637. private _leftStickAxisX;
  72638. private _leftStickAxisY;
  72639. private _rightStickAxisX;
  72640. private _rightStickAxisY;
  72641. /**
  72642. * Triggered when the left control stick has been changed
  72643. */
  72644. private _onleftstickchanged;
  72645. /**
  72646. * Triggered when the right control stick has been changed
  72647. */
  72648. private _onrightstickchanged;
  72649. /**
  72650. * Represents a gamepad controller
  72651. */
  72652. static GAMEPAD: number;
  72653. /**
  72654. * Represents a generic controller
  72655. */
  72656. static GENERIC: number;
  72657. /**
  72658. * Represents an XBox controller
  72659. */
  72660. static XBOX: number;
  72661. /**
  72662. * Represents a pose-enabled controller
  72663. */
  72664. static POSE_ENABLED: number;
  72665. /**
  72666. * Specifies whether the left control stick should be Y-inverted
  72667. */
  72668. protected _invertLeftStickY: boolean;
  72669. /**
  72670. * Specifies if the gamepad has been connected
  72671. */
  72672. readonly isConnected: boolean;
  72673. /**
  72674. * Initializes the gamepad
  72675. * @param id The id of the gamepad
  72676. * @param index The index of the gamepad
  72677. * @param browserGamepad The browser gamepad
  72678. * @param leftStickX The x component of the left joystick
  72679. * @param leftStickY The y component of the left joystick
  72680. * @param rightStickX The x component of the right joystick
  72681. * @param rightStickY The y component of the right joystick
  72682. */
  72683. constructor(
  72684. /**
  72685. * The id of the gamepad
  72686. */
  72687. id: string,
  72688. /**
  72689. * The index of the gamepad
  72690. */
  72691. index: number,
  72692. /**
  72693. * The browser gamepad
  72694. */
  72695. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72696. /**
  72697. * Callback triggered when the left joystick has changed
  72698. * @param callback
  72699. */
  72700. onleftstickchanged(callback: (values: StickValues) => void): void;
  72701. /**
  72702. * Callback triggered when the right joystick has changed
  72703. * @param callback
  72704. */
  72705. onrightstickchanged(callback: (values: StickValues) => void): void;
  72706. /**
  72707. * Gets the left joystick
  72708. */
  72709. /**
  72710. * Sets the left joystick values
  72711. */
  72712. leftStick: StickValues;
  72713. /**
  72714. * Gets the right joystick
  72715. */
  72716. /**
  72717. * Sets the right joystick value
  72718. */
  72719. rightStick: StickValues;
  72720. /**
  72721. * Updates the gamepad joystick positions
  72722. */
  72723. update(): void;
  72724. /**
  72725. * Disposes the gamepad
  72726. */
  72727. dispose(): void;
  72728. }
  72729. /**
  72730. * Represents a generic gamepad
  72731. */
  72732. export class GenericPad extends Gamepad {
  72733. private _buttons;
  72734. private _onbuttondown;
  72735. private _onbuttonup;
  72736. /**
  72737. * Observable triggered when a button has been pressed
  72738. */
  72739. onButtonDownObservable: Observable<number>;
  72740. /**
  72741. * Observable triggered when a button has been released
  72742. */
  72743. onButtonUpObservable: Observable<number>;
  72744. /**
  72745. * Callback triggered when a button has been pressed
  72746. * @param callback Called when a button has been pressed
  72747. */
  72748. onbuttondown(callback: (buttonPressed: number) => void): void;
  72749. /**
  72750. * Callback triggered when a button has been released
  72751. * @param callback Called when a button has been released
  72752. */
  72753. onbuttonup(callback: (buttonReleased: number) => void): void;
  72754. /**
  72755. * Initializes the generic gamepad
  72756. * @param id The id of the generic gamepad
  72757. * @param index The index of the generic gamepad
  72758. * @param browserGamepad The browser gamepad
  72759. */
  72760. constructor(id: string, index: number, browserGamepad: any);
  72761. private _setButtonValue;
  72762. /**
  72763. * Updates the generic gamepad
  72764. */
  72765. update(): void;
  72766. /**
  72767. * Disposes the generic gamepad
  72768. */
  72769. dispose(): void;
  72770. }
  72771. }
  72772. declare module BABYLON {
  72773. /**
  72774. * Defines the types of pose enabled controllers that are supported
  72775. */
  72776. export enum PoseEnabledControllerType {
  72777. /**
  72778. * HTC Vive
  72779. */
  72780. VIVE = 0,
  72781. /**
  72782. * Oculus Rift
  72783. */
  72784. OCULUS = 1,
  72785. /**
  72786. * Windows mixed reality
  72787. */
  72788. WINDOWS = 2,
  72789. /**
  72790. * Samsung gear VR
  72791. */
  72792. GEAR_VR = 3,
  72793. /**
  72794. * Google Daydream
  72795. */
  72796. DAYDREAM = 4,
  72797. /**
  72798. * Generic
  72799. */
  72800. GENERIC = 5
  72801. }
  72802. /**
  72803. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72804. */
  72805. export interface MutableGamepadButton {
  72806. /**
  72807. * Value of the button/trigger
  72808. */
  72809. value: number;
  72810. /**
  72811. * If the button/trigger is currently touched
  72812. */
  72813. touched: boolean;
  72814. /**
  72815. * If the button/trigger is currently pressed
  72816. */
  72817. pressed: boolean;
  72818. }
  72819. /**
  72820. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72821. * @hidden
  72822. */
  72823. export interface ExtendedGamepadButton extends GamepadButton {
  72824. /**
  72825. * If the button/trigger is currently pressed
  72826. */
  72827. readonly pressed: boolean;
  72828. /**
  72829. * If the button/trigger is currently touched
  72830. */
  72831. readonly touched: boolean;
  72832. /**
  72833. * Value of the button/trigger
  72834. */
  72835. readonly value: number;
  72836. }
  72837. /** @hidden */
  72838. export interface _GamePadFactory {
  72839. /**
  72840. * Returns wether or not the current gamepad can be created for this type of controller.
  72841. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72842. * @returns true if it can be created, otherwise false
  72843. */
  72844. canCreate(gamepadInfo: any): boolean;
  72845. /**
  72846. * Creates a new instance of the Gamepad.
  72847. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72848. * @returns the new gamepad instance
  72849. */
  72850. create(gamepadInfo: any): Gamepad;
  72851. }
  72852. /**
  72853. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72854. */
  72855. export class PoseEnabledControllerHelper {
  72856. /** @hidden */
  72857. static _ControllerFactories: _GamePadFactory[];
  72858. /** @hidden */
  72859. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72860. /**
  72861. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72862. * @param vrGamepad the gamepad to initialized
  72863. * @returns a vr controller of the type the gamepad identified as
  72864. */
  72865. static InitiateController(vrGamepad: any): Gamepad;
  72866. }
  72867. /**
  72868. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72869. */
  72870. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72871. private _deviceRoomPosition;
  72872. private _deviceRoomRotationQuaternion;
  72873. /**
  72874. * The device position in babylon space
  72875. */
  72876. devicePosition: Vector3;
  72877. /**
  72878. * The device rotation in babylon space
  72879. */
  72880. deviceRotationQuaternion: Quaternion;
  72881. /**
  72882. * The scale factor of the device in babylon space
  72883. */
  72884. deviceScaleFactor: number;
  72885. /**
  72886. * (Likely devicePosition should be used instead) The device position in its room space
  72887. */
  72888. position: Vector3;
  72889. /**
  72890. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72891. */
  72892. rotationQuaternion: Quaternion;
  72893. /**
  72894. * The type of controller (Eg. Windows mixed reality)
  72895. */
  72896. controllerType: PoseEnabledControllerType;
  72897. protected _calculatedPosition: Vector3;
  72898. private _calculatedRotation;
  72899. /**
  72900. * The raw pose from the device
  72901. */
  72902. rawPose: DevicePose;
  72903. private _trackPosition;
  72904. private _maxRotationDistFromHeadset;
  72905. private _draggedRoomRotation;
  72906. /**
  72907. * @hidden
  72908. */
  72909. _disableTrackPosition(fixedPosition: Vector3): void;
  72910. /**
  72911. * Internal, the mesh attached to the controller
  72912. * @hidden
  72913. */
  72914. _mesh: Nullable<AbstractMesh>;
  72915. private _poseControlledCamera;
  72916. private _leftHandSystemQuaternion;
  72917. /**
  72918. * Internal, matrix used to convert room space to babylon space
  72919. * @hidden
  72920. */
  72921. _deviceToWorld: Matrix;
  72922. /**
  72923. * Node to be used when casting a ray from the controller
  72924. * @hidden
  72925. */
  72926. _pointingPoseNode: Nullable<TransformNode>;
  72927. /**
  72928. * Name of the child mesh that can be used to cast a ray from the controller
  72929. */
  72930. static readonly POINTING_POSE: string;
  72931. /**
  72932. * Creates a new PoseEnabledController from a gamepad
  72933. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72934. */
  72935. constructor(browserGamepad: any);
  72936. private _workingMatrix;
  72937. /**
  72938. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72939. */
  72940. update(): void;
  72941. /**
  72942. * Updates only the pose device and mesh without doing any button event checking
  72943. */
  72944. protected _updatePoseAndMesh(): void;
  72945. /**
  72946. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72947. * @param poseData raw pose fromthe device
  72948. */
  72949. updateFromDevice(poseData: DevicePose): void;
  72950. /**
  72951. * @hidden
  72952. */
  72953. _meshAttachedObservable: Observable<AbstractMesh>;
  72954. /**
  72955. * Attaches a mesh to the controller
  72956. * @param mesh the mesh to be attached
  72957. */
  72958. attachToMesh(mesh: AbstractMesh): void;
  72959. /**
  72960. * Attaches the controllers mesh to a camera
  72961. * @param camera the camera the mesh should be attached to
  72962. */
  72963. attachToPoseControlledCamera(camera: TargetCamera): void;
  72964. /**
  72965. * Disposes of the controller
  72966. */
  72967. dispose(): void;
  72968. /**
  72969. * The mesh that is attached to the controller
  72970. */
  72971. readonly mesh: Nullable<AbstractMesh>;
  72972. /**
  72973. * Gets the ray of the controller in the direction the controller is pointing
  72974. * @param length the length the resulting ray should be
  72975. * @returns a ray in the direction the controller is pointing
  72976. */
  72977. getForwardRay(length?: number): Ray;
  72978. }
  72979. }
  72980. declare module BABYLON {
  72981. /**
  72982. * Defines the WebVRController object that represents controllers tracked in 3D space
  72983. */
  72984. export abstract class WebVRController extends PoseEnabledController {
  72985. /**
  72986. * Internal, the default controller model for the controller
  72987. */
  72988. protected _defaultModel: AbstractMesh;
  72989. /**
  72990. * Fired when the trigger state has changed
  72991. */
  72992. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72993. /**
  72994. * Fired when the main button state has changed
  72995. */
  72996. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72997. /**
  72998. * Fired when the secondary button state has changed
  72999. */
  73000. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  73001. /**
  73002. * Fired when the pad state has changed
  73003. */
  73004. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  73005. /**
  73006. * Fired when controllers stick values have changed
  73007. */
  73008. onPadValuesChangedObservable: Observable<StickValues>;
  73009. /**
  73010. * Array of button availible on the controller
  73011. */
  73012. protected _buttons: Array<MutableGamepadButton>;
  73013. private _onButtonStateChange;
  73014. /**
  73015. * Fired when a controller button's state has changed
  73016. * @param callback the callback containing the button that was modified
  73017. */
  73018. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  73019. /**
  73020. * X and Y axis corrisponding to the controllers joystick
  73021. */
  73022. pad: StickValues;
  73023. /**
  73024. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  73025. */
  73026. hand: string;
  73027. /**
  73028. * The default controller model for the controller
  73029. */
  73030. readonly defaultModel: AbstractMesh;
  73031. /**
  73032. * Creates a new WebVRController from a gamepad
  73033. * @param vrGamepad the gamepad that the WebVRController should be created from
  73034. */
  73035. constructor(vrGamepad: any);
  73036. /**
  73037. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  73038. */
  73039. update(): void;
  73040. /**
  73041. * Function to be called when a button is modified
  73042. */
  73043. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  73044. /**
  73045. * Loads a mesh and attaches it to the controller
  73046. * @param scene the scene the mesh should be added to
  73047. * @param meshLoaded callback for when the mesh has been loaded
  73048. */
  73049. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  73050. private _setButtonValue;
  73051. private _changes;
  73052. private _checkChanges;
  73053. /**
  73054. * Disposes of th webVRCOntroller
  73055. */
  73056. dispose(): void;
  73057. }
  73058. }
  73059. declare module BABYLON {
  73060. /**
  73061. * The HemisphericLight simulates the ambient environment light,
  73062. * so the passed direction is the light reflection direction, not the incoming direction.
  73063. */
  73064. export class HemisphericLight extends Light {
  73065. /**
  73066. * The groundColor is the light in the opposite direction to the one specified during creation.
  73067. * 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.
  73068. */
  73069. groundColor: Color3;
  73070. /**
  73071. * The light reflection direction, not the incoming direction.
  73072. */
  73073. direction: Vector3;
  73074. /**
  73075. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  73076. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  73077. * The HemisphericLight can't cast shadows.
  73078. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73079. * @param name The friendly name of the light
  73080. * @param direction The direction of the light reflection
  73081. * @param scene The scene the light belongs to
  73082. */
  73083. constructor(name: string, direction: Vector3, scene: Scene);
  73084. protected _buildUniformLayout(): void;
  73085. /**
  73086. * Returns the string "HemisphericLight".
  73087. * @return The class name
  73088. */
  73089. getClassName(): string;
  73090. /**
  73091. * Sets the HemisphericLight direction towards the passed target (Vector3).
  73092. * Returns the updated direction.
  73093. * @param target The target the direction should point to
  73094. * @return The computed direction
  73095. */
  73096. setDirectionToTarget(target: Vector3): Vector3;
  73097. /**
  73098. * Returns the shadow generator associated to the light.
  73099. * @returns Always null for hemispheric lights because it does not support shadows.
  73100. */
  73101. getShadowGenerator(): Nullable<IShadowGenerator>;
  73102. /**
  73103. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  73104. * @param effect The effect to update
  73105. * @param lightIndex The index of the light in the effect to update
  73106. * @returns The hemispheric light
  73107. */
  73108. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  73109. /**
  73110. * Computes the world matrix of the node
  73111. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73112. * @param useWasUpdatedFlag defines a reserved property
  73113. * @returns the world matrix
  73114. */
  73115. computeWorldMatrix(): Matrix;
  73116. /**
  73117. * Returns the integer 3.
  73118. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73119. */
  73120. getTypeID(): number;
  73121. /**
  73122. * Prepares the list of defines specific to the light type.
  73123. * @param defines the list of defines
  73124. * @param lightIndex defines the index of the light for the effect
  73125. */
  73126. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73127. }
  73128. }
  73129. declare module BABYLON {
  73130. /** @hidden */
  73131. export var vrMultiviewToSingleviewPixelShader: {
  73132. name: string;
  73133. shader: string;
  73134. };
  73135. }
  73136. declare module BABYLON {
  73137. /**
  73138. * Renders to multiple views with a single draw call
  73139. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73140. */
  73141. export class MultiviewRenderTarget extends RenderTargetTexture {
  73142. /**
  73143. * Creates a multiview render target
  73144. * @param scene scene used with the render target
  73145. * @param size the size of the render target (used for each view)
  73146. */
  73147. constructor(scene: Scene, size?: number | {
  73148. width: number;
  73149. height: number;
  73150. } | {
  73151. ratio: number;
  73152. });
  73153. /**
  73154. * @hidden
  73155. * @param faceIndex the face index, if its a cube texture
  73156. */
  73157. _bindFrameBuffer(faceIndex?: number): void;
  73158. /**
  73159. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73160. * @returns the view count
  73161. */
  73162. getViewCount(): number;
  73163. }
  73164. }
  73165. declare module BABYLON {
  73166. interface Engine {
  73167. /**
  73168. * Creates a new multiview render target
  73169. * @param width defines the width of the texture
  73170. * @param height defines the height of the texture
  73171. * @returns the created multiview texture
  73172. */
  73173. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73174. /**
  73175. * Binds a multiview framebuffer to be drawn to
  73176. * @param multiviewTexture texture to bind
  73177. */
  73178. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73179. }
  73180. interface Camera {
  73181. /**
  73182. * @hidden
  73183. * 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)
  73184. */
  73185. _useMultiviewToSingleView: boolean;
  73186. /**
  73187. * @hidden
  73188. * 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)
  73189. */
  73190. _multiviewTexture: Nullable<RenderTargetTexture>;
  73191. /**
  73192. * @hidden
  73193. * ensures the multiview texture of the camera exists and has the specified width/height
  73194. * @param width height to set on the multiview texture
  73195. * @param height width to set on the multiview texture
  73196. */
  73197. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73198. }
  73199. interface Scene {
  73200. /** @hidden */
  73201. _transformMatrixR: Matrix;
  73202. /** @hidden */
  73203. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73204. /** @hidden */
  73205. _createMultiviewUbo(): void;
  73206. /** @hidden */
  73207. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73208. /** @hidden */
  73209. _renderMultiviewToSingleView(camera: Camera): void;
  73210. }
  73211. }
  73212. declare module BABYLON {
  73213. /**
  73214. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73215. * This will not be used for webXR as it supports displaying texture arrays directly
  73216. */
  73217. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73218. /**
  73219. * Initializes a VRMultiviewToSingleview
  73220. * @param name name of the post process
  73221. * @param camera camera to be applied to
  73222. * @param scaleFactor scaling factor to the size of the output texture
  73223. */
  73224. constructor(name: string, camera: Camera, scaleFactor: number);
  73225. }
  73226. }
  73227. declare module BABYLON {
  73228. /**
  73229. * Defines the interface used by display changed events
  73230. */
  73231. interface IDisplayChangedEventArgs {
  73232. /** Gets the vrDisplay object (if any) */
  73233. vrDisplay: Nullable<any>;
  73234. /** Gets a boolean indicating if webVR is supported */
  73235. vrSupported: boolean;
  73236. }
  73237. interface Engine {
  73238. /** @hidden */
  73239. _vrDisplay: any;
  73240. /** @hidden */
  73241. _vrSupported: boolean;
  73242. /** @hidden */
  73243. _oldSize: Size;
  73244. /** @hidden */
  73245. _oldHardwareScaleFactor: number;
  73246. /** @hidden */
  73247. _vrExclusivePointerMode: boolean;
  73248. /** @hidden */
  73249. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73250. /** @hidden */
  73251. _onVRDisplayPointerRestricted: () => void;
  73252. /** @hidden */
  73253. _onVRDisplayPointerUnrestricted: () => void;
  73254. /** @hidden */
  73255. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73256. /** @hidden */
  73257. _onVrDisplayDisconnect: Nullable<() => void>;
  73258. /** @hidden */
  73259. _onVrDisplayPresentChange: Nullable<() => void>;
  73260. /**
  73261. * Observable signaled when VR display mode changes
  73262. */
  73263. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73264. /**
  73265. * Observable signaled when VR request present is complete
  73266. */
  73267. onVRRequestPresentComplete: Observable<boolean>;
  73268. /**
  73269. * Observable signaled when VR request present starts
  73270. */
  73271. onVRRequestPresentStart: Observable<Engine>;
  73272. /**
  73273. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73274. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73275. */
  73276. isInVRExclusivePointerMode: boolean;
  73277. /**
  73278. * Gets a boolean indicating if a webVR device was detected
  73279. * @returns true if a webVR device was detected
  73280. */
  73281. isVRDevicePresent(): boolean;
  73282. /**
  73283. * Gets the current webVR device
  73284. * @returns the current webVR device (or null)
  73285. */
  73286. getVRDevice(): any;
  73287. /**
  73288. * Initializes a webVR display and starts listening to display change events
  73289. * The onVRDisplayChangedObservable will be notified upon these changes
  73290. * @returns A promise containing a VRDisplay and if vr is supported
  73291. */
  73292. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73293. /** @hidden */
  73294. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73295. /**
  73296. * Call this function to switch to webVR mode
  73297. * Will do nothing if webVR is not supported or if there is no webVR device
  73298. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73299. */
  73300. enableVR(): void;
  73301. /** @hidden */
  73302. _onVRFullScreenTriggered(): void;
  73303. }
  73304. }
  73305. declare module BABYLON {
  73306. /**
  73307. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73308. * IMPORTANT!! The data is right-hand data.
  73309. * @export
  73310. * @interface DevicePose
  73311. */
  73312. export interface DevicePose {
  73313. /**
  73314. * The position of the device, values in array are [x,y,z].
  73315. */
  73316. readonly position: Nullable<Float32Array>;
  73317. /**
  73318. * The linearVelocity of the device, values in array are [x,y,z].
  73319. */
  73320. readonly linearVelocity: Nullable<Float32Array>;
  73321. /**
  73322. * The linearAcceleration of the device, values in array are [x,y,z].
  73323. */
  73324. readonly linearAcceleration: Nullable<Float32Array>;
  73325. /**
  73326. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73327. */
  73328. readonly orientation: Nullable<Float32Array>;
  73329. /**
  73330. * The angularVelocity of the device, values in array are [x,y,z].
  73331. */
  73332. readonly angularVelocity: Nullable<Float32Array>;
  73333. /**
  73334. * The angularAcceleration of the device, values in array are [x,y,z].
  73335. */
  73336. readonly angularAcceleration: Nullable<Float32Array>;
  73337. }
  73338. /**
  73339. * Interface representing a pose controlled object in Babylon.
  73340. * A pose controlled object has both regular pose values as well as pose values
  73341. * from an external device such as a VR head mounted display
  73342. */
  73343. export interface PoseControlled {
  73344. /**
  73345. * The position of the object in babylon space.
  73346. */
  73347. position: Vector3;
  73348. /**
  73349. * The rotation quaternion of the object in babylon space.
  73350. */
  73351. rotationQuaternion: Quaternion;
  73352. /**
  73353. * The position of the device in babylon space.
  73354. */
  73355. devicePosition?: Vector3;
  73356. /**
  73357. * The rotation quaternion of the device in babylon space.
  73358. */
  73359. deviceRotationQuaternion: Quaternion;
  73360. /**
  73361. * The raw pose coming from the device.
  73362. */
  73363. rawPose: Nullable<DevicePose>;
  73364. /**
  73365. * The scale of the device to be used when translating from device space to babylon space.
  73366. */
  73367. deviceScaleFactor: number;
  73368. /**
  73369. * Updates the poseControlled values based on the input device pose.
  73370. * @param poseData the pose data to update the object with
  73371. */
  73372. updateFromDevice(poseData: DevicePose): void;
  73373. }
  73374. /**
  73375. * Set of options to customize the webVRCamera
  73376. */
  73377. export interface WebVROptions {
  73378. /**
  73379. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73380. */
  73381. trackPosition?: boolean;
  73382. /**
  73383. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73384. */
  73385. positionScale?: number;
  73386. /**
  73387. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73388. */
  73389. displayName?: string;
  73390. /**
  73391. * Should the native controller meshes be initialized. (default: true)
  73392. */
  73393. controllerMeshes?: boolean;
  73394. /**
  73395. * Creating a default HemiLight only on controllers. (default: true)
  73396. */
  73397. defaultLightingOnControllers?: boolean;
  73398. /**
  73399. * If you don't want to use the default VR button of the helper. (default: false)
  73400. */
  73401. useCustomVRButton?: boolean;
  73402. /**
  73403. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73404. */
  73405. customVRButton?: HTMLButtonElement;
  73406. /**
  73407. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73408. */
  73409. rayLength?: number;
  73410. /**
  73411. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73412. */
  73413. defaultHeight?: number;
  73414. /**
  73415. * If multiview should be used if availible (default: false)
  73416. */
  73417. useMultiview?: boolean;
  73418. }
  73419. /**
  73420. * This represents a WebVR camera.
  73421. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73422. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73423. */
  73424. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73425. private webVROptions;
  73426. /**
  73427. * @hidden
  73428. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73429. */
  73430. _vrDevice: any;
  73431. /**
  73432. * The rawPose of the vrDevice.
  73433. */
  73434. rawPose: Nullable<DevicePose>;
  73435. private _onVREnabled;
  73436. private _specsVersion;
  73437. private _attached;
  73438. private _frameData;
  73439. protected _descendants: Array<Node>;
  73440. private _deviceRoomPosition;
  73441. /** @hidden */
  73442. _deviceRoomRotationQuaternion: Quaternion;
  73443. private _standingMatrix;
  73444. /**
  73445. * Represents device position in babylon space.
  73446. */
  73447. devicePosition: Vector3;
  73448. /**
  73449. * Represents device rotation in babylon space.
  73450. */
  73451. deviceRotationQuaternion: Quaternion;
  73452. /**
  73453. * The scale of the device to be used when translating from device space to babylon space.
  73454. */
  73455. deviceScaleFactor: number;
  73456. private _deviceToWorld;
  73457. private _worldToDevice;
  73458. /**
  73459. * References to the webVR controllers for the vrDevice.
  73460. */
  73461. controllers: Array<WebVRController>;
  73462. /**
  73463. * Emits an event when a controller is attached.
  73464. */
  73465. onControllersAttachedObservable: Observable<WebVRController[]>;
  73466. /**
  73467. * Emits an event when a controller's mesh has been loaded;
  73468. */
  73469. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73470. /**
  73471. * Emits an event when the HMD's pose has been updated.
  73472. */
  73473. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73474. private _poseSet;
  73475. /**
  73476. * If the rig cameras be used as parent instead of this camera.
  73477. */
  73478. rigParenting: boolean;
  73479. private _lightOnControllers;
  73480. private _defaultHeight?;
  73481. /**
  73482. * Instantiates a WebVRFreeCamera.
  73483. * @param name The name of the WebVRFreeCamera
  73484. * @param position The starting anchor position for the camera
  73485. * @param scene The scene the camera belongs to
  73486. * @param webVROptions a set of customizable options for the webVRCamera
  73487. */
  73488. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73489. /**
  73490. * Gets the device distance from the ground in meters.
  73491. * @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.
  73492. */
  73493. deviceDistanceToRoomGround(): number;
  73494. /**
  73495. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73496. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73497. */
  73498. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73499. /**
  73500. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73501. * @returns A promise with a boolean set to if the standing matrix is supported.
  73502. */
  73503. useStandingMatrixAsync(): Promise<boolean>;
  73504. /**
  73505. * Disposes the camera
  73506. */
  73507. dispose(): void;
  73508. /**
  73509. * Gets a vrController by name.
  73510. * @param name The name of the controller to retreive
  73511. * @returns the controller matching the name specified or null if not found
  73512. */
  73513. getControllerByName(name: string): Nullable<WebVRController>;
  73514. private _leftController;
  73515. /**
  73516. * The controller corrisponding to the users left hand.
  73517. */
  73518. readonly leftController: Nullable<WebVRController>;
  73519. private _rightController;
  73520. /**
  73521. * The controller corrisponding to the users right hand.
  73522. */
  73523. readonly rightController: Nullable<WebVRController>;
  73524. /**
  73525. * Casts a ray forward from the vrCamera's gaze.
  73526. * @param length Length of the ray (default: 100)
  73527. * @returns the ray corrisponding to the gaze
  73528. */
  73529. getForwardRay(length?: number): Ray;
  73530. /**
  73531. * @hidden
  73532. * Updates the camera based on device's frame data
  73533. */
  73534. _checkInputs(): void;
  73535. /**
  73536. * Updates the poseControlled values based on the input device pose.
  73537. * @param poseData Pose coming from the device
  73538. */
  73539. updateFromDevice(poseData: DevicePose): void;
  73540. private _htmlElementAttached;
  73541. private _detachIfAttached;
  73542. /**
  73543. * WebVR's attach control will start broadcasting frames to the device.
  73544. * Note that in certain browsers (chrome for example) this function must be called
  73545. * within a user-interaction callback. Example:
  73546. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73547. *
  73548. * @param element html element to attach the vrDevice to
  73549. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73550. */
  73551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73552. /**
  73553. * Detaches the camera from the html element and disables VR
  73554. *
  73555. * @param element html element to detach from
  73556. */
  73557. detachControl(element: HTMLElement): void;
  73558. /**
  73559. * @returns the name of this class
  73560. */
  73561. getClassName(): string;
  73562. /**
  73563. * Calls resetPose on the vrDisplay
  73564. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73565. */
  73566. resetToCurrentRotation(): void;
  73567. /**
  73568. * @hidden
  73569. * Updates the rig cameras (left and right eye)
  73570. */
  73571. _updateRigCameras(): void;
  73572. private _workingVector;
  73573. private _oneVector;
  73574. private _workingMatrix;
  73575. private updateCacheCalled;
  73576. private _correctPositionIfNotTrackPosition;
  73577. /**
  73578. * @hidden
  73579. * Updates the cached values of the camera
  73580. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73581. */
  73582. _updateCache(ignoreParentClass?: boolean): void;
  73583. /**
  73584. * @hidden
  73585. * Get current device position in babylon world
  73586. */
  73587. _computeDevicePosition(): void;
  73588. /**
  73589. * Updates the current device position and rotation in the babylon world
  73590. */
  73591. update(): void;
  73592. /**
  73593. * @hidden
  73594. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73595. * @returns an identity matrix
  73596. */
  73597. _getViewMatrix(): Matrix;
  73598. private _tmpMatrix;
  73599. /**
  73600. * This function is called by the two RIG cameras.
  73601. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73602. * @hidden
  73603. */
  73604. _getWebVRViewMatrix(): Matrix;
  73605. /** @hidden */
  73606. _getWebVRProjectionMatrix(): Matrix;
  73607. private _onGamepadConnectedObserver;
  73608. private _onGamepadDisconnectedObserver;
  73609. private _updateCacheWhenTrackingDisabledObserver;
  73610. /**
  73611. * Initializes the controllers and their meshes
  73612. */
  73613. initControllers(): void;
  73614. }
  73615. }
  73616. declare module BABYLON {
  73617. /**
  73618. * Size options for a post process
  73619. */
  73620. export type PostProcessOptions = {
  73621. width: number;
  73622. height: number;
  73623. };
  73624. /**
  73625. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73626. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73627. */
  73628. export class PostProcess {
  73629. /** Name of the PostProcess. */
  73630. name: string;
  73631. /**
  73632. * Gets or sets the unique id of the post process
  73633. */
  73634. uniqueId: number;
  73635. /**
  73636. * Width of the texture to apply the post process on
  73637. */
  73638. width: number;
  73639. /**
  73640. * Height of the texture to apply the post process on
  73641. */
  73642. height: number;
  73643. /**
  73644. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73645. * @hidden
  73646. */
  73647. _outputTexture: Nullable<InternalTexture>;
  73648. /**
  73649. * Sampling mode used by the shader
  73650. * See https://doc.babylonjs.com/classes/3.1/texture
  73651. */
  73652. renderTargetSamplingMode: number;
  73653. /**
  73654. * Clear color to use when screen clearing
  73655. */
  73656. clearColor: Color4;
  73657. /**
  73658. * If the buffer needs to be cleared before applying the post process. (default: true)
  73659. * Should be set to false if shader will overwrite all previous pixels.
  73660. */
  73661. autoClear: boolean;
  73662. /**
  73663. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73664. */
  73665. alphaMode: number;
  73666. /**
  73667. * Sets the setAlphaBlendConstants of the babylon engine
  73668. */
  73669. alphaConstants: Color4;
  73670. /**
  73671. * Animations to be used for the post processing
  73672. */
  73673. animations: Animation[];
  73674. /**
  73675. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73676. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73677. */
  73678. enablePixelPerfectMode: boolean;
  73679. /**
  73680. * Force the postprocess to be applied without taking in account viewport
  73681. */
  73682. forceFullscreenViewport: boolean;
  73683. /**
  73684. * List of inspectable custom properties (used by the Inspector)
  73685. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73686. */
  73687. inspectableCustomProperties: IInspectable[];
  73688. /**
  73689. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73690. *
  73691. * | Value | Type | Description |
  73692. * | ----- | ----------------------------------- | ----------- |
  73693. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73694. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73695. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73696. *
  73697. */
  73698. scaleMode: number;
  73699. /**
  73700. * Force textures to be a power of two (default: false)
  73701. */
  73702. alwaysForcePOT: boolean;
  73703. private _samples;
  73704. /**
  73705. * Number of sample textures (default: 1)
  73706. */
  73707. samples: number;
  73708. /**
  73709. * Modify the scale of the post process to be the same as the viewport (default: false)
  73710. */
  73711. adaptScaleToCurrentViewport: boolean;
  73712. private _camera;
  73713. private _scene;
  73714. private _engine;
  73715. private _options;
  73716. private _reusable;
  73717. private _textureType;
  73718. /**
  73719. * Smart array of input and output textures for the post process.
  73720. * @hidden
  73721. */
  73722. _textures: SmartArray<InternalTexture>;
  73723. /**
  73724. * The index in _textures that corresponds to the output texture.
  73725. * @hidden
  73726. */
  73727. _currentRenderTextureInd: number;
  73728. private _effect;
  73729. private _samplers;
  73730. private _fragmentUrl;
  73731. private _vertexUrl;
  73732. private _parameters;
  73733. private _scaleRatio;
  73734. protected _indexParameters: any;
  73735. private _shareOutputWithPostProcess;
  73736. private _texelSize;
  73737. private _forcedOutputTexture;
  73738. /**
  73739. * Returns the fragment url or shader name used in the post process.
  73740. * @returns the fragment url or name in the shader store.
  73741. */
  73742. getEffectName(): string;
  73743. /**
  73744. * An event triggered when the postprocess is activated.
  73745. */
  73746. onActivateObservable: Observable<Camera>;
  73747. private _onActivateObserver;
  73748. /**
  73749. * A function that is added to the onActivateObservable
  73750. */
  73751. onActivate: Nullable<(camera: Camera) => void>;
  73752. /**
  73753. * An event triggered when the postprocess changes its size.
  73754. */
  73755. onSizeChangedObservable: Observable<PostProcess>;
  73756. private _onSizeChangedObserver;
  73757. /**
  73758. * A function that is added to the onSizeChangedObservable
  73759. */
  73760. onSizeChanged: (postProcess: PostProcess) => void;
  73761. /**
  73762. * An event triggered when the postprocess applies its effect.
  73763. */
  73764. onApplyObservable: Observable<Effect>;
  73765. private _onApplyObserver;
  73766. /**
  73767. * A function that is added to the onApplyObservable
  73768. */
  73769. onApply: (effect: Effect) => void;
  73770. /**
  73771. * An event triggered before rendering the postprocess
  73772. */
  73773. onBeforeRenderObservable: Observable<Effect>;
  73774. private _onBeforeRenderObserver;
  73775. /**
  73776. * A function that is added to the onBeforeRenderObservable
  73777. */
  73778. onBeforeRender: (effect: Effect) => void;
  73779. /**
  73780. * An event triggered after rendering the postprocess
  73781. */
  73782. onAfterRenderObservable: Observable<Effect>;
  73783. private _onAfterRenderObserver;
  73784. /**
  73785. * A function that is added to the onAfterRenderObservable
  73786. */
  73787. onAfterRender: (efect: Effect) => void;
  73788. /**
  73789. * 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
  73790. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73791. */
  73792. inputTexture: InternalTexture;
  73793. /**
  73794. * Gets the camera which post process is applied to.
  73795. * @returns The camera the post process is applied to.
  73796. */
  73797. getCamera(): Camera;
  73798. /**
  73799. * Gets the texel size of the postprocess.
  73800. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73801. */
  73802. readonly texelSize: Vector2;
  73803. /**
  73804. * Creates a new instance PostProcess
  73805. * @param name The name of the PostProcess.
  73806. * @param fragmentUrl The url of the fragment shader to be used.
  73807. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73808. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73809. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73810. * @param camera The camera to apply the render pass to.
  73811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73812. * @param engine The engine which the post process will be applied. (default: current engine)
  73813. * @param reusable If the post process can be reused on the same frame. (default: false)
  73814. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73815. * @param textureType Type of textures used when performing the post process. (default: 0)
  73816. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73817. * @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
  73818. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73819. */
  73820. constructor(
  73821. /** Name of the PostProcess. */
  73822. 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);
  73823. /**
  73824. * Gets a string idenfifying the name of the class
  73825. * @returns "PostProcess" string
  73826. */
  73827. getClassName(): string;
  73828. /**
  73829. * Gets the engine which this post process belongs to.
  73830. * @returns The engine the post process was enabled with.
  73831. */
  73832. getEngine(): Engine;
  73833. /**
  73834. * The effect that is created when initializing the post process.
  73835. * @returns The created effect corrisponding the the postprocess.
  73836. */
  73837. getEffect(): Effect;
  73838. /**
  73839. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73840. * @param postProcess The post process to share the output with.
  73841. * @returns This post process.
  73842. */
  73843. shareOutputWith(postProcess: PostProcess): PostProcess;
  73844. /**
  73845. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73846. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73847. */
  73848. useOwnOutput(): void;
  73849. /**
  73850. * Updates the effect with the current post process compile time values and recompiles the shader.
  73851. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73852. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73853. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73854. * @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
  73855. * @param onCompiled Called when the shader has been compiled.
  73856. * @param onError Called if there is an error when compiling a shader.
  73857. */
  73858. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73859. /**
  73860. * The post process is reusable if it can be used multiple times within one frame.
  73861. * @returns If the post process is reusable
  73862. */
  73863. isReusable(): boolean;
  73864. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73865. markTextureDirty(): void;
  73866. /**
  73867. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73868. * 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.
  73869. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73870. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73871. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73872. * @returns The target texture that was bound to be written to.
  73873. */
  73874. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73875. /**
  73876. * If the post process is supported.
  73877. */
  73878. readonly isSupported: boolean;
  73879. /**
  73880. * The aspect ratio of the output texture.
  73881. */
  73882. readonly aspectRatio: number;
  73883. /**
  73884. * Get a value indicating if the post-process is ready to be used
  73885. * @returns true if the post-process is ready (shader is compiled)
  73886. */
  73887. isReady(): boolean;
  73888. /**
  73889. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73890. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73891. */
  73892. apply(): Nullable<Effect>;
  73893. private _disposeTextures;
  73894. /**
  73895. * Disposes the post process.
  73896. * @param camera The camera to dispose the post process on.
  73897. */
  73898. dispose(camera?: Camera): void;
  73899. }
  73900. }
  73901. declare module BABYLON {
  73902. /**
  73903. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73904. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73905. */
  73906. export class PostProcessManager {
  73907. private _scene;
  73908. private _indexBuffer;
  73909. private _vertexBuffers;
  73910. /**
  73911. * Creates a new instance PostProcess
  73912. * @param scene The scene that the post process is associated with.
  73913. */
  73914. constructor(scene: Scene);
  73915. private _prepareBuffers;
  73916. private _buildIndexBuffer;
  73917. /**
  73918. * Rebuilds the vertex buffers of the manager.
  73919. * @hidden
  73920. */
  73921. _rebuild(): void;
  73922. /**
  73923. * Prepares a frame to be run through a post process.
  73924. * @param sourceTexture The input texture to the post procesess. (default: null)
  73925. * @param postProcesses An array of post processes to be run. (default: null)
  73926. * @returns True if the post processes were able to be run.
  73927. * @hidden
  73928. */
  73929. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73930. /**
  73931. * Manually render a set of post processes to a texture.
  73932. * @param postProcesses An array of post processes to be run.
  73933. * @param targetTexture The target texture to render to.
  73934. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73935. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73936. * @param lodLevel defines which lod of the texture to render to
  73937. */
  73938. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73939. /**
  73940. * Finalize the result of the output of the postprocesses.
  73941. * @param doNotPresent If true the result will not be displayed to the screen.
  73942. * @param targetTexture The target texture to render to.
  73943. * @param faceIndex The index of the face to bind the target texture to.
  73944. * @param postProcesses The array of post processes to render.
  73945. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73946. * @hidden
  73947. */
  73948. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73949. /**
  73950. * Disposes of the post process manager.
  73951. */
  73952. dispose(): void;
  73953. }
  73954. }
  73955. declare module BABYLON {
  73956. interface AbstractScene {
  73957. /**
  73958. * The list of layers (background and foreground) of the scene
  73959. */
  73960. layers: Array<Layer>;
  73961. }
  73962. /**
  73963. * Defines the layer scene component responsible to manage any layers
  73964. * in a given scene.
  73965. */
  73966. export class LayerSceneComponent implements ISceneComponent {
  73967. /**
  73968. * The component name helpfull to identify the component in the list of scene components.
  73969. */
  73970. readonly name: string;
  73971. /**
  73972. * The scene the component belongs to.
  73973. */
  73974. scene: Scene;
  73975. private _engine;
  73976. /**
  73977. * Creates a new instance of the component for the given scene
  73978. * @param scene Defines the scene to register the component in
  73979. */
  73980. constructor(scene: Scene);
  73981. /**
  73982. * Registers the component in a given scene
  73983. */
  73984. register(): void;
  73985. /**
  73986. * Rebuilds the elements related to this component in case of
  73987. * context lost for instance.
  73988. */
  73989. rebuild(): void;
  73990. /**
  73991. * Disposes the component and the associated ressources.
  73992. */
  73993. dispose(): void;
  73994. private _draw;
  73995. private _drawCameraPredicate;
  73996. private _drawCameraBackground;
  73997. private _drawCameraForeground;
  73998. private _drawRenderTargetPredicate;
  73999. private _drawRenderTargetBackground;
  74000. private _drawRenderTargetForeground;
  74001. }
  74002. }
  74003. declare module BABYLON {
  74004. /** @hidden */
  74005. export var layerPixelShader: {
  74006. name: string;
  74007. shader: string;
  74008. };
  74009. }
  74010. declare module BABYLON {
  74011. /** @hidden */
  74012. export var layerVertexShader: {
  74013. name: string;
  74014. shader: string;
  74015. };
  74016. }
  74017. declare module BABYLON {
  74018. /**
  74019. * This represents a full screen 2d layer.
  74020. * This can be useful to display a picture in the background of your scene for instance.
  74021. * @see https://www.babylonjs-playground.com/#08A2BS#1
  74022. */
  74023. export class Layer {
  74024. /**
  74025. * Define the name of the layer.
  74026. */
  74027. name: string;
  74028. /**
  74029. * Define the texture the layer should display.
  74030. */
  74031. texture: Nullable<Texture>;
  74032. /**
  74033. * Is the layer in background or foreground.
  74034. */
  74035. isBackground: boolean;
  74036. /**
  74037. * Define the color of the layer (instead of texture).
  74038. */
  74039. color: Color4;
  74040. /**
  74041. * Define the scale of the layer in order to zoom in out of the texture.
  74042. */
  74043. scale: Vector2;
  74044. /**
  74045. * Define an offset for the layer in order to shift the texture.
  74046. */
  74047. offset: Vector2;
  74048. /**
  74049. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  74050. */
  74051. alphaBlendingMode: number;
  74052. /**
  74053. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  74054. * Alpha test will not mix with the background color in case of transparency.
  74055. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  74056. */
  74057. alphaTest: boolean;
  74058. /**
  74059. * Define a mask to restrict the layer to only some of the scene cameras.
  74060. */
  74061. layerMask: number;
  74062. /**
  74063. * Define the list of render target the layer is visible into.
  74064. */
  74065. renderTargetTextures: RenderTargetTexture[];
  74066. /**
  74067. * Define if the layer is only used in renderTarget or if it also
  74068. * renders in the main frame buffer of the canvas.
  74069. */
  74070. renderOnlyInRenderTargetTextures: boolean;
  74071. private _scene;
  74072. private _vertexBuffers;
  74073. private _indexBuffer;
  74074. private _effect;
  74075. private _alphaTestEffect;
  74076. /**
  74077. * An event triggered when the layer is disposed.
  74078. */
  74079. onDisposeObservable: Observable<Layer>;
  74080. private _onDisposeObserver;
  74081. /**
  74082. * Back compatibility with callback before the onDisposeObservable existed.
  74083. * The set callback will be triggered when the layer has been disposed.
  74084. */
  74085. onDispose: () => void;
  74086. /**
  74087. * An event triggered before rendering the scene
  74088. */
  74089. onBeforeRenderObservable: Observable<Layer>;
  74090. private _onBeforeRenderObserver;
  74091. /**
  74092. * Back compatibility with callback before the onBeforeRenderObservable existed.
  74093. * The set callback will be triggered just before rendering the layer.
  74094. */
  74095. onBeforeRender: () => void;
  74096. /**
  74097. * An event triggered after rendering the scene
  74098. */
  74099. onAfterRenderObservable: Observable<Layer>;
  74100. private _onAfterRenderObserver;
  74101. /**
  74102. * Back compatibility with callback before the onAfterRenderObservable existed.
  74103. * The set callback will be triggered just after rendering the layer.
  74104. */
  74105. onAfterRender: () => void;
  74106. /**
  74107. * Instantiates a new layer.
  74108. * This represents a full screen 2d layer.
  74109. * This can be useful to display a picture in the background of your scene for instance.
  74110. * @see https://www.babylonjs-playground.com/#08A2BS#1
  74111. * @param name Define the name of the layer in the scene
  74112. * @param imgUrl Define the url of the texture to display in the layer
  74113. * @param scene Define the scene the layer belongs to
  74114. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  74115. * @param color Defines a color for the layer
  74116. */
  74117. constructor(
  74118. /**
  74119. * Define the name of the layer.
  74120. */
  74121. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  74122. private _createIndexBuffer;
  74123. /** @hidden */
  74124. _rebuild(): void;
  74125. /**
  74126. * Renders the layer in the scene.
  74127. */
  74128. render(): void;
  74129. /**
  74130. * Disposes and releases the associated ressources.
  74131. */
  74132. dispose(): void;
  74133. }
  74134. }
  74135. declare module BABYLON {
  74136. interface AbstractScene {
  74137. /**
  74138. * The list of procedural textures added to the scene
  74139. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74140. */
  74141. proceduralTextures: Array<ProceduralTexture>;
  74142. }
  74143. /**
  74144. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74145. * in a given scene.
  74146. */
  74147. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74148. /**
  74149. * The component name helpfull to identify the component in the list of scene components.
  74150. */
  74151. readonly name: string;
  74152. /**
  74153. * The scene the component belongs to.
  74154. */
  74155. scene: Scene;
  74156. /**
  74157. * Creates a new instance of the component for the given scene
  74158. * @param scene Defines the scene to register the component in
  74159. */
  74160. constructor(scene: Scene);
  74161. /**
  74162. * Registers the component in a given scene
  74163. */
  74164. register(): void;
  74165. /**
  74166. * Rebuilds the elements related to this component in case of
  74167. * context lost for instance.
  74168. */
  74169. rebuild(): void;
  74170. /**
  74171. * Disposes the component and the associated ressources.
  74172. */
  74173. dispose(): void;
  74174. private _beforeClear;
  74175. }
  74176. }
  74177. declare module BABYLON {
  74178. interface Engine {
  74179. /**
  74180. * Creates a new render target cube texture
  74181. * @param size defines the size of the texture
  74182. * @param options defines the options used to create the texture
  74183. * @returns a new render target cube texture stored in an InternalTexture
  74184. */
  74185. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74186. }
  74187. }
  74188. declare module BABYLON {
  74189. /** @hidden */
  74190. export var proceduralVertexShader: {
  74191. name: string;
  74192. shader: string;
  74193. };
  74194. }
  74195. declare module BABYLON {
  74196. /**
  74197. * 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.
  74198. * This is the base class of any Procedural texture and contains most of the shareable code.
  74199. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74200. */
  74201. export class ProceduralTexture extends Texture {
  74202. isCube: boolean;
  74203. /**
  74204. * Define if the texture is enabled or not (disabled texture will not render)
  74205. */
  74206. isEnabled: boolean;
  74207. /**
  74208. * Define if the texture must be cleared before rendering (default is true)
  74209. */
  74210. autoClear: boolean;
  74211. /**
  74212. * Callback called when the texture is generated
  74213. */
  74214. onGenerated: () => void;
  74215. /**
  74216. * Event raised when the texture is generated
  74217. */
  74218. onGeneratedObservable: Observable<ProceduralTexture>;
  74219. /** @hidden */
  74220. _generateMipMaps: boolean;
  74221. /** @hidden **/
  74222. _effect: Effect;
  74223. /** @hidden */
  74224. _textures: {
  74225. [key: string]: Texture;
  74226. };
  74227. private _size;
  74228. private _currentRefreshId;
  74229. private _refreshRate;
  74230. private _vertexBuffers;
  74231. private _indexBuffer;
  74232. private _uniforms;
  74233. private _samplers;
  74234. private _fragment;
  74235. private _floats;
  74236. private _ints;
  74237. private _floatsArrays;
  74238. private _colors3;
  74239. private _colors4;
  74240. private _vectors2;
  74241. private _vectors3;
  74242. private _matrices;
  74243. private _fallbackTexture;
  74244. private _fallbackTextureUsed;
  74245. private _engine;
  74246. private _cachedDefines;
  74247. private _contentUpdateId;
  74248. private _contentData;
  74249. /**
  74250. * Instantiates a new procedural texture.
  74251. * 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.
  74252. * This is the base class of any Procedural texture and contains most of the shareable code.
  74253. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74254. * @param name Define the name of the texture
  74255. * @param size Define the size of the texture to create
  74256. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74257. * @param scene Define the scene the texture belongs to
  74258. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74259. * @param generateMipMaps Define if the texture should creates mip maps or not
  74260. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74261. */
  74262. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74263. /**
  74264. * The effect that is created when initializing the post process.
  74265. * @returns The created effect corrisponding the the postprocess.
  74266. */
  74267. getEffect(): Effect;
  74268. /**
  74269. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74270. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74271. */
  74272. getContent(): Nullable<ArrayBufferView>;
  74273. private _createIndexBuffer;
  74274. /** @hidden */
  74275. _rebuild(): void;
  74276. /**
  74277. * Resets the texture in order to recreate its associated resources.
  74278. * This can be called in case of context loss
  74279. */
  74280. reset(): void;
  74281. protected _getDefines(): string;
  74282. /**
  74283. * Is the texture ready to be used ? (rendered at least once)
  74284. * @returns true if ready, otherwise, false.
  74285. */
  74286. isReady(): boolean;
  74287. /**
  74288. * Resets the refresh counter of the texture and start bak from scratch.
  74289. * Could be useful to regenerate the texture if it is setup to render only once.
  74290. */
  74291. resetRefreshCounter(): void;
  74292. /**
  74293. * Set the fragment shader to use in order to render the texture.
  74294. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74295. */
  74296. setFragment(fragment: any): void;
  74297. /**
  74298. * Define the refresh rate of the texture or the rendering frequency.
  74299. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74300. */
  74301. refreshRate: number;
  74302. /** @hidden */
  74303. _shouldRender(): boolean;
  74304. /**
  74305. * Get the size the texture is rendering at.
  74306. * @returns the size (texture is always squared)
  74307. */
  74308. getRenderSize(): number;
  74309. /**
  74310. * Resize the texture to new value.
  74311. * @param size Define the new size the texture should have
  74312. * @param generateMipMaps Define whether the new texture should create mip maps
  74313. */
  74314. resize(size: number, generateMipMaps: boolean): void;
  74315. private _checkUniform;
  74316. /**
  74317. * Set a texture in the shader program used to render.
  74318. * @param name Define the name of the uniform samplers as defined in the shader
  74319. * @param texture Define the texture to bind to this sampler
  74320. * @return the texture itself allowing "fluent" like uniform updates
  74321. */
  74322. setTexture(name: string, texture: Texture): ProceduralTexture;
  74323. /**
  74324. * Set a float in the shader.
  74325. * @param name Define the name of the uniform as defined in the shader
  74326. * @param value Define the value to give to the uniform
  74327. * @return the texture itself allowing "fluent" like uniform updates
  74328. */
  74329. setFloat(name: string, value: number): ProceduralTexture;
  74330. /**
  74331. * Set a int in the shader.
  74332. * @param name Define the name of the uniform as defined in the shader
  74333. * @param value Define the value to give to the uniform
  74334. * @return the texture itself allowing "fluent" like uniform updates
  74335. */
  74336. setInt(name: string, value: number): ProceduralTexture;
  74337. /**
  74338. * Set an array of floats in the shader.
  74339. * @param name Define the name of the uniform as defined in the shader
  74340. * @param value Define the value to give to the uniform
  74341. * @return the texture itself allowing "fluent" like uniform updates
  74342. */
  74343. setFloats(name: string, value: number[]): ProceduralTexture;
  74344. /**
  74345. * Set a vec3 in the shader from a Color3.
  74346. * @param name Define the name of the uniform as defined in the shader
  74347. * @param value Define the value to give to the uniform
  74348. * @return the texture itself allowing "fluent" like uniform updates
  74349. */
  74350. setColor3(name: string, value: Color3): ProceduralTexture;
  74351. /**
  74352. * Set a vec4 in the shader from a Color4.
  74353. * @param name Define the name of the uniform as defined in the shader
  74354. * @param value Define the value to give to the uniform
  74355. * @return the texture itself allowing "fluent" like uniform updates
  74356. */
  74357. setColor4(name: string, value: Color4): ProceduralTexture;
  74358. /**
  74359. * Set a vec2 in the shader from a Vector2.
  74360. * @param name Define the name of the uniform as defined in the shader
  74361. * @param value Define the value to give to the uniform
  74362. * @return the texture itself allowing "fluent" like uniform updates
  74363. */
  74364. setVector2(name: string, value: Vector2): ProceduralTexture;
  74365. /**
  74366. * Set a vec3 in the shader from a Vector3.
  74367. * @param name Define the name of the uniform as defined in the shader
  74368. * @param value Define the value to give to the uniform
  74369. * @return the texture itself allowing "fluent" like uniform updates
  74370. */
  74371. setVector3(name: string, value: Vector3): ProceduralTexture;
  74372. /**
  74373. * Set a mat4 in the shader from a MAtrix.
  74374. * @param name Define the name of the uniform as defined in the shader
  74375. * @param value Define the value to give to the uniform
  74376. * @return the texture itself allowing "fluent" like uniform updates
  74377. */
  74378. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74379. /**
  74380. * Render the texture to its associated render target.
  74381. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74382. */
  74383. render(useCameraPostProcess?: boolean): void;
  74384. /**
  74385. * Clone the texture.
  74386. * @returns the cloned texture
  74387. */
  74388. clone(): ProceduralTexture;
  74389. /**
  74390. * Dispose the texture and release its asoociated resources.
  74391. */
  74392. dispose(): void;
  74393. }
  74394. }
  74395. declare module BABYLON {
  74396. /**
  74397. * This represents the base class for particle system in Babylon.
  74398. * 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.
  74399. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74400. * @example https://doc.babylonjs.com/babylon101/particles
  74401. */
  74402. export class BaseParticleSystem {
  74403. /**
  74404. * Source color is added to the destination color without alpha affecting the result
  74405. */
  74406. static BLENDMODE_ONEONE: number;
  74407. /**
  74408. * Blend current color and particle color using particle’s alpha
  74409. */
  74410. static BLENDMODE_STANDARD: number;
  74411. /**
  74412. * Add current color and particle color multiplied by particle’s alpha
  74413. */
  74414. static BLENDMODE_ADD: number;
  74415. /**
  74416. * Multiply current color with particle color
  74417. */
  74418. static BLENDMODE_MULTIPLY: number;
  74419. /**
  74420. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74421. */
  74422. static BLENDMODE_MULTIPLYADD: number;
  74423. /**
  74424. * List of animations used by the particle system.
  74425. */
  74426. animations: Animation[];
  74427. /**
  74428. * The id of the Particle system.
  74429. */
  74430. id: string;
  74431. /**
  74432. * The friendly name of the Particle system.
  74433. */
  74434. name: string;
  74435. /**
  74436. * The rendering group used by the Particle system to chose when to render.
  74437. */
  74438. renderingGroupId: number;
  74439. /**
  74440. * The emitter represents the Mesh or position we are attaching the particle system to.
  74441. */
  74442. emitter: Nullable<AbstractMesh | Vector3>;
  74443. /**
  74444. * The maximum number of particles to emit per frame
  74445. */
  74446. emitRate: number;
  74447. /**
  74448. * If you want to launch only a few particles at once, that can be done, as well.
  74449. */
  74450. manualEmitCount: number;
  74451. /**
  74452. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74453. */
  74454. updateSpeed: number;
  74455. /**
  74456. * The amount of time the particle system is running (depends of the overall update speed).
  74457. */
  74458. targetStopDuration: number;
  74459. /**
  74460. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74461. */
  74462. disposeOnStop: boolean;
  74463. /**
  74464. * Minimum power of emitting particles.
  74465. */
  74466. minEmitPower: number;
  74467. /**
  74468. * Maximum power of emitting particles.
  74469. */
  74470. maxEmitPower: number;
  74471. /**
  74472. * Minimum life time of emitting particles.
  74473. */
  74474. minLifeTime: number;
  74475. /**
  74476. * Maximum life time of emitting particles.
  74477. */
  74478. maxLifeTime: number;
  74479. /**
  74480. * Minimum Size of emitting particles.
  74481. */
  74482. minSize: number;
  74483. /**
  74484. * Maximum Size of emitting particles.
  74485. */
  74486. maxSize: number;
  74487. /**
  74488. * Minimum scale of emitting particles on X axis.
  74489. */
  74490. minScaleX: number;
  74491. /**
  74492. * Maximum scale of emitting particles on X axis.
  74493. */
  74494. maxScaleX: number;
  74495. /**
  74496. * Minimum scale of emitting particles on Y axis.
  74497. */
  74498. minScaleY: number;
  74499. /**
  74500. * Maximum scale of emitting particles on Y axis.
  74501. */
  74502. maxScaleY: number;
  74503. /**
  74504. * Gets or sets the minimal initial rotation in radians.
  74505. */
  74506. minInitialRotation: number;
  74507. /**
  74508. * Gets or sets the maximal initial rotation in radians.
  74509. */
  74510. maxInitialRotation: number;
  74511. /**
  74512. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74513. */
  74514. minAngularSpeed: number;
  74515. /**
  74516. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74517. */
  74518. maxAngularSpeed: number;
  74519. /**
  74520. * The texture used to render each particle. (this can be a spritesheet)
  74521. */
  74522. particleTexture: Nullable<Texture>;
  74523. /**
  74524. * The layer mask we are rendering the particles through.
  74525. */
  74526. layerMask: number;
  74527. /**
  74528. * This can help using your own shader to render the particle system.
  74529. * The according effect will be created
  74530. */
  74531. customShader: any;
  74532. /**
  74533. * By default particle system starts as soon as they are created. This prevents the
  74534. * automatic start to happen and let you decide when to start emitting particles.
  74535. */
  74536. preventAutoStart: boolean;
  74537. private _noiseTexture;
  74538. /**
  74539. * Gets or sets a texture used to add random noise to particle positions
  74540. */
  74541. noiseTexture: Nullable<ProceduralTexture>;
  74542. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74543. noiseStrength: Vector3;
  74544. /**
  74545. * Callback triggered when the particle animation is ending.
  74546. */
  74547. onAnimationEnd: Nullable<() => void>;
  74548. /**
  74549. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74550. */
  74551. blendMode: number;
  74552. /**
  74553. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74554. * to override the particles.
  74555. */
  74556. forceDepthWrite: boolean;
  74557. /** 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 */
  74558. preWarmCycles: number;
  74559. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74560. preWarmStepOffset: number;
  74561. /**
  74562. * 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)
  74563. */
  74564. spriteCellChangeSpeed: number;
  74565. /**
  74566. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74567. */
  74568. startSpriteCellID: number;
  74569. /**
  74570. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74571. */
  74572. endSpriteCellID: number;
  74573. /**
  74574. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74575. */
  74576. spriteCellWidth: number;
  74577. /**
  74578. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74579. */
  74580. spriteCellHeight: number;
  74581. /**
  74582. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74583. */
  74584. spriteRandomStartCell: boolean;
  74585. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74586. translationPivot: Vector2;
  74587. /** @hidden */
  74588. protected _isAnimationSheetEnabled: boolean;
  74589. /**
  74590. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74591. */
  74592. beginAnimationOnStart: boolean;
  74593. /**
  74594. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74595. */
  74596. beginAnimationFrom: number;
  74597. /**
  74598. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74599. */
  74600. beginAnimationTo: number;
  74601. /**
  74602. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74603. */
  74604. beginAnimationLoop: boolean;
  74605. /**
  74606. * Gets or sets a world offset applied to all particles
  74607. */
  74608. worldOffset: Vector3;
  74609. /**
  74610. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74611. */
  74612. isAnimationSheetEnabled: boolean;
  74613. /**
  74614. * Get hosting scene
  74615. * @returns the scene
  74616. */
  74617. getScene(): Scene;
  74618. /**
  74619. * You can use gravity if you want to give an orientation to your particles.
  74620. */
  74621. gravity: Vector3;
  74622. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74623. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74624. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74625. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74626. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74627. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74628. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74629. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74630. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74631. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74632. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74633. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74634. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74635. /**
  74636. * Defines the delay in milliseconds before starting the system (0 by default)
  74637. */
  74638. startDelay: number;
  74639. /**
  74640. * Gets the current list of drag gradients.
  74641. * You must use addDragGradient and removeDragGradient to udpate this list
  74642. * @returns the list of drag gradients
  74643. */
  74644. getDragGradients(): Nullable<Array<FactorGradient>>;
  74645. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74646. limitVelocityDamping: number;
  74647. /**
  74648. * Gets the current list of limit velocity gradients.
  74649. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74650. * @returns the list of limit velocity gradients
  74651. */
  74652. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74653. /**
  74654. * Gets the current list of color gradients.
  74655. * You must use addColorGradient and removeColorGradient to udpate this list
  74656. * @returns the list of color gradients
  74657. */
  74658. getColorGradients(): Nullable<Array<ColorGradient>>;
  74659. /**
  74660. * Gets the current list of size gradients.
  74661. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74662. * @returns the list of size gradients
  74663. */
  74664. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74665. /**
  74666. * Gets the current list of color remap gradients.
  74667. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74668. * @returns the list of color remap gradients
  74669. */
  74670. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74671. /**
  74672. * Gets the current list of alpha remap gradients.
  74673. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74674. * @returns the list of alpha remap gradients
  74675. */
  74676. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74677. /**
  74678. * Gets the current list of life time gradients.
  74679. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74680. * @returns the list of life time gradients
  74681. */
  74682. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74683. /**
  74684. * Gets the current list of angular speed gradients.
  74685. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74686. * @returns the list of angular speed gradients
  74687. */
  74688. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74689. /**
  74690. * Gets the current list of velocity gradients.
  74691. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74692. * @returns the list of velocity gradients
  74693. */
  74694. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74695. /**
  74696. * Gets the current list of start size gradients.
  74697. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74698. * @returns the list of start size gradients
  74699. */
  74700. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74701. /**
  74702. * Gets the current list of emit rate gradients.
  74703. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74704. * @returns the list of emit rate gradients
  74705. */
  74706. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74707. /**
  74708. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74709. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74710. */
  74711. direction1: Vector3;
  74712. /**
  74713. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74714. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74715. */
  74716. direction2: Vector3;
  74717. /**
  74718. * 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.
  74719. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74720. */
  74721. minEmitBox: Vector3;
  74722. /**
  74723. * 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.
  74724. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74725. */
  74726. maxEmitBox: Vector3;
  74727. /**
  74728. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74729. */
  74730. color1: Color4;
  74731. /**
  74732. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74733. */
  74734. color2: Color4;
  74735. /**
  74736. * Color the particle will have at the end of its lifetime
  74737. */
  74738. colorDead: Color4;
  74739. /**
  74740. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74741. */
  74742. textureMask: Color4;
  74743. /**
  74744. * The particle emitter type defines the emitter used by the particle system.
  74745. * It can be for example box, sphere, or cone...
  74746. */
  74747. particleEmitterType: IParticleEmitterType;
  74748. /** @hidden */
  74749. _isSubEmitter: boolean;
  74750. /**
  74751. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74752. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74753. */
  74754. billboardMode: number;
  74755. protected _isBillboardBased: boolean;
  74756. /**
  74757. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74758. */
  74759. isBillboardBased: boolean;
  74760. /**
  74761. * The scene the particle system belongs to.
  74762. */
  74763. protected _scene: Scene;
  74764. /**
  74765. * Local cache of defines for image processing.
  74766. */
  74767. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74768. /**
  74769. * Default configuration related to image processing available in the standard Material.
  74770. */
  74771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74772. /**
  74773. * Gets the image processing configuration used either in this material.
  74774. */
  74775. /**
  74776. * Sets the Default image processing configuration used either in the this material.
  74777. *
  74778. * If sets to null, the scene one is in use.
  74779. */
  74780. imageProcessingConfiguration: ImageProcessingConfiguration;
  74781. /**
  74782. * Attaches a new image processing configuration to the Standard Material.
  74783. * @param configuration
  74784. */
  74785. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74786. /** @hidden */
  74787. protected _reset(): void;
  74788. /** @hidden */
  74789. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74790. /**
  74791. * Instantiates a particle system.
  74792. * 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.
  74793. * @param name The name of the particle system
  74794. */
  74795. constructor(name: string);
  74796. /**
  74797. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74798. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74799. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74800. * @returns the emitter
  74801. */
  74802. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74803. /**
  74804. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74805. * @param radius The radius of the hemisphere to emit from
  74806. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74807. * @returns the emitter
  74808. */
  74809. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74810. /**
  74811. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74812. * @param radius The radius of the sphere to emit from
  74813. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74814. * @returns the emitter
  74815. */
  74816. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74817. /**
  74818. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74819. * @param radius The radius of the sphere to emit from
  74820. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74821. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74822. * @returns the emitter
  74823. */
  74824. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74825. /**
  74826. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74827. * @param radius The radius of the emission cylinder
  74828. * @param height The height of the emission cylinder
  74829. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74830. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74831. * @returns the emitter
  74832. */
  74833. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74834. /**
  74835. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74836. * @param radius The radius of the cylinder to emit from
  74837. * @param height The height of the emission cylinder
  74838. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74839. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74840. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74841. * @returns the emitter
  74842. */
  74843. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74844. /**
  74845. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74846. * @param radius The radius of the cone to emit from
  74847. * @param angle The base angle of the cone
  74848. * @returns the emitter
  74849. */
  74850. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74851. /**
  74852. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74853. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74854. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74855. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74856. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74857. * @returns the emitter
  74858. */
  74859. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74860. }
  74861. }
  74862. declare module BABYLON {
  74863. /**
  74864. * Type of sub emitter
  74865. */
  74866. export enum SubEmitterType {
  74867. /**
  74868. * Attached to the particle over it's lifetime
  74869. */
  74870. ATTACHED = 0,
  74871. /**
  74872. * Created when the particle dies
  74873. */
  74874. END = 1
  74875. }
  74876. /**
  74877. * Sub emitter class used to emit particles from an existing particle
  74878. */
  74879. export class SubEmitter {
  74880. /**
  74881. * the particle system to be used by the sub emitter
  74882. */
  74883. particleSystem: ParticleSystem;
  74884. /**
  74885. * Type of the submitter (Default: END)
  74886. */
  74887. type: SubEmitterType;
  74888. /**
  74889. * 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)
  74890. * Note: This only is supported when using an emitter of type Mesh
  74891. */
  74892. inheritDirection: boolean;
  74893. /**
  74894. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74895. */
  74896. inheritedVelocityAmount: number;
  74897. /**
  74898. * Creates a sub emitter
  74899. * @param particleSystem the particle system to be used by the sub emitter
  74900. */
  74901. constructor(
  74902. /**
  74903. * the particle system to be used by the sub emitter
  74904. */
  74905. particleSystem: ParticleSystem);
  74906. /**
  74907. * Clones the sub emitter
  74908. * @returns the cloned sub emitter
  74909. */
  74910. clone(): SubEmitter;
  74911. /**
  74912. * Serialize current object to a JSON object
  74913. * @returns the serialized object
  74914. */
  74915. serialize(): any;
  74916. /** @hidden */
  74917. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74918. /**
  74919. * Creates a new SubEmitter from a serialized JSON version
  74920. * @param serializationObject defines the JSON object to read from
  74921. * @param scene defines the hosting scene
  74922. * @param rootUrl defines the rootUrl for data loading
  74923. * @returns a new SubEmitter
  74924. */
  74925. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74926. /** Release associated resources */
  74927. dispose(): void;
  74928. }
  74929. }
  74930. declare module BABYLON {
  74931. /** @hidden */
  74932. export var clipPlaneFragmentDeclaration: {
  74933. name: string;
  74934. shader: string;
  74935. };
  74936. }
  74937. declare module BABYLON {
  74938. /** @hidden */
  74939. export var imageProcessingDeclaration: {
  74940. name: string;
  74941. shader: string;
  74942. };
  74943. }
  74944. declare module BABYLON {
  74945. /** @hidden */
  74946. export var imageProcessingFunctions: {
  74947. name: string;
  74948. shader: string;
  74949. };
  74950. }
  74951. declare module BABYLON {
  74952. /** @hidden */
  74953. export var clipPlaneFragment: {
  74954. name: string;
  74955. shader: string;
  74956. };
  74957. }
  74958. declare module BABYLON {
  74959. /** @hidden */
  74960. export var particlesPixelShader: {
  74961. name: string;
  74962. shader: string;
  74963. };
  74964. }
  74965. declare module BABYLON {
  74966. /** @hidden */
  74967. export var clipPlaneVertexDeclaration: {
  74968. name: string;
  74969. shader: string;
  74970. };
  74971. }
  74972. declare module BABYLON {
  74973. /** @hidden */
  74974. export var clipPlaneVertex: {
  74975. name: string;
  74976. shader: string;
  74977. };
  74978. }
  74979. declare module BABYLON {
  74980. /** @hidden */
  74981. export var particlesVertexShader: {
  74982. name: string;
  74983. shader: string;
  74984. };
  74985. }
  74986. declare module BABYLON {
  74987. /**
  74988. * This represents a particle system in Babylon.
  74989. * 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.
  74990. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74991. * @example https://doc.babylonjs.com/babylon101/particles
  74992. */
  74993. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74994. /**
  74995. * Billboard mode will only apply to Y axis
  74996. */
  74997. static readonly BILLBOARDMODE_Y: number;
  74998. /**
  74999. * Billboard mode will apply to all axes
  75000. */
  75001. static readonly BILLBOARDMODE_ALL: number;
  75002. /**
  75003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75004. */
  75005. static readonly BILLBOARDMODE_STRETCHED: number;
  75006. /**
  75007. * This function can be defined to provide custom update for active particles.
  75008. * This function will be called instead of regular update (age, position, color, etc.).
  75009. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  75010. */
  75011. updateFunction: (particles: Particle[]) => void;
  75012. private _emitterWorldMatrix;
  75013. /**
  75014. * This function can be defined to specify initial direction for every new particle.
  75015. * It by default use the emitterType defined function
  75016. */
  75017. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  75018. /**
  75019. * This function can be defined to specify initial position for every new particle.
  75020. * It by default use the emitterType defined function
  75021. */
  75022. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  75023. /**
  75024. * @hidden
  75025. */
  75026. _inheritedVelocityOffset: Vector3;
  75027. /**
  75028. * An event triggered when the system is disposed
  75029. */
  75030. onDisposeObservable: Observable<ParticleSystem>;
  75031. private _onDisposeObserver;
  75032. /**
  75033. * Sets a callback that will be triggered when the system is disposed
  75034. */
  75035. onDispose: () => void;
  75036. private _particles;
  75037. private _epsilon;
  75038. private _capacity;
  75039. private _stockParticles;
  75040. private _newPartsExcess;
  75041. private _vertexData;
  75042. private _vertexBuffer;
  75043. private _vertexBuffers;
  75044. private _spriteBuffer;
  75045. private _indexBuffer;
  75046. private _effect;
  75047. private _customEffect;
  75048. private _cachedDefines;
  75049. private _scaledColorStep;
  75050. private _colorDiff;
  75051. private _scaledDirection;
  75052. private _scaledGravity;
  75053. private _currentRenderId;
  75054. private _alive;
  75055. private _useInstancing;
  75056. private _started;
  75057. private _stopped;
  75058. private _actualFrame;
  75059. private _scaledUpdateSpeed;
  75060. private _vertexBufferSize;
  75061. /** @hidden */
  75062. _currentEmitRateGradient: Nullable<FactorGradient>;
  75063. /** @hidden */
  75064. _currentEmitRate1: number;
  75065. /** @hidden */
  75066. _currentEmitRate2: number;
  75067. /** @hidden */
  75068. _currentStartSizeGradient: Nullable<FactorGradient>;
  75069. /** @hidden */
  75070. _currentStartSize1: number;
  75071. /** @hidden */
  75072. _currentStartSize2: number;
  75073. private readonly _rawTextureWidth;
  75074. private _rampGradientsTexture;
  75075. private _useRampGradients;
  75076. /** Gets or sets a boolean indicating that ramp gradients must be used
  75077. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75078. */
  75079. useRampGradients: boolean;
  75080. /**
  75081. * 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.
  75082. * 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: [])
  75083. */
  75084. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  75085. private _subEmitters;
  75086. /**
  75087. * @hidden
  75088. * If the particle systems emitter should be disposed when the particle system is disposed
  75089. */
  75090. _disposeEmitterOnDispose: boolean;
  75091. /**
  75092. * The current active Sub-systems, this property is used by the root particle system only.
  75093. */
  75094. activeSubSystems: Array<ParticleSystem>;
  75095. private _rootParticleSystem;
  75096. /**
  75097. * Gets the current list of active particles
  75098. */
  75099. readonly particles: Particle[];
  75100. /**
  75101. * Returns the string "ParticleSystem"
  75102. * @returns a string containing the class name
  75103. */
  75104. getClassName(): string;
  75105. /**
  75106. * Instantiates a particle system.
  75107. * 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.
  75108. * @param name The name of the particle system
  75109. * @param capacity The max number of particles alive at the same time
  75110. * @param scene The scene the particle system belongs to
  75111. * @param customEffect a custom effect used to change the way particles are rendered by default
  75112. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75113. * @param epsilon Offset used to render the particles
  75114. */
  75115. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  75116. private _addFactorGradient;
  75117. private _removeFactorGradient;
  75118. /**
  75119. * Adds a new life time gradient
  75120. * @param gradient defines the gradient to use (between 0 and 1)
  75121. * @param factor defines the life time factor to affect to the specified gradient
  75122. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75123. * @returns the current particle system
  75124. */
  75125. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75126. /**
  75127. * Remove a specific life time gradient
  75128. * @param gradient defines the gradient to remove
  75129. * @returns the current particle system
  75130. */
  75131. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75132. /**
  75133. * Adds a new size gradient
  75134. * @param gradient defines the gradient to use (between 0 and 1)
  75135. * @param factor defines the size factor to affect to the specified gradient
  75136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75137. * @returns the current particle system
  75138. */
  75139. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75140. /**
  75141. * Remove a specific size gradient
  75142. * @param gradient defines the gradient to remove
  75143. * @returns the current particle system
  75144. */
  75145. removeSizeGradient(gradient: number): IParticleSystem;
  75146. /**
  75147. * Adds a new color remap gradient
  75148. * @param gradient defines the gradient to use (between 0 and 1)
  75149. * @param min defines the color remap minimal range
  75150. * @param max defines the color remap maximal range
  75151. * @returns the current particle system
  75152. */
  75153. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75154. /**
  75155. * Remove a specific color remap gradient
  75156. * @param gradient defines the gradient to remove
  75157. * @returns the current particle system
  75158. */
  75159. removeColorRemapGradient(gradient: number): IParticleSystem;
  75160. /**
  75161. * Adds a new alpha remap gradient
  75162. * @param gradient defines the gradient to use (between 0 and 1)
  75163. * @param min defines the alpha remap minimal range
  75164. * @param max defines the alpha remap maximal range
  75165. * @returns the current particle system
  75166. */
  75167. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75168. /**
  75169. * Remove a specific alpha remap gradient
  75170. * @param gradient defines the gradient to remove
  75171. * @returns the current particle system
  75172. */
  75173. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75174. /**
  75175. * Adds a new angular speed gradient
  75176. * @param gradient defines the gradient to use (between 0 and 1)
  75177. * @param factor defines the angular speed to affect to the specified gradient
  75178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75179. * @returns the current particle system
  75180. */
  75181. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75182. /**
  75183. * Remove a specific angular speed gradient
  75184. * @param gradient defines the gradient to remove
  75185. * @returns the current particle system
  75186. */
  75187. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75188. /**
  75189. * Adds a new velocity gradient
  75190. * @param gradient defines the gradient to use (between 0 and 1)
  75191. * @param factor defines the velocity to affect to the specified gradient
  75192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75193. * @returns the current particle system
  75194. */
  75195. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75196. /**
  75197. * Remove a specific velocity gradient
  75198. * @param gradient defines the gradient to remove
  75199. * @returns the current particle system
  75200. */
  75201. removeVelocityGradient(gradient: number): IParticleSystem;
  75202. /**
  75203. * Adds a new limit velocity gradient
  75204. * @param gradient defines the gradient to use (between 0 and 1)
  75205. * @param factor defines the limit velocity value to affect to the specified gradient
  75206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75207. * @returns the current particle system
  75208. */
  75209. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75210. /**
  75211. * Remove a specific limit velocity gradient
  75212. * @param gradient defines the gradient to remove
  75213. * @returns the current particle system
  75214. */
  75215. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75216. /**
  75217. * Adds a new drag gradient
  75218. * @param gradient defines the gradient to use (between 0 and 1)
  75219. * @param factor defines the drag value to affect to the specified gradient
  75220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75221. * @returns the current particle system
  75222. */
  75223. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75224. /**
  75225. * Remove a specific drag gradient
  75226. * @param gradient defines the gradient to remove
  75227. * @returns the current particle system
  75228. */
  75229. removeDragGradient(gradient: number): IParticleSystem;
  75230. /**
  75231. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75232. * @param gradient defines the gradient to use (between 0 and 1)
  75233. * @param factor defines the emit rate value to affect to the specified gradient
  75234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75235. * @returns the current particle system
  75236. */
  75237. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75238. /**
  75239. * Remove a specific emit rate gradient
  75240. * @param gradient defines the gradient to remove
  75241. * @returns the current particle system
  75242. */
  75243. removeEmitRateGradient(gradient: number): IParticleSystem;
  75244. /**
  75245. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75246. * @param gradient defines the gradient to use (between 0 and 1)
  75247. * @param factor defines the start size value to affect to the specified gradient
  75248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75249. * @returns the current particle system
  75250. */
  75251. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75252. /**
  75253. * Remove a specific start size gradient
  75254. * @param gradient defines the gradient to remove
  75255. * @returns the current particle system
  75256. */
  75257. removeStartSizeGradient(gradient: number): IParticleSystem;
  75258. private _createRampGradientTexture;
  75259. /**
  75260. * Gets the current list of ramp gradients.
  75261. * You must use addRampGradient and removeRampGradient to udpate this list
  75262. * @returns the list of ramp gradients
  75263. */
  75264. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75265. /**
  75266. * Adds a new ramp gradient used to remap particle colors
  75267. * @param gradient defines the gradient to use (between 0 and 1)
  75268. * @param color defines the color to affect to the specified gradient
  75269. * @returns the current particle system
  75270. */
  75271. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75272. /**
  75273. * Remove a specific ramp gradient
  75274. * @param gradient defines the gradient to remove
  75275. * @returns the current particle system
  75276. */
  75277. removeRampGradient(gradient: number): ParticleSystem;
  75278. /**
  75279. * Adds a new color gradient
  75280. * @param gradient defines the gradient to use (between 0 and 1)
  75281. * @param color1 defines the color to affect to the specified gradient
  75282. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75283. * @returns this particle system
  75284. */
  75285. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75286. /**
  75287. * Remove a specific color gradient
  75288. * @param gradient defines the gradient to remove
  75289. * @returns this particle system
  75290. */
  75291. removeColorGradient(gradient: number): IParticleSystem;
  75292. private _fetchR;
  75293. protected _reset(): void;
  75294. private _resetEffect;
  75295. private _createVertexBuffers;
  75296. private _createIndexBuffer;
  75297. /**
  75298. * Gets the maximum number of particles active at the same time.
  75299. * @returns The max number of active particles.
  75300. */
  75301. getCapacity(): number;
  75302. /**
  75303. * Gets whether there are still active particles in the system.
  75304. * @returns True if it is alive, otherwise false.
  75305. */
  75306. isAlive(): boolean;
  75307. /**
  75308. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75309. * @returns True if it has been started, otherwise false.
  75310. */
  75311. isStarted(): boolean;
  75312. private _prepareSubEmitterInternalArray;
  75313. /**
  75314. * Starts the particle system and begins to emit
  75315. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75316. */
  75317. start(delay?: number): void;
  75318. /**
  75319. * Stops the particle system.
  75320. * @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.
  75321. */
  75322. stop(stopSubEmitters?: boolean): void;
  75323. /**
  75324. * Remove all active particles
  75325. */
  75326. reset(): void;
  75327. /**
  75328. * @hidden (for internal use only)
  75329. */
  75330. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75331. /**
  75332. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75333. * Its lifetime will start back at 0.
  75334. */
  75335. recycleParticle: (particle: Particle) => void;
  75336. private _stopSubEmitters;
  75337. private _createParticle;
  75338. private _removeFromRoot;
  75339. private _emitFromParticle;
  75340. private _update;
  75341. /** @hidden */
  75342. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75343. /** @hidden */
  75344. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75345. /** @hidden */
  75346. private _getEffect;
  75347. /**
  75348. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75349. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75350. */
  75351. animate(preWarmOnly?: boolean): void;
  75352. private _appendParticleVertices;
  75353. /**
  75354. * Rebuilds the particle system.
  75355. */
  75356. rebuild(): void;
  75357. /**
  75358. * Is this system ready to be used/rendered
  75359. * @return true if the system is ready
  75360. */
  75361. isReady(): boolean;
  75362. private _render;
  75363. /**
  75364. * Renders the particle system in its current state.
  75365. * @returns the current number of particles
  75366. */
  75367. render(): number;
  75368. /**
  75369. * Disposes the particle system and free the associated resources
  75370. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75371. */
  75372. dispose(disposeTexture?: boolean): void;
  75373. /**
  75374. * Clones the particle system.
  75375. * @param name The name of the cloned object
  75376. * @param newEmitter The new emitter to use
  75377. * @returns the cloned particle system
  75378. */
  75379. clone(name: string, newEmitter: any): ParticleSystem;
  75380. /**
  75381. * Serializes the particle system to a JSON object.
  75382. * @returns the JSON object
  75383. */
  75384. serialize(): any;
  75385. /** @hidden */
  75386. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75387. /** @hidden */
  75388. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75389. /**
  75390. * Parses a JSON object to create a particle system.
  75391. * @param parsedParticleSystem The JSON object to parse
  75392. * @param scene The scene to create the particle system in
  75393. * @param rootUrl The root url to use to load external dependencies like texture
  75394. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75395. * @returns the Parsed particle system
  75396. */
  75397. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75398. }
  75399. }
  75400. declare module BABYLON {
  75401. /**
  75402. * A particle represents one of the element emitted by a particle system.
  75403. * This is mainly define by its coordinates, direction, velocity and age.
  75404. */
  75405. export class Particle {
  75406. /**
  75407. * The particle system the particle belongs to.
  75408. */
  75409. particleSystem: ParticleSystem;
  75410. private static _Count;
  75411. /**
  75412. * Unique ID of the particle
  75413. */
  75414. id: number;
  75415. /**
  75416. * The world position of the particle in the scene.
  75417. */
  75418. position: Vector3;
  75419. /**
  75420. * The world direction of the particle in the scene.
  75421. */
  75422. direction: Vector3;
  75423. /**
  75424. * The color of the particle.
  75425. */
  75426. color: Color4;
  75427. /**
  75428. * The color change of the particle per step.
  75429. */
  75430. colorStep: Color4;
  75431. /**
  75432. * Defines how long will the life of the particle be.
  75433. */
  75434. lifeTime: number;
  75435. /**
  75436. * The current age of the particle.
  75437. */
  75438. age: number;
  75439. /**
  75440. * The current size of the particle.
  75441. */
  75442. size: number;
  75443. /**
  75444. * The current scale of the particle.
  75445. */
  75446. scale: Vector2;
  75447. /**
  75448. * The current angle of the particle.
  75449. */
  75450. angle: number;
  75451. /**
  75452. * Defines how fast is the angle changing.
  75453. */
  75454. angularSpeed: number;
  75455. /**
  75456. * Defines the cell index used by the particle to be rendered from a sprite.
  75457. */
  75458. cellIndex: number;
  75459. /**
  75460. * The information required to support color remapping
  75461. */
  75462. remapData: Vector4;
  75463. /** @hidden */
  75464. _randomCellOffset?: number;
  75465. /** @hidden */
  75466. _initialDirection: Nullable<Vector3>;
  75467. /** @hidden */
  75468. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75469. /** @hidden */
  75470. _initialStartSpriteCellID: number;
  75471. /** @hidden */
  75472. _initialEndSpriteCellID: number;
  75473. /** @hidden */
  75474. _currentColorGradient: Nullable<ColorGradient>;
  75475. /** @hidden */
  75476. _currentColor1: Color4;
  75477. /** @hidden */
  75478. _currentColor2: Color4;
  75479. /** @hidden */
  75480. _currentSizeGradient: Nullable<FactorGradient>;
  75481. /** @hidden */
  75482. _currentSize1: number;
  75483. /** @hidden */
  75484. _currentSize2: number;
  75485. /** @hidden */
  75486. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75487. /** @hidden */
  75488. _currentAngularSpeed1: number;
  75489. /** @hidden */
  75490. _currentAngularSpeed2: number;
  75491. /** @hidden */
  75492. _currentVelocityGradient: Nullable<FactorGradient>;
  75493. /** @hidden */
  75494. _currentVelocity1: number;
  75495. /** @hidden */
  75496. _currentVelocity2: number;
  75497. /** @hidden */
  75498. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75499. /** @hidden */
  75500. _currentLimitVelocity1: number;
  75501. /** @hidden */
  75502. _currentLimitVelocity2: number;
  75503. /** @hidden */
  75504. _currentDragGradient: Nullable<FactorGradient>;
  75505. /** @hidden */
  75506. _currentDrag1: number;
  75507. /** @hidden */
  75508. _currentDrag2: number;
  75509. /** @hidden */
  75510. _randomNoiseCoordinates1: Vector3;
  75511. /** @hidden */
  75512. _randomNoiseCoordinates2: Vector3;
  75513. /**
  75514. * Creates a new instance Particle
  75515. * @param particleSystem the particle system the particle belongs to
  75516. */
  75517. constructor(
  75518. /**
  75519. * The particle system the particle belongs to.
  75520. */
  75521. particleSystem: ParticleSystem);
  75522. private updateCellInfoFromSystem;
  75523. /**
  75524. * Defines how the sprite cell index is updated for the particle
  75525. */
  75526. updateCellIndex(): void;
  75527. /** @hidden */
  75528. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75529. /** @hidden */
  75530. _inheritParticleInfoToSubEmitters(): void;
  75531. /** @hidden */
  75532. _reset(): void;
  75533. /**
  75534. * Copy the properties of particle to another one.
  75535. * @param other the particle to copy the information to.
  75536. */
  75537. copyTo(other: Particle): void;
  75538. }
  75539. }
  75540. declare module BABYLON {
  75541. /**
  75542. * Particle emitter represents a volume emitting particles.
  75543. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75544. */
  75545. export interface IParticleEmitterType {
  75546. /**
  75547. * Called by the particle System when the direction is computed for the created particle.
  75548. * @param worldMatrix is the world matrix of the particle system
  75549. * @param directionToUpdate is the direction vector to update with the result
  75550. * @param particle is the particle we are computed the direction for
  75551. */
  75552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75553. /**
  75554. * Called by the particle System when the position is computed for the created particle.
  75555. * @param worldMatrix is the world matrix of the particle system
  75556. * @param positionToUpdate is the position vector to update with the result
  75557. * @param particle is the particle we are computed the position for
  75558. */
  75559. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75560. /**
  75561. * Clones the current emitter and returns a copy of it
  75562. * @returns the new emitter
  75563. */
  75564. clone(): IParticleEmitterType;
  75565. /**
  75566. * Called by the GPUParticleSystem to setup the update shader
  75567. * @param effect defines the update shader
  75568. */
  75569. applyToShader(effect: Effect): void;
  75570. /**
  75571. * Returns a string to use to update the GPU particles update shader
  75572. * @returns the effect defines string
  75573. */
  75574. getEffectDefines(): string;
  75575. /**
  75576. * Returns a string representing the class name
  75577. * @returns a string containing the class name
  75578. */
  75579. getClassName(): string;
  75580. /**
  75581. * Serializes the particle system to a JSON object.
  75582. * @returns the JSON object
  75583. */
  75584. serialize(): any;
  75585. /**
  75586. * Parse properties from a JSON object
  75587. * @param serializationObject defines the JSON object
  75588. */
  75589. parse(serializationObject: any): void;
  75590. }
  75591. }
  75592. declare module BABYLON {
  75593. /**
  75594. * Particle emitter emitting particles from the inside of a box.
  75595. * It emits the particles randomly between 2 given directions.
  75596. */
  75597. export class BoxParticleEmitter implements IParticleEmitterType {
  75598. /**
  75599. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75600. */
  75601. direction1: Vector3;
  75602. /**
  75603. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75604. */
  75605. direction2: Vector3;
  75606. /**
  75607. * 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.
  75608. */
  75609. minEmitBox: Vector3;
  75610. /**
  75611. * 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.
  75612. */
  75613. maxEmitBox: Vector3;
  75614. /**
  75615. * Creates a new instance BoxParticleEmitter
  75616. */
  75617. constructor();
  75618. /**
  75619. * Called by the particle System when the direction is computed for the created particle.
  75620. * @param worldMatrix is the world matrix of the particle system
  75621. * @param directionToUpdate is the direction vector to update with the result
  75622. * @param particle is the particle we are computed the direction for
  75623. */
  75624. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75625. /**
  75626. * Called by the particle System when the position is computed for the created particle.
  75627. * @param worldMatrix is the world matrix of the particle system
  75628. * @param positionToUpdate is the position vector to update with the result
  75629. * @param particle is the particle we are computed the position for
  75630. */
  75631. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75632. /**
  75633. * Clones the current emitter and returns a copy of it
  75634. * @returns the new emitter
  75635. */
  75636. clone(): BoxParticleEmitter;
  75637. /**
  75638. * Called by the GPUParticleSystem to setup the update shader
  75639. * @param effect defines the update shader
  75640. */
  75641. applyToShader(effect: Effect): void;
  75642. /**
  75643. * Returns a string to use to update the GPU particles update shader
  75644. * @returns a string containng the defines string
  75645. */
  75646. getEffectDefines(): string;
  75647. /**
  75648. * Returns the string "BoxParticleEmitter"
  75649. * @returns a string containing the class name
  75650. */
  75651. getClassName(): string;
  75652. /**
  75653. * Serializes the particle system to a JSON object.
  75654. * @returns the JSON object
  75655. */
  75656. serialize(): any;
  75657. /**
  75658. * Parse properties from a JSON object
  75659. * @param serializationObject defines the JSON object
  75660. */
  75661. parse(serializationObject: any): void;
  75662. }
  75663. }
  75664. declare module BABYLON {
  75665. /**
  75666. * Particle emitter emitting particles from the inside of a cone.
  75667. * It emits the particles alongside the cone volume from the base to the particle.
  75668. * The emission direction might be randomized.
  75669. */
  75670. export class ConeParticleEmitter implements IParticleEmitterType {
  75671. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75672. directionRandomizer: number;
  75673. private _radius;
  75674. private _angle;
  75675. private _height;
  75676. /**
  75677. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75678. */
  75679. radiusRange: number;
  75680. /**
  75681. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75682. */
  75683. heightRange: number;
  75684. /**
  75685. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75686. */
  75687. emitFromSpawnPointOnly: boolean;
  75688. /**
  75689. * Gets or sets the radius of the emission cone
  75690. */
  75691. radius: number;
  75692. /**
  75693. * Gets or sets the angle of the emission cone
  75694. */
  75695. angle: number;
  75696. private _buildHeight;
  75697. /**
  75698. * Creates a new instance ConeParticleEmitter
  75699. * @param radius the radius of the emission cone (1 by default)
  75700. * @param angle the cone base angle (PI by default)
  75701. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75702. */
  75703. constructor(radius?: number, angle?: number,
  75704. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75705. directionRandomizer?: number);
  75706. /**
  75707. * Called by the particle System when the direction is computed for the created particle.
  75708. * @param worldMatrix is the world matrix of the particle system
  75709. * @param directionToUpdate is the direction vector to update with the result
  75710. * @param particle is the particle we are computed the direction for
  75711. */
  75712. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75713. /**
  75714. * Called by the particle System when the position is computed for the created particle.
  75715. * @param worldMatrix is the world matrix of the particle system
  75716. * @param positionToUpdate is the position vector to update with the result
  75717. * @param particle is the particle we are computed the position for
  75718. */
  75719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75720. /**
  75721. * Clones the current emitter and returns a copy of it
  75722. * @returns the new emitter
  75723. */
  75724. clone(): ConeParticleEmitter;
  75725. /**
  75726. * Called by the GPUParticleSystem to setup the update shader
  75727. * @param effect defines the update shader
  75728. */
  75729. applyToShader(effect: Effect): void;
  75730. /**
  75731. * Returns a string to use to update the GPU particles update shader
  75732. * @returns a string containng the defines string
  75733. */
  75734. getEffectDefines(): string;
  75735. /**
  75736. * Returns the string "ConeParticleEmitter"
  75737. * @returns a string containing the class name
  75738. */
  75739. getClassName(): string;
  75740. /**
  75741. * Serializes the particle system to a JSON object.
  75742. * @returns the JSON object
  75743. */
  75744. serialize(): any;
  75745. /**
  75746. * Parse properties from a JSON object
  75747. * @param serializationObject defines the JSON object
  75748. */
  75749. parse(serializationObject: any): void;
  75750. }
  75751. }
  75752. declare module BABYLON {
  75753. /**
  75754. * Particle emitter emitting particles from the inside of a cylinder.
  75755. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75756. */
  75757. export class CylinderParticleEmitter implements IParticleEmitterType {
  75758. /**
  75759. * The radius of the emission cylinder.
  75760. */
  75761. radius: number;
  75762. /**
  75763. * The height of the emission cylinder.
  75764. */
  75765. height: number;
  75766. /**
  75767. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75768. */
  75769. radiusRange: number;
  75770. /**
  75771. * How much to randomize the particle direction [0-1].
  75772. */
  75773. directionRandomizer: number;
  75774. /**
  75775. * Creates a new instance CylinderParticleEmitter
  75776. * @param radius the radius of the emission cylinder (1 by default)
  75777. * @param height the height of the emission cylinder (1 by default)
  75778. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75779. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75780. */
  75781. constructor(
  75782. /**
  75783. * The radius of the emission cylinder.
  75784. */
  75785. radius?: number,
  75786. /**
  75787. * The height of the emission cylinder.
  75788. */
  75789. height?: number,
  75790. /**
  75791. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75792. */
  75793. radiusRange?: number,
  75794. /**
  75795. * How much to randomize the particle direction [0-1].
  75796. */
  75797. directionRandomizer?: number);
  75798. /**
  75799. * Called by the particle System when the direction is computed for the created particle.
  75800. * @param worldMatrix is the world matrix of the particle system
  75801. * @param directionToUpdate is the direction vector to update with the result
  75802. * @param particle is the particle we are computed the direction for
  75803. */
  75804. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75805. /**
  75806. * Called by the particle System when the position is computed for the created particle.
  75807. * @param worldMatrix is the world matrix of the particle system
  75808. * @param positionToUpdate is the position vector to update with the result
  75809. * @param particle is the particle we are computed the position for
  75810. */
  75811. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75812. /**
  75813. * Clones the current emitter and returns a copy of it
  75814. * @returns the new emitter
  75815. */
  75816. clone(): CylinderParticleEmitter;
  75817. /**
  75818. * Called by the GPUParticleSystem to setup the update shader
  75819. * @param effect defines the update shader
  75820. */
  75821. applyToShader(effect: Effect): void;
  75822. /**
  75823. * Returns a string to use to update the GPU particles update shader
  75824. * @returns a string containng the defines string
  75825. */
  75826. getEffectDefines(): string;
  75827. /**
  75828. * Returns the string "CylinderParticleEmitter"
  75829. * @returns a string containing the class name
  75830. */
  75831. getClassName(): string;
  75832. /**
  75833. * Serializes the particle system to a JSON object.
  75834. * @returns the JSON object
  75835. */
  75836. serialize(): any;
  75837. /**
  75838. * Parse properties from a JSON object
  75839. * @param serializationObject defines the JSON object
  75840. */
  75841. parse(serializationObject: any): void;
  75842. }
  75843. /**
  75844. * Particle emitter emitting particles from the inside of a cylinder.
  75845. * It emits the particles randomly between two vectors.
  75846. */
  75847. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75848. /**
  75849. * The min limit of the emission direction.
  75850. */
  75851. direction1: Vector3;
  75852. /**
  75853. * The max limit of the emission direction.
  75854. */
  75855. direction2: Vector3;
  75856. /**
  75857. * Creates a new instance CylinderDirectedParticleEmitter
  75858. * @param radius the radius of the emission cylinder (1 by default)
  75859. * @param height the height of the emission cylinder (1 by default)
  75860. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75861. * @param direction1 the min limit of the emission direction (up vector by default)
  75862. * @param direction2 the max limit of the emission direction (up vector by default)
  75863. */
  75864. constructor(radius?: number, height?: number, radiusRange?: number,
  75865. /**
  75866. * The min limit of the emission direction.
  75867. */
  75868. direction1?: Vector3,
  75869. /**
  75870. * The max limit of the emission direction.
  75871. */
  75872. direction2?: Vector3);
  75873. /**
  75874. * Called by the particle System when the direction is computed for the created particle.
  75875. * @param worldMatrix is the world matrix of the particle system
  75876. * @param directionToUpdate is the direction vector to update with the result
  75877. * @param particle is the particle we are computed the direction for
  75878. */
  75879. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75880. /**
  75881. * Clones the current emitter and returns a copy of it
  75882. * @returns the new emitter
  75883. */
  75884. clone(): CylinderDirectedParticleEmitter;
  75885. /**
  75886. * Called by the GPUParticleSystem to setup the update shader
  75887. * @param effect defines the update shader
  75888. */
  75889. applyToShader(effect: Effect): void;
  75890. /**
  75891. * Returns a string to use to update the GPU particles update shader
  75892. * @returns a string containng the defines string
  75893. */
  75894. getEffectDefines(): string;
  75895. /**
  75896. * Returns the string "CylinderDirectedParticleEmitter"
  75897. * @returns a string containing the class name
  75898. */
  75899. getClassName(): string;
  75900. /**
  75901. * Serializes the particle system to a JSON object.
  75902. * @returns the JSON object
  75903. */
  75904. serialize(): any;
  75905. /**
  75906. * Parse properties from a JSON object
  75907. * @param serializationObject defines the JSON object
  75908. */
  75909. parse(serializationObject: any): void;
  75910. }
  75911. }
  75912. declare module BABYLON {
  75913. /**
  75914. * Particle emitter emitting particles from the inside of a hemisphere.
  75915. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75916. */
  75917. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75918. /**
  75919. * The radius of the emission hemisphere.
  75920. */
  75921. radius: number;
  75922. /**
  75923. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75924. */
  75925. radiusRange: number;
  75926. /**
  75927. * How much to randomize the particle direction [0-1].
  75928. */
  75929. directionRandomizer: number;
  75930. /**
  75931. * Creates a new instance HemisphericParticleEmitter
  75932. * @param radius the radius of the emission hemisphere (1 by default)
  75933. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75934. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75935. */
  75936. constructor(
  75937. /**
  75938. * The radius of the emission hemisphere.
  75939. */
  75940. radius?: number,
  75941. /**
  75942. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75943. */
  75944. radiusRange?: number,
  75945. /**
  75946. * How much to randomize the particle direction [0-1].
  75947. */
  75948. directionRandomizer?: number);
  75949. /**
  75950. * Called by the particle System when the direction is computed for the created particle.
  75951. * @param worldMatrix is the world matrix of the particle system
  75952. * @param directionToUpdate is the direction vector to update with the result
  75953. * @param particle is the particle we are computed the direction for
  75954. */
  75955. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75956. /**
  75957. * Called by the particle System when the position is computed for the created particle.
  75958. * @param worldMatrix is the world matrix of the particle system
  75959. * @param positionToUpdate is the position vector to update with the result
  75960. * @param particle is the particle we are computed the position for
  75961. */
  75962. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75963. /**
  75964. * Clones the current emitter and returns a copy of it
  75965. * @returns the new emitter
  75966. */
  75967. clone(): HemisphericParticleEmitter;
  75968. /**
  75969. * Called by the GPUParticleSystem to setup the update shader
  75970. * @param effect defines the update shader
  75971. */
  75972. applyToShader(effect: Effect): void;
  75973. /**
  75974. * Returns a string to use to update the GPU particles update shader
  75975. * @returns a string containng the defines string
  75976. */
  75977. getEffectDefines(): string;
  75978. /**
  75979. * Returns the string "HemisphericParticleEmitter"
  75980. * @returns a string containing the class name
  75981. */
  75982. getClassName(): string;
  75983. /**
  75984. * Serializes the particle system to a JSON object.
  75985. * @returns the JSON object
  75986. */
  75987. serialize(): any;
  75988. /**
  75989. * Parse properties from a JSON object
  75990. * @param serializationObject defines the JSON object
  75991. */
  75992. parse(serializationObject: any): void;
  75993. }
  75994. }
  75995. declare module BABYLON {
  75996. /**
  75997. * Particle emitter emitting particles from a point.
  75998. * It emits the particles randomly between 2 given directions.
  75999. */
  76000. export class PointParticleEmitter implements IParticleEmitterType {
  76001. /**
  76002. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  76003. */
  76004. direction1: Vector3;
  76005. /**
  76006. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  76007. */
  76008. direction2: Vector3;
  76009. /**
  76010. * Creates a new instance PointParticleEmitter
  76011. */
  76012. constructor();
  76013. /**
  76014. * Called by the particle System when the direction is computed for the created particle.
  76015. * @param worldMatrix is the world matrix of the particle system
  76016. * @param directionToUpdate is the direction vector to update with the result
  76017. * @param particle is the particle we are computed the direction for
  76018. */
  76019. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76020. /**
  76021. * Called by the particle System when the position is computed for the created particle.
  76022. * @param worldMatrix is the world matrix of the particle system
  76023. * @param positionToUpdate is the position vector to update with the result
  76024. * @param particle is the particle we are computed the position for
  76025. */
  76026. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  76027. /**
  76028. * Clones the current emitter and returns a copy of it
  76029. * @returns the new emitter
  76030. */
  76031. clone(): PointParticleEmitter;
  76032. /**
  76033. * Called by the GPUParticleSystem to setup the update shader
  76034. * @param effect defines the update shader
  76035. */
  76036. applyToShader(effect: Effect): void;
  76037. /**
  76038. * Returns a string to use to update the GPU particles update shader
  76039. * @returns a string containng the defines string
  76040. */
  76041. getEffectDefines(): string;
  76042. /**
  76043. * Returns the string "PointParticleEmitter"
  76044. * @returns a string containing the class name
  76045. */
  76046. getClassName(): string;
  76047. /**
  76048. * Serializes the particle system to a JSON object.
  76049. * @returns the JSON object
  76050. */
  76051. serialize(): any;
  76052. /**
  76053. * Parse properties from a JSON object
  76054. * @param serializationObject defines the JSON object
  76055. */
  76056. parse(serializationObject: any): void;
  76057. }
  76058. }
  76059. declare module BABYLON {
  76060. /**
  76061. * Particle emitter emitting particles from the inside of a sphere.
  76062. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  76063. */
  76064. export class SphereParticleEmitter implements IParticleEmitterType {
  76065. /**
  76066. * The radius of the emission sphere.
  76067. */
  76068. radius: number;
  76069. /**
  76070. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  76071. */
  76072. radiusRange: number;
  76073. /**
  76074. * How much to randomize the particle direction [0-1].
  76075. */
  76076. directionRandomizer: number;
  76077. /**
  76078. * Creates a new instance SphereParticleEmitter
  76079. * @param radius the radius of the emission sphere (1 by default)
  76080. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76081. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  76082. */
  76083. constructor(
  76084. /**
  76085. * The radius of the emission sphere.
  76086. */
  76087. radius?: number,
  76088. /**
  76089. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  76090. */
  76091. radiusRange?: number,
  76092. /**
  76093. * How much to randomize the particle direction [0-1].
  76094. */
  76095. directionRandomizer?: number);
  76096. /**
  76097. * Called by the particle System when the direction is computed for the created particle.
  76098. * @param worldMatrix is the world matrix of the particle system
  76099. * @param directionToUpdate is the direction vector to update with the result
  76100. * @param particle is the particle we are computed the direction for
  76101. */
  76102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76103. /**
  76104. * Called by the particle System when the position is computed for the created particle.
  76105. * @param worldMatrix is the world matrix of the particle system
  76106. * @param positionToUpdate is the position vector to update with the result
  76107. * @param particle is the particle we are computed the position for
  76108. */
  76109. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  76110. /**
  76111. * Clones the current emitter and returns a copy of it
  76112. * @returns the new emitter
  76113. */
  76114. clone(): SphereParticleEmitter;
  76115. /**
  76116. * Called by the GPUParticleSystem to setup the update shader
  76117. * @param effect defines the update shader
  76118. */
  76119. applyToShader(effect: Effect): void;
  76120. /**
  76121. * Returns a string to use to update the GPU particles update shader
  76122. * @returns a string containng the defines string
  76123. */
  76124. getEffectDefines(): string;
  76125. /**
  76126. * Returns the string "SphereParticleEmitter"
  76127. * @returns a string containing the class name
  76128. */
  76129. getClassName(): string;
  76130. /**
  76131. * Serializes the particle system to a JSON object.
  76132. * @returns the JSON object
  76133. */
  76134. serialize(): any;
  76135. /**
  76136. * Parse properties from a JSON object
  76137. * @param serializationObject defines the JSON object
  76138. */
  76139. parse(serializationObject: any): void;
  76140. }
  76141. /**
  76142. * Particle emitter emitting particles from the inside of a sphere.
  76143. * It emits the particles randomly between two vectors.
  76144. */
  76145. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76146. /**
  76147. * The min limit of the emission direction.
  76148. */
  76149. direction1: Vector3;
  76150. /**
  76151. * The max limit of the emission direction.
  76152. */
  76153. direction2: Vector3;
  76154. /**
  76155. * Creates a new instance SphereDirectedParticleEmitter
  76156. * @param radius the radius of the emission sphere (1 by default)
  76157. * @param direction1 the min limit of the emission direction (up vector by default)
  76158. * @param direction2 the max limit of the emission direction (up vector by default)
  76159. */
  76160. constructor(radius?: number,
  76161. /**
  76162. * The min limit of the emission direction.
  76163. */
  76164. direction1?: Vector3,
  76165. /**
  76166. * The max limit of the emission direction.
  76167. */
  76168. direction2?: Vector3);
  76169. /**
  76170. * Called by the particle System when the direction is computed for the created particle.
  76171. * @param worldMatrix is the world matrix of the particle system
  76172. * @param directionToUpdate is the direction vector to update with the result
  76173. * @param particle is the particle we are computed the direction for
  76174. */
  76175. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76176. /**
  76177. * Clones the current emitter and returns a copy of it
  76178. * @returns the new emitter
  76179. */
  76180. clone(): SphereDirectedParticleEmitter;
  76181. /**
  76182. * Called by the GPUParticleSystem to setup the update shader
  76183. * @param effect defines the update shader
  76184. */
  76185. applyToShader(effect: Effect): void;
  76186. /**
  76187. * Returns a string to use to update the GPU particles update shader
  76188. * @returns a string containng the defines string
  76189. */
  76190. getEffectDefines(): string;
  76191. /**
  76192. * Returns the string "SphereDirectedParticleEmitter"
  76193. * @returns a string containing the class name
  76194. */
  76195. getClassName(): string;
  76196. /**
  76197. * Serializes the particle system to a JSON object.
  76198. * @returns the JSON object
  76199. */
  76200. serialize(): any;
  76201. /**
  76202. * Parse properties from a JSON object
  76203. * @param serializationObject defines the JSON object
  76204. */
  76205. parse(serializationObject: any): void;
  76206. }
  76207. }
  76208. declare module BABYLON {
  76209. /**
  76210. * Interface representing a particle system in Babylon.js.
  76211. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76212. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76213. */
  76214. export interface IParticleSystem {
  76215. /**
  76216. * List of animations used by the particle system.
  76217. */
  76218. animations: Animation[];
  76219. /**
  76220. * The id of the Particle system.
  76221. */
  76222. id: string;
  76223. /**
  76224. * The name of the Particle system.
  76225. */
  76226. name: string;
  76227. /**
  76228. * The emitter represents the Mesh or position we are attaching the particle system to.
  76229. */
  76230. emitter: Nullable<AbstractMesh | Vector3>;
  76231. /**
  76232. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76233. */
  76234. isBillboardBased: boolean;
  76235. /**
  76236. * The rendering group used by the Particle system to chose when to render.
  76237. */
  76238. renderingGroupId: number;
  76239. /**
  76240. * The layer mask we are rendering the particles through.
  76241. */
  76242. layerMask: number;
  76243. /**
  76244. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76245. */
  76246. updateSpeed: number;
  76247. /**
  76248. * The amount of time the particle system is running (depends of the overall update speed).
  76249. */
  76250. targetStopDuration: number;
  76251. /**
  76252. * The texture used to render each particle. (this can be a spritesheet)
  76253. */
  76254. particleTexture: Nullable<Texture>;
  76255. /**
  76256. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76257. */
  76258. blendMode: number;
  76259. /**
  76260. * Minimum life time of emitting particles.
  76261. */
  76262. minLifeTime: number;
  76263. /**
  76264. * Maximum life time of emitting particles.
  76265. */
  76266. maxLifeTime: number;
  76267. /**
  76268. * Minimum Size of emitting particles.
  76269. */
  76270. minSize: number;
  76271. /**
  76272. * Maximum Size of emitting particles.
  76273. */
  76274. maxSize: number;
  76275. /**
  76276. * Minimum scale of emitting particles on X axis.
  76277. */
  76278. minScaleX: number;
  76279. /**
  76280. * Maximum scale of emitting particles on X axis.
  76281. */
  76282. maxScaleX: number;
  76283. /**
  76284. * Minimum scale of emitting particles on Y axis.
  76285. */
  76286. minScaleY: number;
  76287. /**
  76288. * Maximum scale of emitting particles on Y axis.
  76289. */
  76290. maxScaleY: number;
  76291. /**
  76292. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76293. */
  76294. color1: Color4;
  76295. /**
  76296. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76297. */
  76298. color2: Color4;
  76299. /**
  76300. * Color the particle will have at the end of its lifetime.
  76301. */
  76302. colorDead: Color4;
  76303. /**
  76304. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76305. */
  76306. emitRate: number;
  76307. /**
  76308. * You can use gravity if you want to give an orientation to your particles.
  76309. */
  76310. gravity: Vector3;
  76311. /**
  76312. * Minimum power of emitting particles.
  76313. */
  76314. minEmitPower: number;
  76315. /**
  76316. * Maximum power of emitting particles.
  76317. */
  76318. maxEmitPower: number;
  76319. /**
  76320. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76321. */
  76322. minAngularSpeed: number;
  76323. /**
  76324. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76325. */
  76326. maxAngularSpeed: number;
  76327. /**
  76328. * Gets or sets the minimal initial rotation in radians.
  76329. */
  76330. minInitialRotation: number;
  76331. /**
  76332. * Gets or sets the maximal initial rotation in radians.
  76333. */
  76334. maxInitialRotation: number;
  76335. /**
  76336. * The particle emitter type defines the emitter used by the particle system.
  76337. * It can be for example box, sphere, or cone...
  76338. */
  76339. particleEmitterType: Nullable<IParticleEmitterType>;
  76340. /**
  76341. * Defines the delay in milliseconds before starting the system (0 by default)
  76342. */
  76343. startDelay: number;
  76344. /**
  76345. * 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
  76346. */
  76347. preWarmCycles: number;
  76348. /**
  76349. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76350. */
  76351. preWarmStepOffset: number;
  76352. /**
  76353. * 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)
  76354. */
  76355. spriteCellChangeSpeed: number;
  76356. /**
  76357. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76358. */
  76359. startSpriteCellID: number;
  76360. /**
  76361. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76362. */
  76363. endSpriteCellID: number;
  76364. /**
  76365. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76366. */
  76367. spriteCellWidth: number;
  76368. /**
  76369. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76370. */
  76371. spriteCellHeight: number;
  76372. /**
  76373. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76374. */
  76375. spriteRandomStartCell: boolean;
  76376. /**
  76377. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76378. */
  76379. isAnimationSheetEnabled: boolean;
  76380. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76381. translationPivot: Vector2;
  76382. /**
  76383. * Gets or sets a texture used to add random noise to particle positions
  76384. */
  76385. noiseTexture: Nullable<BaseTexture>;
  76386. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76387. noiseStrength: Vector3;
  76388. /**
  76389. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76390. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76391. */
  76392. billboardMode: number;
  76393. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76394. limitVelocityDamping: number;
  76395. /**
  76396. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76397. */
  76398. beginAnimationOnStart: boolean;
  76399. /**
  76400. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76401. */
  76402. beginAnimationFrom: number;
  76403. /**
  76404. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76405. */
  76406. beginAnimationTo: number;
  76407. /**
  76408. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76409. */
  76410. beginAnimationLoop: boolean;
  76411. /**
  76412. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76413. */
  76414. disposeOnStop: boolean;
  76415. /**
  76416. * Gets the maximum number of particles active at the same time.
  76417. * @returns The max number of active particles.
  76418. */
  76419. getCapacity(): number;
  76420. /**
  76421. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76422. * @returns True if it has been started, otherwise false.
  76423. */
  76424. isStarted(): boolean;
  76425. /**
  76426. * Animates the particle system for this frame.
  76427. */
  76428. animate(): void;
  76429. /**
  76430. * Renders the particle system in its current state.
  76431. * @returns the current number of particles
  76432. */
  76433. render(): number;
  76434. /**
  76435. * Dispose the particle system and frees its associated resources.
  76436. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76437. */
  76438. dispose(disposeTexture?: boolean): void;
  76439. /**
  76440. * Clones the particle system.
  76441. * @param name The name of the cloned object
  76442. * @param newEmitter The new emitter to use
  76443. * @returns the cloned particle system
  76444. */
  76445. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76446. /**
  76447. * Serializes the particle system to a JSON object.
  76448. * @returns the JSON object
  76449. */
  76450. serialize(): any;
  76451. /**
  76452. * Rebuild the particle system
  76453. */
  76454. rebuild(): void;
  76455. /**
  76456. * Starts the particle system and begins to emit
  76457. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76458. */
  76459. start(delay?: number): void;
  76460. /**
  76461. * Stops the particle system.
  76462. */
  76463. stop(): void;
  76464. /**
  76465. * Remove all active particles
  76466. */
  76467. reset(): void;
  76468. /**
  76469. * Is this system ready to be used/rendered
  76470. * @return true if the system is ready
  76471. */
  76472. isReady(): boolean;
  76473. /**
  76474. * Adds a new color gradient
  76475. * @param gradient defines the gradient to use (between 0 and 1)
  76476. * @param color1 defines the color to affect to the specified gradient
  76477. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76478. * @returns the current particle system
  76479. */
  76480. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76481. /**
  76482. * Remove a specific color gradient
  76483. * @param gradient defines the gradient to remove
  76484. * @returns the current particle system
  76485. */
  76486. removeColorGradient(gradient: number): IParticleSystem;
  76487. /**
  76488. * Adds a new size gradient
  76489. * @param gradient defines the gradient to use (between 0 and 1)
  76490. * @param factor defines the size factor to affect to the specified gradient
  76491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76492. * @returns the current particle system
  76493. */
  76494. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76495. /**
  76496. * Remove a specific size gradient
  76497. * @param gradient defines the gradient to remove
  76498. * @returns the current particle system
  76499. */
  76500. removeSizeGradient(gradient: number): IParticleSystem;
  76501. /**
  76502. * Gets the current list of color gradients.
  76503. * You must use addColorGradient and removeColorGradient to udpate this list
  76504. * @returns the list of color gradients
  76505. */
  76506. getColorGradients(): Nullable<Array<ColorGradient>>;
  76507. /**
  76508. * Gets the current list of size gradients.
  76509. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76510. * @returns the list of size gradients
  76511. */
  76512. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76513. /**
  76514. * Gets the current list of angular speed gradients.
  76515. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76516. * @returns the list of angular speed gradients
  76517. */
  76518. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76519. /**
  76520. * Adds a new angular speed gradient
  76521. * @param gradient defines the gradient to use (between 0 and 1)
  76522. * @param factor defines the angular speed to affect to the specified gradient
  76523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76524. * @returns the current particle system
  76525. */
  76526. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76527. /**
  76528. * Remove a specific angular speed gradient
  76529. * @param gradient defines the gradient to remove
  76530. * @returns the current particle system
  76531. */
  76532. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76533. /**
  76534. * Gets the current list of velocity gradients.
  76535. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76536. * @returns the list of velocity gradients
  76537. */
  76538. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76539. /**
  76540. * Adds a new velocity gradient
  76541. * @param gradient defines the gradient to use (between 0 and 1)
  76542. * @param factor defines the velocity to affect to the specified gradient
  76543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76544. * @returns the current particle system
  76545. */
  76546. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76547. /**
  76548. * Remove a specific velocity gradient
  76549. * @param gradient defines the gradient to remove
  76550. * @returns the current particle system
  76551. */
  76552. removeVelocityGradient(gradient: number): IParticleSystem;
  76553. /**
  76554. * Gets the current list of limit velocity gradients.
  76555. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76556. * @returns the list of limit velocity gradients
  76557. */
  76558. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76559. /**
  76560. * Adds a new limit velocity gradient
  76561. * @param gradient defines the gradient to use (between 0 and 1)
  76562. * @param factor defines the limit velocity to affect to the specified gradient
  76563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76564. * @returns the current particle system
  76565. */
  76566. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76567. /**
  76568. * Remove a specific limit velocity gradient
  76569. * @param gradient defines the gradient to remove
  76570. * @returns the current particle system
  76571. */
  76572. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76573. /**
  76574. * Adds a new drag gradient
  76575. * @param gradient defines the gradient to use (between 0 and 1)
  76576. * @param factor defines the drag to affect to the specified gradient
  76577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76578. * @returns the current particle system
  76579. */
  76580. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76581. /**
  76582. * Remove a specific drag gradient
  76583. * @param gradient defines the gradient to remove
  76584. * @returns the current particle system
  76585. */
  76586. removeDragGradient(gradient: number): IParticleSystem;
  76587. /**
  76588. * Gets the current list of drag gradients.
  76589. * You must use addDragGradient and removeDragGradient to udpate this list
  76590. * @returns the list of drag gradients
  76591. */
  76592. getDragGradients(): Nullable<Array<FactorGradient>>;
  76593. /**
  76594. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76595. * @param gradient defines the gradient to use (between 0 and 1)
  76596. * @param factor defines the emit rate to affect to the specified gradient
  76597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76598. * @returns the current particle system
  76599. */
  76600. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76601. /**
  76602. * Remove a specific emit rate gradient
  76603. * @param gradient defines the gradient to remove
  76604. * @returns the current particle system
  76605. */
  76606. removeEmitRateGradient(gradient: number): IParticleSystem;
  76607. /**
  76608. * Gets the current list of emit rate gradients.
  76609. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76610. * @returns the list of emit rate gradients
  76611. */
  76612. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76613. /**
  76614. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76615. * @param gradient defines the gradient to use (between 0 and 1)
  76616. * @param factor defines the start size to affect to the specified gradient
  76617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76618. * @returns the current particle system
  76619. */
  76620. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76621. /**
  76622. * Remove a specific start size gradient
  76623. * @param gradient defines the gradient to remove
  76624. * @returns the current particle system
  76625. */
  76626. removeStartSizeGradient(gradient: number): IParticleSystem;
  76627. /**
  76628. * Gets the current list of start size gradients.
  76629. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76630. * @returns the list of start size gradients
  76631. */
  76632. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76633. /**
  76634. * Adds a new life time gradient
  76635. * @param gradient defines the gradient to use (between 0 and 1)
  76636. * @param factor defines the life time factor to affect to the specified gradient
  76637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76638. * @returns the current particle system
  76639. */
  76640. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76641. /**
  76642. * Remove a specific life time gradient
  76643. * @param gradient defines the gradient to remove
  76644. * @returns the current particle system
  76645. */
  76646. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76647. /**
  76648. * Gets the current list of life time gradients.
  76649. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76650. * @returns the list of life time gradients
  76651. */
  76652. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76653. /**
  76654. * Gets the current list of color gradients.
  76655. * You must use addColorGradient and removeColorGradient to udpate this list
  76656. * @returns the list of color gradients
  76657. */
  76658. getColorGradients(): Nullable<Array<ColorGradient>>;
  76659. /**
  76660. * Adds a new ramp gradient used to remap particle colors
  76661. * @param gradient defines the gradient to use (between 0 and 1)
  76662. * @param color defines the color to affect to the specified gradient
  76663. * @returns the current particle system
  76664. */
  76665. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76666. /**
  76667. * Gets the current list of ramp gradients.
  76668. * You must use addRampGradient and removeRampGradient to udpate this list
  76669. * @returns the list of ramp gradients
  76670. */
  76671. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76672. /** Gets or sets a boolean indicating that ramp gradients must be used
  76673. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76674. */
  76675. useRampGradients: boolean;
  76676. /**
  76677. * Adds a new color remap gradient
  76678. * @param gradient defines the gradient to use (between 0 and 1)
  76679. * @param min defines the color remap minimal range
  76680. * @param max defines the color remap maximal range
  76681. * @returns the current particle system
  76682. */
  76683. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76684. /**
  76685. * Gets the current list of color remap gradients.
  76686. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76687. * @returns the list of color remap gradients
  76688. */
  76689. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76690. /**
  76691. * Adds a new alpha remap gradient
  76692. * @param gradient defines the gradient to use (between 0 and 1)
  76693. * @param min defines the alpha remap minimal range
  76694. * @param max defines the alpha remap maximal range
  76695. * @returns the current particle system
  76696. */
  76697. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76698. /**
  76699. * Gets the current list of alpha remap gradients.
  76700. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76701. * @returns the list of alpha remap gradients
  76702. */
  76703. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76704. /**
  76705. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76706. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76707. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76708. * @returns the emitter
  76709. */
  76710. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76711. /**
  76712. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76713. * @param radius The radius of the hemisphere to emit from
  76714. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76715. * @returns the emitter
  76716. */
  76717. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76718. /**
  76719. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76720. * @param radius The radius of the sphere to emit from
  76721. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76722. * @returns the emitter
  76723. */
  76724. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76725. /**
  76726. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76727. * @param radius The radius of the sphere to emit from
  76728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76730. * @returns the emitter
  76731. */
  76732. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76733. /**
  76734. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76735. * @param radius The radius of the emission cylinder
  76736. * @param height The height of the emission cylinder
  76737. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76738. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76739. * @returns the emitter
  76740. */
  76741. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76742. /**
  76743. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76744. * @param radius The radius of the cylinder to emit from
  76745. * @param height The height of the emission cylinder
  76746. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76747. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76748. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76749. * @returns the emitter
  76750. */
  76751. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76752. /**
  76753. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76754. * @param radius The radius of the cone to emit from
  76755. * @param angle The base angle of the cone
  76756. * @returns the emitter
  76757. */
  76758. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76759. /**
  76760. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76761. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76762. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76763. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76764. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76765. * @returns the emitter
  76766. */
  76767. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76768. /**
  76769. * Get hosting scene
  76770. * @returns the scene
  76771. */
  76772. getScene(): Scene;
  76773. }
  76774. }
  76775. declare module BABYLON {
  76776. /**
  76777. * Creates an instance based on a source mesh.
  76778. */
  76779. export class InstancedMesh extends AbstractMesh {
  76780. private _sourceMesh;
  76781. private _currentLOD;
  76782. /** @hidden */
  76783. _indexInSourceMeshInstanceArray: number;
  76784. constructor(name: string, source: Mesh);
  76785. /**
  76786. * Returns the string "InstancedMesh".
  76787. */
  76788. getClassName(): string;
  76789. /** Gets the list of lights affecting that mesh */
  76790. readonly lightSources: Light[];
  76791. _resyncLightSources(): void;
  76792. _resyncLighSource(light: Light): void;
  76793. _removeLightSource(light: Light): void;
  76794. /**
  76795. * If the source mesh receives shadows
  76796. */
  76797. readonly receiveShadows: boolean;
  76798. /**
  76799. * The material of the source mesh
  76800. */
  76801. readonly material: Nullable<Material>;
  76802. /**
  76803. * Visibility of the source mesh
  76804. */
  76805. readonly visibility: number;
  76806. /**
  76807. * Skeleton of the source mesh
  76808. */
  76809. readonly skeleton: Nullable<Skeleton>;
  76810. /**
  76811. * Rendering ground id of the source mesh
  76812. */
  76813. renderingGroupId: number;
  76814. /**
  76815. * Returns the total number of vertices (integer).
  76816. */
  76817. getTotalVertices(): number;
  76818. /**
  76819. * Returns a positive integer : the total number of indices in this mesh geometry.
  76820. * @returns the numner of indices or zero if the mesh has no geometry.
  76821. */
  76822. getTotalIndices(): number;
  76823. /**
  76824. * The source mesh of the instance
  76825. */
  76826. readonly sourceMesh: Mesh;
  76827. /**
  76828. * Is this node ready to be used/rendered
  76829. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76830. * @return {boolean} is it ready
  76831. */
  76832. isReady(completeCheck?: boolean): boolean;
  76833. /**
  76834. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76835. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76836. * @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.
  76837. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76838. */
  76839. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76840. /**
  76841. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76842. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76843. * The `data` are either a numeric array either a Float32Array.
  76844. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76845. * 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).
  76846. * Note that a new underlying VertexBuffer object is created each call.
  76847. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76848. *
  76849. * Possible `kind` values :
  76850. * - VertexBuffer.PositionKind
  76851. * - VertexBuffer.UVKind
  76852. * - VertexBuffer.UV2Kind
  76853. * - VertexBuffer.UV3Kind
  76854. * - VertexBuffer.UV4Kind
  76855. * - VertexBuffer.UV5Kind
  76856. * - VertexBuffer.UV6Kind
  76857. * - VertexBuffer.ColorKind
  76858. * - VertexBuffer.MatricesIndicesKind
  76859. * - VertexBuffer.MatricesIndicesExtraKind
  76860. * - VertexBuffer.MatricesWeightsKind
  76861. * - VertexBuffer.MatricesWeightsExtraKind
  76862. *
  76863. * Returns the Mesh.
  76864. */
  76865. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76866. /**
  76867. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76868. * If the mesh has no geometry, it is simply returned as it is.
  76869. * The `data` are either a numeric array either a Float32Array.
  76870. * No new underlying VertexBuffer object is created.
  76871. * 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.
  76872. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76873. *
  76874. * Possible `kind` values :
  76875. * - VertexBuffer.PositionKind
  76876. * - VertexBuffer.UVKind
  76877. * - VertexBuffer.UV2Kind
  76878. * - VertexBuffer.UV3Kind
  76879. * - VertexBuffer.UV4Kind
  76880. * - VertexBuffer.UV5Kind
  76881. * - VertexBuffer.UV6Kind
  76882. * - VertexBuffer.ColorKind
  76883. * - VertexBuffer.MatricesIndicesKind
  76884. * - VertexBuffer.MatricesIndicesExtraKind
  76885. * - VertexBuffer.MatricesWeightsKind
  76886. * - VertexBuffer.MatricesWeightsExtraKind
  76887. *
  76888. * Returns the Mesh.
  76889. */
  76890. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76891. /**
  76892. * Sets the mesh indices.
  76893. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76894. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76895. * This method creates a new index buffer each call.
  76896. * Returns the Mesh.
  76897. */
  76898. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76899. /**
  76900. * Boolean : True if the mesh owns the requested kind of data.
  76901. */
  76902. isVerticesDataPresent(kind: string): boolean;
  76903. /**
  76904. * Returns an array of indices (IndicesArray).
  76905. */
  76906. getIndices(): Nullable<IndicesArray>;
  76907. readonly _positions: Nullable<Vector3[]>;
  76908. /**
  76909. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76910. * This means the mesh underlying bounding box and sphere are recomputed.
  76911. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76912. * @returns the current mesh
  76913. */
  76914. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76915. /** @hidden */
  76916. _preActivate(): InstancedMesh;
  76917. /** @hidden */
  76918. _activate(renderId: number, intermediateRendering: boolean): boolean;
  76919. /** @hidden */
  76920. _postActivate(): void;
  76921. getWorldMatrix(): Matrix;
  76922. readonly isAnInstance: boolean;
  76923. /**
  76924. * Returns the current associated LOD AbstractMesh.
  76925. */
  76926. getLOD(camera: Camera): AbstractMesh;
  76927. /** @hidden */
  76928. _syncSubMeshes(): InstancedMesh;
  76929. /** @hidden */
  76930. _generatePointsArray(): boolean;
  76931. /**
  76932. * Creates a new InstancedMesh from the current mesh.
  76933. * - name (string) : the cloned mesh name
  76934. * - newParent (optional Node) : the optional Node to parent the clone to.
  76935. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76936. *
  76937. * Returns the clone.
  76938. */
  76939. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76940. /**
  76941. * Disposes the InstancedMesh.
  76942. * Returns nothing.
  76943. */
  76944. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76945. }
  76946. }
  76947. declare module BABYLON {
  76948. /**
  76949. * Defines the options associated with the creation of a shader material.
  76950. */
  76951. export interface IShaderMaterialOptions {
  76952. /**
  76953. * Does the material work in alpha blend mode
  76954. */
  76955. needAlphaBlending: boolean;
  76956. /**
  76957. * Does the material work in alpha test mode
  76958. */
  76959. needAlphaTesting: boolean;
  76960. /**
  76961. * The list of attribute names used in the shader
  76962. */
  76963. attributes: string[];
  76964. /**
  76965. * The list of unifrom names used in the shader
  76966. */
  76967. uniforms: string[];
  76968. /**
  76969. * The list of UBO names used in the shader
  76970. */
  76971. uniformBuffers: string[];
  76972. /**
  76973. * The list of sampler names used in the shader
  76974. */
  76975. samplers: string[];
  76976. /**
  76977. * The list of defines used in the shader
  76978. */
  76979. defines: string[];
  76980. }
  76981. /**
  76982. * 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.
  76983. *
  76984. * This returned material effects how the mesh will look based on the code in the shaders.
  76985. *
  76986. * @see http://doc.babylonjs.com/how_to/shader_material
  76987. */
  76988. export class ShaderMaterial extends Material {
  76989. private _shaderPath;
  76990. private _options;
  76991. private _textures;
  76992. private _textureArrays;
  76993. private _floats;
  76994. private _ints;
  76995. private _floatsArrays;
  76996. private _colors3;
  76997. private _colors3Arrays;
  76998. private _colors4;
  76999. private _vectors2;
  77000. private _vectors3;
  77001. private _vectors4;
  77002. private _matrices;
  77003. private _matrices3x3;
  77004. private _matrices2x2;
  77005. private _vectors2Arrays;
  77006. private _vectors3Arrays;
  77007. private _cachedWorldViewMatrix;
  77008. private _renderId;
  77009. /**
  77010. * Instantiate a new shader material.
  77011. * 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.
  77012. * This returned material effects how the mesh will look based on the code in the shaders.
  77013. * @see http://doc.babylonjs.com/how_to/shader_material
  77014. * @param name Define the name of the material in the scene
  77015. * @param scene Define the scene the material belongs to
  77016. * @param shaderPath Defines the route to the shader code in one of three ways:
  77017. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  77018. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  77019. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  77020. * @param options Define the options used to create the shader
  77021. */
  77022. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  77023. /**
  77024. * Gets the options used to compile the shader.
  77025. * They can be modified to trigger a new compilation
  77026. */
  77027. readonly options: IShaderMaterialOptions;
  77028. /**
  77029. * Gets the current class name of the material e.g. "ShaderMaterial"
  77030. * Mainly use in serialization.
  77031. * @returns the class name
  77032. */
  77033. getClassName(): string;
  77034. /**
  77035. * Specifies if the material will require alpha blending
  77036. * @returns a boolean specifying if alpha blending is needed
  77037. */
  77038. needAlphaBlending(): boolean;
  77039. /**
  77040. * Specifies if this material should be rendered in alpha test mode
  77041. * @returns a boolean specifying if an alpha test is needed.
  77042. */
  77043. needAlphaTesting(): boolean;
  77044. private _checkUniform;
  77045. /**
  77046. * Set a texture in the shader.
  77047. * @param name Define the name of the uniform samplers as defined in the shader
  77048. * @param texture Define the texture to bind to this sampler
  77049. * @return the material itself allowing "fluent" like uniform updates
  77050. */
  77051. setTexture(name: string, texture: Texture): ShaderMaterial;
  77052. /**
  77053. * Set a texture array in the shader.
  77054. * @param name Define the name of the uniform sampler array as defined in the shader
  77055. * @param textures Define the list of textures to bind to this sampler
  77056. * @return the material itself allowing "fluent" like uniform updates
  77057. */
  77058. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  77059. /**
  77060. * Set a float in the shader.
  77061. * @param name Define the name of the uniform as defined in the shader
  77062. * @param value Define the value to give to the uniform
  77063. * @return the material itself allowing "fluent" like uniform updates
  77064. */
  77065. setFloat(name: string, value: number): ShaderMaterial;
  77066. /**
  77067. * Set a int in the shader.
  77068. * @param name Define the name of the uniform as defined in the shader
  77069. * @param value Define the value to give to the uniform
  77070. * @return the material itself allowing "fluent" like uniform updates
  77071. */
  77072. setInt(name: string, value: number): ShaderMaterial;
  77073. /**
  77074. * Set an array of floats in the shader.
  77075. * @param name Define the name of the uniform as defined in the shader
  77076. * @param value Define the value to give to the uniform
  77077. * @return the material itself allowing "fluent" like uniform updates
  77078. */
  77079. setFloats(name: string, value: number[]): ShaderMaterial;
  77080. /**
  77081. * Set a vec3 in the shader from a Color3.
  77082. * @param name Define the name of the uniform as defined in the shader
  77083. * @param value Define the value to give to the uniform
  77084. * @return the material itself allowing "fluent" like uniform updates
  77085. */
  77086. setColor3(name: string, value: Color3): ShaderMaterial;
  77087. /**
  77088. * Set a vec3 array in the shader from a Color3 array.
  77089. * @param name Define the name of the uniform as defined in the shader
  77090. * @param value Define the value to give to the uniform
  77091. * @return the material itself allowing "fluent" like uniform updates
  77092. */
  77093. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  77094. /**
  77095. * Set a vec4 in the shader from a Color4.
  77096. * @param name Define the name of the uniform as defined in the shader
  77097. * @param value Define the value to give to the uniform
  77098. * @return the material itself allowing "fluent" like uniform updates
  77099. */
  77100. setColor4(name: string, value: Color4): ShaderMaterial;
  77101. /**
  77102. * Set a vec2 in the shader from a Vector2.
  77103. * @param name Define the name of the uniform as defined in the shader
  77104. * @param value Define the value to give to the uniform
  77105. * @return the material itself allowing "fluent" like uniform updates
  77106. */
  77107. setVector2(name: string, value: Vector2): ShaderMaterial;
  77108. /**
  77109. * Set a vec3 in the shader from a Vector3.
  77110. * @param name Define the name of the uniform as defined in the shader
  77111. * @param value Define the value to give to the uniform
  77112. * @return the material itself allowing "fluent" like uniform updates
  77113. */
  77114. setVector3(name: string, value: Vector3): ShaderMaterial;
  77115. /**
  77116. * Set a vec4 in the shader from a Vector4.
  77117. * @param name Define the name of the uniform as defined in the shader
  77118. * @param value Define the value to give to the uniform
  77119. * @return the material itself allowing "fluent" like uniform updates
  77120. */
  77121. setVector4(name: string, value: Vector4): ShaderMaterial;
  77122. /**
  77123. * Set a mat4 in the shader from a Matrix.
  77124. * @param name Define the name of the uniform as defined in the shader
  77125. * @param value Define the value to give to the uniform
  77126. * @return the material itself allowing "fluent" like uniform updates
  77127. */
  77128. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77129. /**
  77130. * Set a mat3 in the shader from a Float32Array.
  77131. * @param name Define the name of the uniform as defined in the shader
  77132. * @param value Define the value to give to the uniform
  77133. * @return the material itself allowing "fluent" like uniform updates
  77134. */
  77135. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77136. /**
  77137. * Set a mat2 in the shader from a Float32Array.
  77138. * @param name Define the name of the uniform as defined in the shader
  77139. * @param value Define the value to give to the uniform
  77140. * @return the material itself allowing "fluent" like uniform updates
  77141. */
  77142. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77143. /**
  77144. * Set a vec2 array in the shader from a number array.
  77145. * @param name Define the name of the uniform as defined in the shader
  77146. * @param value Define the value to give to the uniform
  77147. * @return the material itself allowing "fluent" like uniform updates
  77148. */
  77149. setArray2(name: string, value: number[]): ShaderMaterial;
  77150. /**
  77151. * Set a vec3 array in the shader from a number array.
  77152. * @param name Define the name of the uniform as defined in the shader
  77153. * @param value Define the value to give to the uniform
  77154. * @return the material itself allowing "fluent" like uniform updates
  77155. */
  77156. setArray3(name: string, value: number[]): ShaderMaterial;
  77157. private _checkCache;
  77158. /**
  77159. * Specifies that the submesh is ready to be used
  77160. * @param mesh defines the mesh to check
  77161. * @param subMesh defines which submesh to check
  77162. * @param useInstances specifies that instances should be used
  77163. * @returns a boolean indicating that the submesh is ready or not
  77164. */
  77165. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77166. /**
  77167. * Checks if the material is ready to render the requested mesh
  77168. * @param mesh Define the mesh to render
  77169. * @param useInstances Define whether or not the material is used with instances
  77170. * @returns true if ready, otherwise false
  77171. */
  77172. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77173. /**
  77174. * Binds the world matrix to the material
  77175. * @param world defines the world transformation matrix
  77176. */
  77177. bindOnlyWorldMatrix(world: Matrix): void;
  77178. /**
  77179. * Binds the material to the mesh
  77180. * @param world defines the world transformation matrix
  77181. * @param mesh defines the mesh to bind the material to
  77182. */
  77183. bind(world: Matrix, mesh?: Mesh): void;
  77184. /**
  77185. * Gets the active textures from the material
  77186. * @returns an array of textures
  77187. */
  77188. getActiveTextures(): BaseTexture[];
  77189. /**
  77190. * Specifies if the material uses a texture
  77191. * @param texture defines the texture to check against the material
  77192. * @returns a boolean specifying if the material uses the texture
  77193. */
  77194. hasTexture(texture: BaseTexture): boolean;
  77195. /**
  77196. * Makes a duplicate of the material, and gives it a new name
  77197. * @param name defines the new name for the duplicated material
  77198. * @returns the cloned material
  77199. */
  77200. clone(name: string): ShaderMaterial;
  77201. /**
  77202. * Disposes the material
  77203. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77204. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77205. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77206. */
  77207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77208. /**
  77209. * Serializes this material in a JSON representation
  77210. * @returns the serialized material object
  77211. */
  77212. serialize(): any;
  77213. /**
  77214. * Creates a shader material from parsed shader material data
  77215. * @param source defines the JSON represnetation of the material
  77216. * @param scene defines the hosting scene
  77217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77218. * @returns a new material
  77219. */
  77220. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77221. }
  77222. }
  77223. declare module BABYLON {
  77224. /** @hidden */
  77225. export var colorPixelShader: {
  77226. name: string;
  77227. shader: string;
  77228. };
  77229. }
  77230. declare module BABYLON {
  77231. /** @hidden */
  77232. export var colorVertexShader: {
  77233. name: string;
  77234. shader: string;
  77235. };
  77236. }
  77237. declare module BABYLON {
  77238. /**
  77239. * Line mesh
  77240. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77241. */
  77242. export class LinesMesh extends Mesh {
  77243. /**
  77244. * If vertex color should be applied to the mesh
  77245. */
  77246. useVertexColor?: boolean | undefined;
  77247. /**
  77248. * If vertex alpha should be applied to the mesh
  77249. */
  77250. useVertexAlpha?: boolean | undefined;
  77251. /**
  77252. * Color of the line (Default: White)
  77253. */
  77254. color: Color3;
  77255. /**
  77256. * Alpha of the line (Default: 1)
  77257. */
  77258. alpha: number;
  77259. /**
  77260. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77261. * This margin is expressed in world space coordinates, so its value may vary.
  77262. * Default value is 0.1
  77263. */
  77264. intersectionThreshold: number;
  77265. private _colorShader;
  77266. /**
  77267. * Creates a new LinesMesh
  77268. * @param name defines the name
  77269. * @param scene defines the hosting scene
  77270. * @param parent defines the parent mesh if any
  77271. * @param source defines the optional source LinesMesh used to clone data from
  77272. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77273. * When false, achieved by calling a clone(), also passing False.
  77274. * This will make creation of children, recursive.
  77275. * @param useVertexColor defines if this LinesMesh supports vertex color
  77276. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77277. */
  77278. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77279. /**
  77280. * If vertex color should be applied to the mesh
  77281. */
  77282. useVertexColor?: boolean | undefined,
  77283. /**
  77284. * If vertex alpha should be applied to the mesh
  77285. */
  77286. useVertexAlpha?: boolean | undefined);
  77287. private _addClipPlaneDefine;
  77288. private _removeClipPlaneDefine;
  77289. isReady(): boolean;
  77290. /**
  77291. * Returns the string "LineMesh"
  77292. */
  77293. getClassName(): string;
  77294. /**
  77295. * @hidden
  77296. */
  77297. /**
  77298. * @hidden
  77299. */
  77300. material: Material;
  77301. /**
  77302. * @hidden
  77303. */
  77304. readonly checkCollisions: boolean;
  77305. /** @hidden */
  77306. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77307. /** @hidden */
  77308. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77309. /**
  77310. * Disposes of the line mesh
  77311. * @param doNotRecurse If children should be disposed
  77312. */
  77313. dispose(doNotRecurse?: boolean): void;
  77314. /**
  77315. * Returns a new LineMesh object cloned from the current one.
  77316. */
  77317. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77318. /**
  77319. * Creates a new InstancedLinesMesh object from the mesh model.
  77320. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77321. * @param name defines the name of the new instance
  77322. * @returns a new InstancedLinesMesh
  77323. */
  77324. createInstance(name: string): InstancedLinesMesh;
  77325. }
  77326. /**
  77327. * Creates an instance based on a source LinesMesh
  77328. */
  77329. export class InstancedLinesMesh extends InstancedMesh {
  77330. /**
  77331. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77332. * This margin is expressed in world space coordinates, so its value may vary.
  77333. * Initilized with the intersectionThreshold value of the source LinesMesh
  77334. */
  77335. intersectionThreshold: number;
  77336. constructor(name: string, source: LinesMesh);
  77337. /**
  77338. * Returns the string "InstancedLinesMesh".
  77339. */
  77340. getClassName(): string;
  77341. }
  77342. }
  77343. declare module BABYLON {
  77344. /** @hidden */
  77345. export var linePixelShader: {
  77346. name: string;
  77347. shader: string;
  77348. };
  77349. }
  77350. declare module BABYLON {
  77351. /** @hidden */
  77352. export var lineVertexShader: {
  77353. name: string;
  77354. shader: string;
  77355. };
  77356. }
  77357. declare module BABYLON {
  77358. interface AbstractMesh {
  77359. /**
  77360. * Gets the edgesRenderer associated with the mesh
  77361. */
  77362. edgesRenderer: Nullable<EdgesRenderer>;
  77363. }
  77364. interface LinesMesh {
  77365. /**
  77366. * Enables the edge rendering mode on the mesh.
  77367. * This mode makes the mesh edges visible
  77368. * @param epsilon defines the maximal distance between two angles to detect a face
  77369. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77370. * @returns the currentAbstractMesh
  77371. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77372. */
  77373. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77374. }
  77375. interface InstancedLinesMesh {
  77376. /**
  77377. * Enables the edge rendering mode on the mesh.
  77378. * This mode makes the mesh edges visible
  77379. * @param epsilon defines the maximal distance between two angles to detect a face
  77380. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77381. * @returns the current InstancedLinesMesh
  77382. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77383. */
  77384. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77385. }
  77386. /**
  77387. * Defines the minimum contract an Edges renderer should follow.
  77388. */
  77389. export interface IEdgesRenderer extends IDisposable {
  77390. /**
  77391. * Gets or sets a boolean indicating if the edgesRenderer is active
  77392. */
  77393. isEnabled: boolean;
  77394. /**
  77395. * Renders the edges of the attached mesh,
  77396. */
  77397. render(): void;
  77398. /**
  77399. * Checks wether or not the edges renderer is ready to render.
  77400. * @return true if ready, otherwise false.
  77401. */
  77402. isReady(): boolean;
  77403. }
  77404. /**
  77405. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77406. */
  77407. export class EdgesRenderer implements IEdgesRenderer {
  77408. /**
  77409. * Define the size of the edges with an orthographic camera
  77410. */
  77411. edgesWidthScalerForOrthographic: number;
  77412. /**
  77413. * Define the size of the edges with a perspective camera
  77414. */
  77415. edgesWidthScalerForPerspective: number;
  77416. protected _source: AbstractMesh;
  77417. protected _linesPositions: number[];
  77418. protected _linesNormals: number[];
  77419. protected _linesIndices: number[];
  77420. protected _epsilon: number;
  77421. protected _indicesCount: number;
  77422. protected _lineShader: ShaderMaterial;
  77423. protected _ib: DataBuffer;
  77424. protected _buffers: {
  77425. [key: string]: Nullable<VertexBuffer>;
  77426. };
  77427. protected _checkVerticesInsteadOfIndices: boolean;
  77428. private _meshRebuildObserver;
  77429. private _meshDisposeObserver;
  77430. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77431. isEnabled: boolean;
  77432. /**
  77433. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77434. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77435. * @param source Mesh used to create edges
  77436. * @param epsilon sum of angles in adjacency to check for edge
  77437. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77438. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77439. */
  77440. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77441. protected _prepareRessources(): void;
  77442. /** @hidden */
  77443. _rebuild(): void;
  77444. /**
  77445. * Releases the required resources for the edges renderer
  77446. */
  77447. dispose(): void;
  77448. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77449. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77450. /**
  77451. * Checks if the pair of p0 and p1 is en edge
  77452. * @param faceIndex
  77453. * @param edge
  77454. * @param faceNormals
  77455. * @param p0
  77456. * @param p1
  77457. * @private
  77458. */
  77459. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77460. /**
  77461. * push line into the position, normal and index buffer
  77462. * @protected
  77463. */
  77464. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77465. /**
  77466. * Generates lines edges from adjacencjes
  77467. * @private
  77468. */
  77469. _generateEdgesLines(): void;
  77470. /**
  77471. * Checks wether or not the edges renderer is ready to render.
  77472. * @return true if ready, otherwise false.
  77473. */
  77474. isReady(): boolean;
  77475. /**
  77476. * Renders the edges of the attached mesh,
  77477. */
  77478. render(): void;
  77479. }
  77480. /**
  77481. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77482. */
  77483. export class LineEdgesRenderer extends EdgesRenderer {
  77484. /**
  77485. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77486. * @param source LineMesh used to generate edges
  77487. * @param epsilon not important (specified angle for edge detection)
  77488. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77489. */
  77490. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77491. /**
  77492. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77493. */
  77494. _generateEdgesLines(): void;
  77495. }
  77496. }
  77497. declare module BABYLON {
  77498. /**
  77499. * This represents the object necessary to create a rendering group.
  77500. * This is exclusively used and created by the rendering manager.
  77501. * To modify the behavior, you use the available helpers in your scene or meshes.
  77502. * @hidden
  77503. */
  77504. export class RenderingGroup {
  77505. index: number;
  77506. private _scene;
  77507. private _opaqueSubMeshes;
  77508. private _transparentSubMeshes;
  77509. private _alphaTestSubMeshes;
  77510. private _depthOnlySubMeshes;
  77511. private _particleSystems;
  77512. private _spriteManagers;
  77513. private _opaqueSortCompareFn;
  77514. private _alphaTestSortCompareFn;
  77515. private _transparentSortCompareFn;
  77516. private _renderOpaque;
  77517. private _renderAlphaTest;
  77518. private _renderTransparent;
  77519. /** @hidden */
  77520. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77521. onBeforeTransparentRendering: () => void;
  77522. /**
  77523. * Set the opaque sort comparison function.
  77524. * If null the sub meshes will be render in the order they were created
  77525. */
  77526. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77527. /**
  77528. * Set the alpha test sort comparison function.
  77529. * If null the sub meshes will be render in the order they were created
  77530. */
  77531. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77532. /**
  77533. * Set the transparent sort comparison function.
  77534. * If null the sub meshes will be render in the order they were created
  77535. */
  77536. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77537. /**
  77538. * Creates a new rendering group.
  77539. * @param index The rendering group index
  77540. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77541. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77542. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77543. */
  77544. 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>);
  77545. /**
  77546. * Render all the sub meshes contained in the group.
  77547. * @param customRenderFunction Used to override the default render behaviour of the group.
  77548. * @returns true if rendered some submeshes.
  77549. */
  77550. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77551. /**
  77552. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77553. * @param subMeshes The submeshes to render
  77554. */
  77555. private renderOpaqueSorted;
  77556. /**
  77557. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77558. * @param subMeshes The submeshes to render
  77559. */
  77560. private renderAlphaTestSorted;
  77561. /**
  77562. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77563. * @param subMeshes The submeshes to render
  77564. */
  77565. private renderTransparentSorted;
  77566. /**
  77567. * Renders the submeshes in a specified order.
  77568. * @param subMeshes The submeshes to sort before render
  77569. * @param sortCompareFn The comparison function use to sort
  77570. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77571. * @param transparent Specifies to activate blending if true
  77572. */
  77573. private static renderSorted;
  77574. /**
  77575. * Renders the submeshes in the order they were dispatched (no sort applied).
  77576. * @param subMeshes The submeshes to render
  77577. */
  77578. private static renderUnsorted;
  77579. /**
  77580. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77581. * are rendered back to front if in the same alpha index.
  77582. *
  77583. * @param a The first submesh
  77584. * @param b The second submesh
  77585. * @returns The result of the comparison
  77586. */
  77587. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77588. /**
  77589. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77590. * are rendered back to front.
  77591. *
  77592. * @param a The first submesh
  77593. * @param b The second submesh
  77594. * @returns The result of the comparison
  77595. */
  77596. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77597. /**
  77598. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77599. * are rendered front to back (prevent overdraw).
  77600. *
  77601. * @param a The first submesh
  77602. * @param b The second submesh
  77603. * @returns The result of the comparison
  77604. */
  77605. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77606. /**
  77607. * Resets the different lists of submeshes to prepare a new frame.
  77608. */
  77609. prepare(): void;
  77610. dispose(): void;
  77611. /**
  77612. * Inserts the submesh in its correct queue depending on its material.
  77613. * @param subMesh The submesh to dispatch
  77614. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77615. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77616. */
  77617. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77618. dispatchSprites(spriteManager: ISpriteManager): void;
  77619. dispatchParticles(particleSystem: IParticleSystem): void;
  77620. private _renderParticles;
  77621. private _renderSprites;
  77622. }
  77623. }
  77624. declare module BABYLON {
  77625. /**
  77626. * Interface describing the different options available in the rendering manager
  77627. * regarding Auto Clear between groups.
  77628. */
  77629. export interface IRenderingManagerAutoClearSetup {
  77630. /**
  77631. * Defines whether or not autoclear is enable.
  77632. */
  77633. autoClear: boolean;
  77634. /**
  77635. * Defines whether or not to autoclear the depth buffer.
  77636. */
  77637. depth: boolean;
  77638. /**
  77639. * Defines whether or not to autoclear the stencil buffer.
  77640. */
  77641. stencil: boolean;
  77642. }
  77643. /**
  77644. * This class is used by the onRenderingGroupObservable
  77645. */
  77646. export class RenderingGroupInfo {
  77647. /**
  77648. * The Scene that being rendered
  77649. */
  77650. scene: Scene;
  77651. /**
  77652. * The camera currently used for the rendering pass
  77653. */
  77654. camera: Nullable<Camera>;
  77655. /**
  77656. * The ID of the renderingGroup being processed
  77657. */
  77658. renderingGroupId: number;
  77659. }
  77660. /**
  77661. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77662. * It is enable to manage the different groups as well as the different necessary sort functions.
  77663. * This should not be used directly aside of the few static configurations
  77664. */
  77665. export class RenderingManager {
  77666. /**
  77667. * The max id used for rendering groups (not included)
  77668. */
  77669. static MAX_RENDERINGGROUPS: number;
  77670. /**
  77671. * The min id used for rendering groups (included)
  77672. */
  77673. static MIN_RENDERINGGROUPS: number;
  77674. /**
  77675. * Used to globally prevent autoclearing scenes.
  77676. */
  77677. static AUTOCLEAR: boolean;
  77678. /**
  77679. * @hidden
  77680. */
  77681. _useSceneAutoClearSetup: boolean;
  77682. private _scene;
  77683. private _renderingGroups;
  77684. private _depthStencilBufferAlreadyCleaned;
  77685. private _autoClearDepthStencil;
  77686. private _customOpaqueSortCompareFn;
  77687. private _customAlphaTestSortCompareFn;
  77688. private _customTransparentSortCompareFn;
  77689. private _renderingGroupInfo;
  77690. /**
  77691. * Instantiates a new rendering group for a particular scene
  77692. * @param scene Defines the scene the groups belongs to
  77693. */
  77694. constructor(scene: Scene);
  77695. private _clearDepthStencilBuffer;
  77696. /**
  77697. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77698. * @hidden
  77699. */
  77700. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77701. /**
  77702. * Resets the different information of the group to prepare a new frame
  77703. * @hidden
  77704. */
  77705. reset(): void;
  77706. /**
  77707. * Dispose and release the group and its associated resources.
  77708. * @hidden
  77709. */
  77710. dispose(): void;
  77711. /**
  77712. * Clear the info related to rendering groups preventing retention points during dispose.
  77713. */
  77714. freeRenderingGroups(): void;
  77715. private _prepareRenderingGroup;
  77716. /**
  77717. * Add a sprite manager to the rendering manager in order to render it this frame.
  77718. * @param spriteManager Define the sprite manager to render
  77719. */
  77720. dispatchSprites(spriteManager: ISpriteManager): void;
  77721. /**
  77722. * Add a particle system to the rendering manager in order to render it this frame.
  77723. * @param particleSystem Define the particle system to render
  77724. */
  77725. dispatchParticles(particleSystem: IParticleSystem): void;
  77726. /**
  77727. * Add a submesh to the manager in order to render it this frame
  77728. * @param subMesh The submesh to dispatch
  77729. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77730. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77731. */
  77732. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77733. /**
  77734. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77735. * This allowed control for front to back rendering or reversly depending of the special needs.
  77736. *
  77737. * @param renderingGroupId The rendering group id corresponding to its index
  77738. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77739. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77740. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77741. */
  77742. 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;
  77743. /**
  77744. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77745. *
  77746. * @param renderingGroupId The rendering group id corresponding to its index
  77747. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77748. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77749. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77750. */
  77751. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77752. /**
  77753. * Gets the current auto clear configuration for one rendering group of the rendering
  77754. * manager.
  77755. * @param index the rendering group index to get the information for
  77756. * @returns The auto clear setup for the requested rendering group
  77757. */
  77758. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77759. }
  77760. }
  77761. declare module BABYLON {
  77762. /**
  77763. * This Helps creating a texture that will be created from a camera in your scene.
  77764. * It is basically a dynamic texture that could be used to create special effects for instance.
  77765. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77766. */
  77767. export class RenderTargetTexture extends Texture {
  77768. isCube: boolean;
  77769. /**
  77770. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77771. */
  77772. static readonly REFRESHRATE_RENDER_ONCE: number;
  77773. /**
  77774. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77775. */
  77776. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77777. /**
  77778. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77779. * the central point of your effect and can save a lot of performances.
  77780. */
  77781. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77782. /**
  77783. * Use this predicate to dynamically define the list of mesh you want to render.
  77784. * If set, the renderList property will be overwritten.
  77785. */
  77786. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77787. private _renderList;
  77788. /**
  77789. * Use this list to define the list of mesh you want to render.
  77790. */
  77791. renderList: Nullable<Array<AbstractMesh>>;
  77792. private _hookArray;
  77793. /**
  77794. * Define if particles should be rendered in your texture.
  77795. */
  77796. renderParticles: boolean;
  77797. /**
  77798. * Define if sprites should be rendered in your texture.
  77799. */
  77800. renderSprites: boolean;
  77801. /**
  77802. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77803. */
  77804. coordinatesMode: number;
  77805. /**
  77806. * Define the camera used to render the texture.
  77807. */
  77808. activeCamera: Nullable<Camera>;
  77809. /**
  77810. * Override the render function of the texture with your own one.
  77811. */
  77812. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77813. /**
  77814. * Define if camera post processes should be use while rendering the texture.
  77815. */
  77816. useCameraPostProcesses: boolean;
  77817. /**
  77818. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77819. */
  77820. ignoreCameraViewport: boolean;
  77821. private _postProcessManager;
  77822. private _postProcesses;
  77823. private _resizeObserver;
  77824. /**
  77825. * An event triggered when the texture is unbind.
  77826. */
  77827. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77828. /**
  77829. * An event triggered when the texture is unbind.
  77830. */
  77831. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77832. private _onAfterUnbindObserver;
  77833. /**
  77834. * Set a after unbind callback in the texture.
  77835. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77836. */
  77837. onAfterUnbind: () => void;
  77838. /**
  77839. * An event triggered before rendering the texture
  77840. */
  77841. onBeforeRenderObservable: Observable<number>;
  77842. private _onBeforeRenderObserver;
  77843. /**
  77844. * Set a before render callback in the texture.
  77845. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77846. */
  77847. onBeforeRender: (faceIndex: number) => void;
  77848. /**
  77849. * An event triggered after rendering the texture
  77850. */
  77851. onAfterRenderObservable: Observable<number>;
  77852. private _onAfterRenderObserver;
  77853. /**
  77854. * Set a after render callback in the texture.
  77855. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77856. */
  77857. onAfterRender: (faceIndex: number) => void;
  77858. /**
  77859. * An event triggered after the texture clear
  77860. */
  77861. onClearObservable: Observable<Engine>;
  77862. private _onClearObserver;
  77863. /**
  77864. * Set a clear callback in the texture.
  77865. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77866. */
  77867. onClear: (Engine: Engine) => void;
  77868. /**
  77869. * Define the clear color of the Render Target if it should be different from the scene.
  77870. */
  77871. clearColor: Color4;
  77872. protected _size: number | {
  77873. width: number;
  77874. height: number;
  77875. };
  77876. protected _initialSizeParameter: number | {
  77877. width: number;
  77878. height: number;
  77879. } | {
  77880. ratio: number;
  77881. };
  77882. protected _sizeRatio: Nullable<number>;
  77883. /** @hidden */
  77884. _generateMipMaps: boolean;
  77885. protected _renderingManager: RenderingManager;
  77886. /** @hidden */
  77887. _waitingRenderList: string[];
  77888. protected _doNotChangeAspectRatio: boolean;
  77889. protected _currentRefreshId: number;
  77890. protected _refreshRate: number;
  77891. protected _textureMatrix: Matrix;
  77892. protected _samples: number;
  77893. protected _renderTargetOptions: RenderTargetCreationOptions;
  77894. /**
  77895. * Gets render target creation options that were used.
  77896. */
  77897. readonly renderTargetOptions: RenderTargetCreationOptions;
  77898. protected _engine: Engine;
  77899. protected _onRatioRescale(): void;
  77900. /**
  77901. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77902. * It must define where the camera used to render the texture is set
  77903. */
  77904. boundingBoxPosition: Vector3;
  77905. private _boundingBoxSize;
  77906. /**
  77907. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77908. * When defined, the cubemap will switch to local mode
  77909. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77910. * @example https://www.babylonjs-playground.com/#RNASML
  77911. */
  77912. boundingBoxSize: Vector3;
  77913. /**
  77914. * In case the RTT has been created with a depth texture, get the associated
  77915. * depth texture.
  77916. * Otherwise, return null.
  77917. */
  77918. depthStencilTexture: Nullable<InternalTexture>;
  77919. /**
  77920. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77921. * or used a shadow, depth texture...
  77922. * @param name The friendly name of the texture
  77923. * @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)
  77924. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77925. * @param generateMipMaps True if mip maps need to be generated after render.
  77926. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77927. * @param type The type of the buffer in the RTT (int, half float, float...)
  77928. * @param isCube True if a cube texture needs to be created
  77929. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77930. * @param generateDepthBuffer True to generate a depth buffer
  77931. * @param generateStencilBuffer True to generate a stencil buffer
  77932. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77933. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77934. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77935. */
  77936. constructor(name: string, size: number | {
  77937. width: number;
  77938. height: number;
  77939. } | {
  77940. ratio: number;
  77941. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77942. /**
  77943. * Creates a depth stencil texture.
  77944. * This is only available in WebGL 2 or with the depth texture extension available.
  77945. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77946. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77947. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77948. */
  77949. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77950. private _processSizeParameter;
  77951. /**
  77952. * Define the number of samples to use in case of MSAA.
  77953. * It defaults to one meaning no MSAA has been enabled.
  77954. */
  77955. samples: number;
  77956. /**
  77957. * Resets the refresh counter of the texture and start bak from scratch.
  77958. * Could be useful to regenerate the texture if it is setup to render only once.
  77959. */
  77960. resetRefreshCounter(): void;
  77961. /**
  77962. * Define the refresh rate of the texture or the rendering frequency.
  77963. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77964. */
  77965. refreshRate: number;
  77966. /**
  77967. * Adds a post process to the render target rendering passes.
  77968. * @param postProcess define the post process to add
  77969. */
  77970. addPostProcess(postProcess: PostProcess): void;
  77971. /**
  77972. * Clear all the post processes attached to the render target
  77973. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77974. */
  77975. clearPostProcesses(dispose?: boolean): void;
  77976. /**
  77977. * Remove one of the post process from the list of attached post processes to the texture
  77978. * @param postProcess define the post process to remove from the list
  77979. */
  77980. removePostProcess(postProcess: PostProcess): void;
  77981. /** @hidden */
  77982. _shouldRender(): boolean;
  77983. /**
  77984. * Gets the actual render size of the texture.
  77985. * @returns the width of the render size
  77986. */
  77987. getRenderSize(): number;
  77988. /**
  77989. * Gets the actual render width of the texture.
  77990. * @returns the width of the render size
  77991. */
  77992. getRenderWidth(): number;
  77993. /**
  77994. * Gets the actual render height of the texture.
  77995. * @returns the height of the render size
  77996. */
  77997. getRenderHeight(): number;
  77998. /**
  77999. * Get if the texture can be rescaled or not.
  78000. */
  78001. readonly canRescale: boolean;
  78002. /**
  78003. * Resize the texture using a ratio.
  78004. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  78005. */
  78006. scale(ratio: number): void;
  78007. /**
  78008. * Get the texture reflection matrix used to rotate/transform the reflection.
  78009. * @returns the reflection matrix
  78010. */
  78011. getReflectionTextureMatrix(): Matrix;
  78012. /**
  78013. * Resize the texture to a new desired size.
  78014. * Be carrefull as it will recreate all the data in the new texture.
  78015. * @param size Define the new size. It can be:
  78016. * - a number for squared texture,
  78017. * - an object containing { width: number, height: number }
  78018. * - or an object containing a ratio { ratio: number }
  78019. */
  78020. resize(size: number | {
  78021. width: number;
  78022. height: number;
  78023. } | {
  78024. ratio: number;
  78025. }): void;
  78026. /**
  78027. * Renders all the objects from the render list into the texture.
  78028. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  78029. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  78030. */
  78031. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  78032. private _bestReflectionRenderTargetDimension;
  78033. /**
  78034. * @hidden
  78035. * @param faceIndex face index to bind to if this is a cubetexture
  78036. */
  78037. _bindFrameBuffer(faceIndex?: number): void;
  78038. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  78039. private renderToTarget;
  78040. /**
  78041. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  78042. * This allowed control for front to back rendering or reversly depending of the special needs.
  78043. *
  78044. * @param renderingGroupId The rendering group id corresponding to its index
  78045. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  78046. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  78047. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  78048. */
  78049. 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;
  78050. /**
  78051. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  78052. *
  78053. * @param renderingGroupId The rendering group id corresponding to its index
  78054. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  78055. */
  78056. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  78057. /**
  78058. * Clones the texture.
  78059. * @returns the cloned texture
  78060. */
  78061. clone(): RenderTargetTexture;
  78062. /**
  78063. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78064. * @returns The JSON representation of the texture
  78065. */
  78066. serialize(): any;
  78067. /**
  78068. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  78069. */
  78070. disposeFramebufferObjects(): void;
  78071. /**
  78072. * Dispose the texture and release its associated resources.
  78073. */
  78074. dispose(): void;
  78075. /** @hidden */
  78076. _rebuild(): void;
  78077. /**
  78078. * Clear the info related to rendering groups preventing retention point in material dispose.
  78079. */
  78080. freeRenderingGroups(): void;
  78081. /**
  78082. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78083. * @returns the view count
  78084. */
  78085. getViewCount(): number;
  78086. }
  78087. }
  78088. declare module BABYLON {
  78089. /**
  78090. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78091. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78092. * You can then easily use it as a reflectionTexture on a flat surface.
  78093. * In case the surface is not a plane, please consider relying on reflection probes.
  78094. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78095. */
  78096. export class MirrorTexture extends RenderTargetTexture {
  78097. private scene;
  78098. /**
  78099. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78100. * 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.
  78101. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78102. */
  78103. mirrorPlane: Plane;
  78104. /**
  78105. * Define the blur ratio used to blur the reflection if needed.
  78106. */
  78107. blurRatio: number;
  78108. /**
  78109. * Define the adaptive blur kernel used to blur the reflection if needed.
  78110. * This will autocompute the closest best match for the `blurKernel`
  78111. */
  78112. adaptiveBlurKernel: number;
  78113. /**
  78114. * Define the blur kernel used to blur the reflection if needed.
  78115. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78116. */
  78117. blurKernel: number;
  78118. /**
  78119. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78120. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78121. */
  78122. blurKernelX: number;
  78123. /**
  78124. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78125. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78126. */
  78127. blurKernelY: number;
  78128. private _autoComputeBlurKernel;
  78129. protected _onRatioRescale(): void;
  78130. private _updateGammaSpace;
  78131. private _imageProcessingConfigChangeObserver;
  78132. private _transformMatrix;
  78133. private _mirrorMatrix;
  78134. private _savedViewMatrix;
  78135. private _blurX;
  78136. private _blurY;
  78137. private _adaptiveBlurKernel;
  78138. private _blurKernelX;
  78139. private _blurKernelY;
  78140. private _blurRatio;
  78141. /**
  78142. * Instantiates a Mirror Texture.
  78143. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78144. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78145. * You can then easily use it as a reflectionTexture on a flat surface.
  78146. * In case the surface is not a plane, please consider relying on reflection probes.
  78147. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78148. * @param name
  78149. * @param size
  78150. * @param scene
  78151. * @param generateMipMaps
  78152. * @param type
  78153. * @param samplingMode
  78154. * @param generateDepthBuffer
  78155. */
  78156. constructor(name: string, size: number | {
  78157. width: number;
  78158. height: number;
  78159. } | {
  78160. ratio: number;
  78161. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78162. private _preparePostProcesses;
  78163. /**
  78164. * Clone the mirror texture.
  78165. * @returns the cloned texture
  78166. */
  78167. clone(): MirrorTexture;
  78168. /**
  78169. * Serialize the texture to a JSON representation you could use in Parse later on
  78170. * @returns the serialized JSON representation
  78171. */
  78172. serialize(): any;
  78173. /**
  78174. * Dispose the texture and release its associated resources.
  78175. */
  78176. dispose(): void;
  78177. }
  78178. }
  78179. declare module BABYLON {
  78180. /**
  78181. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78182. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78183. */
  78184. export class Texture extends BaseTexture {
  78185. /** @hidden */
  78186. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78187. /** @hidden */
  78188. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78189. /** @hidden */
  78190. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78191. /** nearest is mag = nearest and min = nearest and mip = linear */
  78192. static readonly NEAREST_SAMPLINGMODE: number;
  78193. /** nearest is mag = nearest and min = nearest and mip = linear */
  78194. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78196. static readonly BILINEAR_SAMPLINGMODE: number;
  78197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78198. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78199. /** Trilinear is mag = linear and min = linear and mip = linear */
  78200. static readonly TRILINEAR_SAMPLINGMODE: number;
  78201. /** Trilinear is mag = linear and min = linear and mip = linear */
  78202. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78203. /** mag = nearest and min = nearest and mip = nearest */
  78204. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78205. /** mag = nearest and min = linear and mip = nearest */
  78206. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78207. /** mag = nearest and min = linear and mip = linear */
  78208. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78209. /** mag = nearest and min = linear and mip = none */
  78210. static readonly NEAREST_LINEAR: number;
  78211. /** mag = nearest and min = nearest and mip = none */
  78212. static readonly NEAREST_NEAREST: number;
  78213. /** mag = linear and min = nearest and mip = nearest */
  78214. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78215. /** mag = linear and min = nearest and mip = linear */
  78216. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78217. /** mag = linear and min = linear and mip = none */
  78218. static readonly LINEAR_LINEAR: number;
  78219. /** mag = linear and min = nearest and mip = none */
  78220. static readonly LINEAR_NEAREST: number;
  78221. /** Explicit coordinates mode */
  78222. static readonly EXPLICIT_MODE: number;
  78223. /** Spherical coordinates mode */
  78224. static readonly SPHERICAL_MODE: number;
  78225. /** Planar coordinates mode */
  78226. static readonly PLANAR_MODE: number;
  78227. /** Cubic coordinates mode */
  78228. static readonly CUBIC_MODE: number;
  78229. /** Projection coordinates mode */
  78230. static readonly PROJECTION_MODE: number;
  78231. /** Inverse Cubic coordinates mode */
  78232. static readonly SKYBOX_MODE: number;
  78233. /** Inverse Cubic coordinates mode */
  78234. static readonly INVCUBIC_MODE: number;
  78235. /** Equirectangular coordinates mode */
  78236. static readonly EQUIRECTANGULAR_MODE: number;
  78237. /** Equirectangular Fixed coordinates mode */
  78238. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78239. /** Equirectangular Fixed Mirrored coordinates mode */
  78240. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78241. /** Texture is not repeating outside of 0..1 UVs */
  78242. static readonly CLAMP_ADDRESSMODE: number;
  78243. /** Texture is repeating outside of 0..1 UVs */
  78244. static readonly WRAP_ADDRESSMODE: number;
  78245. /** Texture is repeating and mirrored */
  78246. static readonly MIRROR_ADDRESSMODE: number;
  78247. /**
  78248. * 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
  78249. */
  78250. static UseSerializedUrlIfAny: boolean;
  78251. /**
  78252. * Define the url of the texture.
  78253. */
  78254. url: Nullable<string>;
  78255. /**
  78256. * Define an offset on the texture to offset the u coordinates of the UVs
  78257. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78258. */
  78259. uOffset: number;
  78260. /**
  78261. * Define an offset on the texture to offset the v coordinates of the UVs
  78262. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78263. */
  78264. vOffset: number;
  78265. /**
  78266. * Define an offset on the texture to scale the u coordinates of the UVs
  78267. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78268. */
  78269. uScale: number;
  78270. /**
  78271. * Define an offset on the texture to scale the v coordinates of the UVs
  78272. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78273. */
  78274. vScale: number;
  78275. /**
  78276. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78277. * @see http://doc.babylonjs.com/how_to/more_materials
  78278. */
  78279. uAng: number;
  78280. /**
  78281. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78282. * @see http://doc.babylonjs.com/how_to/more_materials
  78283. */
  78284. vAng: number;
  78285. /**
  78286. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78287. * @see http://doc.babylonjs.com/how_to/more_materials
  78288. */
  78289. wAng: number;
  78290. /**
  78291. * Defines the center of rotation (U)
  78292. */
  78293. uRotationCenter: number;
  78294. /**
  78295. * Defines the center of rotation (V)
  78296. */
  78297. vRotationCenter: number;
  78298. /**
  78299. * Defines the center of rotation (W)
  78300. */
  78301. wRotationCenter: number;
  78302. /**
  78303. * Are mip maps generated for this texture or not.
  78304. */
  78305. readonly noMipmap: boolean;
  78306. /**
  78307. * List of inspectable custom properties (used by the Inspector)
  78308. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78309. */
  78310. inspectableCustomProperties: Nullable<IInspectable[]>;
  78311. private _noMipmap;
  78312. /** @hidden */
  78313. _invertY: boolean;
  78314. private _rowGenerationMatrix;
  78315. private _cachedTextureMatrix;
  78316. private _projectionModeMatrix;
  78317. private _t0;
  78318. private _t1;
  78319. private _t2;
  78320. private _cachedUOffset;
  78321. private _cachedVOffset;
  78322. private _cachedUScale;
  78323. private _cachedVScale;
  78324. private _cachedUAng;
  78325. private _cachedVAng;
  78326. private _cachedWAng;
  78327. private _cachedProjectionMatrixId;
  78328. private _cachedCoordinatesMode;
  78329. /** @hidden */
  78330. protected _initialSamplingMode: number;
  78331. /** @hidden */
  78332. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78333. private _deleteBuffer;
  78334. protected _format: Nullable<number>;
  78335. private _delayedOnLoad;
  78336. private _delayedOnError;
  78337. /**
  78338. * Observable triggered once the texture has been loaded.
  78339. */
  78340. onLoadObservable: Observable<Texture>;
  78341. protected _isBlocking: boolean;
  78342. /**
  78343. * Is the texture preventing material to render while loading.
  78344. * If false, a default texture will be used instead of the loading one during the preparation step.
  78345. */
  78346. isBlocking: boolean;
  78347. /**
  78348. * Get the current sampling mode associated with the texture.
  78349. */
  78350. readonly samplingMode: number;
  78351. /**
  78352. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78353. */
  78354. readonly invertY: boolean;
  78355. /**
  78356. * Instantiates a new texture.
  78357. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78358. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78359. * @param url define the url of the picture to load as a texture
  78360. * @param scene define the scene the texture will belong to
  78361. * @param noMipmap define if the texture will require mip maps or not
  78362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78364. * @param onLoad define a callback triggered when the texture has been loaded
  78365. * @param onError define a callback triggered when an error occurred during the loading session
  78366. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78367. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78368. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78369. */
  78370. 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);
  78371. /**
  78372. * Update the url (and optional buffer) of this texture if url was null during construction.
  78373. * @param url the url of the texture
  78374. * @param buffer the buffer of the texture (defaults to null)
  78375. * @param onLoad callback called when the texture is loaded (defaults to null)
  78376. */
  78377. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78378. /**
  78379. * Finish the loading sequence of a texture flagged as delayed load.
  78380. * @hidden
  78381. */
  78382. delayLoad(): void;
  78383. private _prepareRowForTextureGeneration;
  78384. /**
  78385. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78386. * @returns the transform matrix of the texture.
  78387. */
  78388. getTextureMatrix(): Matrix;
  78389. /**
  78390. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78391. * @returns The reflection texture transform
  78392. */
  78393. getReflectionTextureMatrix(): Matrix;
  78394. /**
  78395. * Clones the texture.
  78396. * @returns the cloned texture
  78397. */
  78398. clone(): Texture;
  78399. /**
  78400. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78401. * @returns The JSON representation of the texture
  78402. */
  78403. serialize(): any;
  78404. /**
  78405. * Get the current class name of the texture useful for serialization or dynamic coding.
  78406. * @returns "Texture"
  78407. */
  78408. getClassName(): string;
  78409. /**
  78410. * Dispose the texture and release its associated resources.
  78411. */
  78412. dispose(): void;
  78413. /**
  78414. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78415. * @param parsedTexture Define the JSON representation of the texture
  78416. * @param scene Define the scene the parsed texture should be instantiated in
  78417. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78418. * @returns The parsed texture if successful
  78419. */
  78420. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78421. /**
  78422. * Creates a texture from its base 64 representation.
  78423. * @param data Define the base64 payload without the data: prefix
  78424. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78425. * @param scene Define the scene the texture should belong to
  78426. * @param noMipmap Forces the texture to not create mip map information if true
  78427. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78428. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78429. * @param onLoad define a callback triggered when the texture has been loaded
  78430. * @param onError define a callback triggered when an error occurred during the loading session
  78431. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78432. * @returns the created texture
  78433. */
  78434. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78435. /**
  78436. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78437. * @param data Define the base64 payload without the data: prefix
  78438. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78439. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78440. * @param scene Define the scene the texture should belong to
  78441. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78442. * @param noMipmap Forces the texture to not create mip map information if true
  78443. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78444. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78445. * @param onLoad define a callback triggered when the texture has been loaded
  78446. * @param onError define a callback triggered when an error occurred during the loading session
  78447. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78448. * @returns the created texture
  78449. */
  78450. 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;
  78451. }
  78452. }
  78453. declare module BABYLON {
  78454. interface Engine {
  78455. /**
  78456. * Creates a raw texture
  78457. * @param data defines the data to store in the texture
  78458. * @param width defines the width of the texture
  78459. * @param height defines the height of the texture
  78460. * @param format defines the format of the data
  78461. * @param generateMipMaps defines if the engine should generate the mip levels
  78462. * @param invertY defines if data must be stored with Y axis inverted
  78463. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78464. * @param compression defines the compression used (null by default)
  78465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78466. * @returns the raw texture inside an InternalTexture
  78467. */
  78468. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78469. /**
  78470. * Update a raw texture
  78471. * @param texture defines the texture to update
  78472. * @param data defines the data to store in the texture
  78473. * @param format defines the format of the data
  78474. * @param invertY defines if data must be stored with Y axis inverted
  78475. */
  78476. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78477. /**
  78478. * Update a raw texture
  78479. * @param texture defines the texture to update
  78480. * @param data defines the data to store in the texture
  78481. * @param format defines the format of the data
  78482. * @param invertY defines if data must be stored with Y axis inverted
  78483. * @param compression defines the compression used (null by default)
  78484. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78485. */
  78486. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78487. /**
  78488. * Creates a new raw cube texture
  78489. * @param data defines the array of data to use to create each face
  78490. * @param size defines the size of the textures
  78491. * @param format defines the format of the data
  78492. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78493. * @param generateMipMaps defines if the engine should generate the mip levels
  78494. * @param invertY defines if data must be stored with Y axis inverted
  78495. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78496. * @param compression defines the compression used (null by default)
  78497. * @returns the cube texture as an InternalTexture
  78498. */
  78499. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78500. /**
  78501. * Update a raw cube texture
  78502. * @param texture defines the texture to udpdate
  78503. * @param data defines the data to store
  78504. * @param format defines the data format
  78505. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78506. * @param invertY defines if data must be stored with Y axis inverted
  78507. */
  78508. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78509. /**
  78510. * Update a raw cube texture
  78511. * @param texture defines the texture to udpdate
  78512. * @param data defines the data to store
  78513. * @param format defines the data format
  78514. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78515. * @param invertY defines if data must be stored with Y axis inverted
  78516. * @param compression defines the compression used (null by default)
  78517. */
  78518. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78519. /**
  78520. * Update a raw cube texture
  78521. * @param texture defines the texture to udpdate
  78522. * @param data defines the data to store
  78523. * @param format defines the data format
  78524. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78525. * @param invertY defines if data must be stored with Y axis inverted
  78526. * @param compression defines the compression used (null by default)
  78527. * @param level defines which level of the texture to update
  78528. */
  78529. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78530. /**
  78531. * Creates a new raw cube texture from a specified url
  78532. * @param url defines the url where the data is located
  78533. * @param scene defines the current scene
  78534. * @param size defines the size of the textures
  78535. * @param format defines the format of the data
  78536. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78537. * @param noMipmap defines if the engine should avoid generating the mip levels
  78538. * @param callback defines a callback used to extract texture data from loaded data
  78539. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78540. * @param onLoad defines a callback called when texture is loaded
  78541. * @param onError defines a callback called if there is an error
  78542. * @returns the cube texture as an InternalTexture
  78543. */
  78544. 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;
  78545. /**
  78546. * Creates a new raw cube texture from a specified url
  78547. * @param url defines the url where the data is located
  78548. * @param scene defines the current scene
  78549. * @param size defines the size of the textures
  78550. * @param format defines the format of the data
  78551. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78552. * @param noMipmap defines if the engine should avoid generating the mip levels
  78553. * @param callback defines a callback used to extract texture data from loaded data
  78554. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78555. * @param onLoad defines a callback called when texture is loaded
  78556. * @param onError defines a callback called if there is an error
  78557. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78558. * @param invertY defines if data must be stored with Y axis inverted
  78559. * @returns the cube texture as an InternalTexture
  78560. */
  78561. 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;
  78562. /**
  78563. * Creates a new raw 3D texture
  78564. * @param data defines the data used to create the texture
  78565. * @param width defines the width of the texture
  78566. * @param height defines the height of the texture
  78567. * @param depth defines the depth of the texture
  78568. * @param format defines the format of the texture
  78569. * @param generateMipMaps defines if the engine must generate mip levels
  78570. * @param invertY defines if data must be stored with Y axis inverted
  78571. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78572. * @param compression defines the compressed used (can be null)
  78573. * @param textureType defines the compressed used (can be null)
  78574. * @returns a new raw 3D texture (stored in an InternalTexture)
  78575. */
  78576. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78577. /**
  78578. * Update a raw 3D texture
  78579. * @param texture defines the texture to update
  78580. * @param data defines the data to store
  78581. * @param format defines the data format
  78582. * @param invertY defines if data must be stored with Y axis inverted
  78583. */
  78584. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78585. /**
  78586. * Update a raw 3D texture
  78587. * @param texture defines the texture to update
  78588. * @param data defines the data to store
  78589. * @param format defines the data format
  78590. * @param invertY defines if data must be stored with Y axis inverted
  78591. * @param compression defines the used compression (can be null)
  78592. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78593. */
  78594. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78595. }
  78596. }
  78597. declare module BABYLON {
  78598. /**
  78599. * Raw texture can help creating a texture directly from an array of data.
  78600. * This can be super useful if you either get the data from an uncompressed source or
  78601. * if you wish to create your texture pixel by pixel.
  78602. */
  78603. export class RawTexture extends Texture {
  78604. /**
  78605. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78606. */
  78607. format: number;
  78608. private _engine;
  78609. /**
  78610. * Instantiates a new RawTexture.
  78611. * Raw texture can help creating a texture directly from an array of data.
  78612. * This can be super useful if you either get the data from an uncompressed source or
  78613. * if you wish to create your texture pixel by pixel.
  78614. * @param data define the array of data to use to create the texture
  78615. * @param width define the width of the texture
  78616. * @param height define the height of the texture
  78617. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78618. * @param scene define the scene the texture belongs to
  78619. * @param generateMipMaps define whether mip maps should be generated or not
  78620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78622. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78623. */
  78624. constructor(data: ArrayBufferView, width: number, height: number,
  78625. /**
  78626. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78627. */
  78628. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78629. /**
  78630. * Updates the texture underlying data.
  78631. * @param data Define the new data of the texture
  78632. */
  78633. update(data: ArrayBufferView): void;
  78634. /**
  78635. * Creates a luminance texture from some data.
  78636. * @param data Define the texture data
  78637. * @param width Define the width of the texture
  78638. * @param height Define the height of the texture
  78639. * @param scene Define the scene the texture belongs to
  78640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78643. * @returns the luminance texture
  78644. */
  78645. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78646. /**
  78647. * Creates a luminance alpha texture from some data.
  78648. * @param data Define the texture data
  78649. * @param width Define the width of the texture
  78650. * @param height Define the height of the texture
  78651. * @param scene Define the scene the texture belongs to
  78652. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78655. * @returns the luminance alpha texture
  78656. */
  78657. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78658. /**
  78659. * Creates an alpha texture from some data.
  78660. * @param data Define the texture data
  78661. * @param width Define the width of the texture
  78662. * @param height Define the height of the texture
  78663. * @param scene Define the scene the texture belongs to
  78664. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78665. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78666. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78667. * @returns the alpha texture
  78668. */
  78669. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78670. /**
  78671. * Creates a RGB texture from some data.
  78672. * @param data Define the texture data
  78673. * @param width Define the width of the texture
  78674. * @param height Define the height of the texture
  78675. * @param scene Define the scene the texture belongs to
  78676. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78677. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78678. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78679. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78680. * @returns the RGB alpha texture
  78681. */
  78682. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78683. /**
  78684. * Creates a RGBA texture from some data.
  78685. * @param data Define the texture data
  78686. * @param width Define the width of the texture
  78687. * @param height Define the height of the texture
  78688. * @param scene Define the scene the texture belongs to
  78689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78692. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78693. * @returns the RGBA texture
  78694. */
  78695. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78696. /**
  78697. * Creates a R texture from some data.
  78698. * @param data Define the texture data
  78699. * @param width Define the width of the texture
  78700. * @param height Define the height of the texture
  78701. * @param scene Define the scene the texture belongs to
  78702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78705. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78706. * @returns the R texture
  78707. */
  78708. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78709. }
  78710. }
  78711. declare module BABYLON {
  78712. /**
  78713. * Defines a runtime animation
  78714. */
  78715. export class RuntimeAnimation {
  78716. private _events;
  78717. /**
  78718. * The current frame of the runtime animation
  78719. */
  78720. private _currentFrame;
  78721. /**
  78722. * The animation used by the runtime animation
  78723. */
  78724. private _animation;
  78725. /**
  78726. * The target of the runtime animation
  78727. */
  78728. private _target;
  78729. /**
  78730. * The initiating animatable
  78731. */
  78732. private _host;
  78733. /**
  78734. * The original value of the runtime animation
  78735. */
  78736. private _originalValue;
  78737. /**
  78738. * The original blend value of the runtime animation
  78739. */
  78740. private _originalBlendValue;
  78741. /**
  78742. * The offsets cache of the runtime animation
  78743. */
  78744. private _offsetsCache;
  78745. /**
  78746. * The high limits cache of the runtime animation
  78747. */
  78748. private _highLimitsCache;
  78749. /**
  78750. * Specifies if the runtime animation has been stopped
  78751. */
  78752. private _stopped;
  78753. /**
  78754. * The blending factor of the runtime animation
  78755. */
  78756. private _blendingFactor;
  78757. /**
  78758. * The BabylonJS scene
  78759. */
  78760. private _scene;
  78761. /**
  78762. * The current value of the runtime animation
  78763. */
  78764. private _currentValue;
  78765. /** @hidden */
  78766. _animationState: _IAnimationState;
  78767. /**
  78768. * The active target of the runtime animation
  78769. */
  78770. private _activeTargets;
  78771. private _currentActiveTarget;
  78772. private _directTarget;
  78773. /**
  78774. * The target path of the runtime animation
  78775. */
  78776. private _targetPath;
  78777. /**
  78778. * The weight of the runtime animation
  78779. */
  78780. private _weight;
  78781. /**
  78782. * The ratio offset of the runtime animation
  78783. */
  78784. private _ratioOffset;
  78785. /**
  78786. * The previous delay of the runtime animation
  78787. */
  78788. private _previousDelay;
  78789. /**
  78790. * The previous ratio of the runtime animation
  78791. */
  78792. private _previousRatio;
  78793. private _enableBlending;
  78794. private _keys;
  78795. private _minFrame;
  78796. private _maxFrame;
  78797. private _minValue;
  78798. private _maxValue;
  78799. private _targetIsArray;
  78800. /**
  78801. * Gets the current frame of the runtime animation
  78802. */
  78803. readonly currentFrame: number;
  78804. /**
  78805. * Gets the weight of the runtime animation
  78806. */
  78807. readonly weight: number;
  78808. /**
  78809. * Gets the current value of the runtime animation
  78810. */
  78811. readonly currentValue: any;
  78812. /**
  78813. * Gets the target path of the runtime animation
  78814. */
  78815. readonly targetPath: string;
  78816. /**
  78817. * Gets the actual target of the runtime animation
  78818. */
  78819. readonly target: any;
  78820. /** @hidden */
  78821. _onLoop: () => void;
  78822. /**
  78823. * Create a new RuntimeAnimation object
  78824. * @param target defines the target of the animation
  78825. * @param animation defines the source animation object
  78826. * @param scene defines the hosting scene
  78827. * @param host defines the initiating Animatable
  78828. */
  78829. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78830. private _preparePath;
  78831. /**
  78832. * Gets the animation from the runtime animation
  78833. */
  78834. readonly animation: Animation;
  78835. /**
  78836. * Resets the runtime animation to the beginning
  78837. * @param restoreOriginal defines whether to restore the target property to the original value
  78838. */
  78839. reset(restoreOriginal?: boolean): void;
  78840. /**
  78841. * Specifies if the runtime animation is stopped
  78842. * @returns Boolean specifying if the runtime animation is stopped
  78843. */
  78844. isStopped(): boolean;
  78845. /**
  78846. * Disposes of the runtime animation
  78847. */
  78848. dispose(): void;
  78849. /**
  78850. * Apply the interpolated value to the target
  78851. * @param currentValue defines the value computed by the animation
  78852. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78853. */
  78854. setValue(currentValue: any, weight: number): void;
  78855. private _getOriginalValues;
  78856. private _setValue;
  78857. /**
  78858. * Gets the loop pmode of the runtime animation
  78859. * @returns Loop Mode
  78860. */
  78861. private _getCorrectLoopMode;
  78862. /**
  78863. * Move the current animation to a given frame
  78864. * @param frame defines the frame to move to
  78865. */
  78866. goToFrame(frame: number): void;
  78867. /**
  78868. * @hidden Internal use only
  78869. */
  78870. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78871. /**
  78872. * Execute the current animation
  78873. * @param delay defines the delay to add to the current frame
  78874. * @param from defines the lower bound of the animation range
  78875. * @param to defines the upper bound of the animation range
  78876. * @param loop defines if the current animation must loop
  78877. * @param speedRatio defines the current speed ratio
  78878. * @param weight defines the weight of the animation (default is -1 so no weight)
  78879. * @param onLoop optional callback called when animation loops
  78880. * @returns a boolean indicating if the animation is running
  78881. */
  78882. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78883. }
  78884. }
  78885. declare module BABYLON {
  78886. /**
  78887. * Class used to store an actual running animation
  78888. */
  78889. export class Animatable {
  78890. /** defines the target object */
  78891. target: any;
  78892. /** defines the starting frame number (default is 0) */
  78893. fromFrame: number;
  78894. /** defines the ending frame number (default is 100) */
  78895. toFrame: number;
  78896. /** defines if the animation must loop (default is false) */
  78897. loopAnimation: boolean;
  78898. /** defines a callback to call when animation ends if it is not looping */
  78899. onAnimationEnd?: (() => void) | null | undefined;
  78900. /** defines a callback to call when animation loops */
  78901. onAnimationLoop?: (() => void) | null | undefined;
  78902. private _localDelayOffset;
  78903. private _pausedDelay;
  78904. private _runtimeAnimations;
  78905. private _paused;
  78906. private _scene;
  78907. private _speedRatio;
  78908. private _weight;
  78909. private _syncRoot;
  78910. /**
  78911. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78912. * This will only apply for non looping animation (default is true)
  78913. */
  78914. disposeOnEnd: boolean;
  78915. /**
  78916. * Gets a boolean indicating if the animation has started
  78917. */
  78918. animationStarted: boolean;
  78919. /**
  78920. * Observer raised when the animation ends
  78921. */
  78922. onAnimationEndObservable: Observable<Animatable>;
  78923. /**
  78924. * Observer raised when the animation loops
  78925. */
  78926. onAnimationLoopObservable: Observable<Animatable>;
  78927. /**
  78928. * Gets the root Animatable used to synchronize and normalize animations
  78929. */
  78930. readonly syncRoot: Nullable<Animatable>;
  78931. /**
  78932. * Gets the current frame of the first RuntimeAnimation
  78933. * Used to synchronize Animatables
  78934. */
  78935. readonly masterFrame: number;
  78936. /**
  78937. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78938. */
  78939. weight: number;
  78940. /**
  78941. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78942. */
  78943. speedRatio: number;
  78944. /**
  78945. * Creates a new Animatable
  78946. * @param scene defines the hosting scene
  78947. * @param target defines the target object
  78948. * @param fromFrame defines the starting frame number (default is 0)
  78949. * @param toFrame defines the ending frame number (default is 100)
  78950. * @param loopAnimation defines if the animation must loop (default is false)
  78951. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78952. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78953. * @param animations defines a group of animation to add to the new Animatable
  78954. * @param onAnimationLoop defines a callback to call when animation loops
  78955. */
  78956. constructor(scene: Scene,
  78957. /** defines the target object */
  78958. target: any,
  78959. /** defines the starting frame number (default is 0) */
  78960. fromFrame?: number,
  78961. /** defines the ending frame number (default is 100) */
  78962. toFrame?: number,
  78963. /** defines if the animation must loop (default is false) */
  78964. loopAnimation?: boolean, speedRatio?: number,
  78965. /** defines a callback to call when animation ends if it is not looping */
  78966. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78967. /** defines a callback to call when animation loops */
  78968. onAnimationLoop?: (() => void) | null | undefined);
  78969. /**
  78970. * Synchronize and normalize current Animatable with a source Animatable
  78971. * This is useful when using animation weights and when animations are not of the same length
  78972. * @param root defines the root Animatable to synchronize with
  78973. * @returns the current Animatable
  78974. */
  78975. syncWith(root: Animatable): Animatable;
  78976. /**
  78977. * Gets the list of runtime animations
  78978. * @returns an array of RuntimeAnimation
  78979. */
  78980. getAnimations(): RuntimeAnimation[];
  78981. /**
  78982. * Adds more animations to the current animatable
  78983. * @param target defines the target of the animations
  78984. * @param animations defines the new animations to add
  78985. */
  78986. appendAnimations(target: any, animations: Animation[]): void;
  78987. /**
  78988. * Gets the source animation for a specific property
  78989. * @param property defines the propertyu to look for
  78990. * @returns null or the source animation for the given property
  78991. */
  78992. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78993. /**
  78994. * Gets the runtime animation for a specific property
  78995. * @param property defines the propertyu to look for
  78996. * @returns null or the runtime animation for the given property
  78997. */
  78998. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78999. /**
  79000. * Resets the animatable to its original state
  79001. */
  79002. reset(): void;
  79003. /**
  79004. * Allows the animatable to blend with current running animations
  79005. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79006. * @param blendingSpeed defines the blending speed to use
  79007. */
  79008. enableBlending(blendingSpeed: number): void;
  79009. /**
  79010. * Disable animation blending
  79011. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79012. */
  79013. disableBlending(): void;
  79014. /**
  79015. * Jump directly to a given frame
  79016. * @param frame defines the frame to jump to
  79017. */
  79018. goToFrame(frame: number): void;
  79019. /**
  79020. * Pause the animation
  79021. */
  79022. pause(): void;
  79023. /**
  79024. * Restart the animation
  79025. */
  79026. restart(): void;
  79027. private _raiseOnAnimationEnd;
  79028. /**
  79029. * Stop and delete the current animation
  79030. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79031. * @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)
  79032. */
  79033. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79034. /**
  79035. * Wait asynchronously for the animation to end
  79036. * @returns a promise which will be fullfilled when the animation ends
  79037. */
  79038. waitAsync(): Promise<Animatable>;
  79039. /** @hidden */
  79040. _animate(delay: number): boolean;
  79041. }
  79042. interface Scene {
  79043. /** @hidden */
  79044. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79045. /** @hidden */
  79046. _processLateAnimationBindingsForMatrices(holder: {
  79047. totalWeight: number;
  79048. animations: RuntimeAnimation[];
  79049. originalValue: Matrix;
  79050. }): any;
  79051. /** @hidden */
  79052. _processLateAnimationBindingsForQuaternions(holder: {
  79053. totalWeight: number;
  79054. animations: RuntimeAnimation[];
  79055. originalValue: Quaternion;
  79056. }, refQuaternion: Quaternion): Quaternion;
  79057. /** @hidden */
  79058. _processLateAnimationBindings(): void;
  79059. /**
  79060. * Will start the animation sequence of a given target
  79061. * @param target defines the target
  79062. * @param from defines from which frame should animation start
  79063. * @param to defines until which frame should animation run.
  79064. * @param weight defines the weight to apply to the animation (1.0 by default)
  79065. * @param loop defines if the animation loops
  79066. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79067. * @param onAnimationEnd defines the function to be executed when the animation ends
  79068. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79069. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79070. * @param onAnimationLoop defines the callback to call when an animation loops
  79071. * @returns the animatable object created for this animation
  79072. */
  79073. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79074. /**
  79075. * Will start the animation sequence of a given target
  79076. * @param target defines the target
  79077. * @param from defines from which frame should animation start
  79078. * @param to defines until which frame should animation run.
  79079. * @param loop defines if the animation loops
  79080. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79081. * @param onAnimationEnd defines the function to be executed when the animation ends
  79082. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79083. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79084. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79085. * @param onAnimationLoop defines the callback to call when an animation loops
  79086. * @returns the animatable object created for this animation
  79087. */
  79088. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79089. /**
  79090. * Will start the animation sequence of a given target and its hierarchy
  79091. * @param target defines the target
  79092. * @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.
  79093. * @param from defines from which frame should animation start
  79094. * @param to defines until which frame should animation run.
  79095. * @param loop defines if the animation loops
  79096. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79097. * @param onAnimationEnd defines the function to be executed when the animation ends
  79098. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79099. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79100. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79101. * @param onAnimationLoop defines the callback to call when an animation loops
  79102. * @returns the list of created animatables
  79103. */
  79104. 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[];
  79105. /**
  79106. * Begin a new animation on a given node
  79107. * @param target defines the target where the animation will take place
  79108. * @param animations defines the list of animations to start
  79109. * @param from defines the initial value
  79110. * @param to defines the final value
  79111. * @param loop defines if you want animation to loop (off by default)
  79112. * @param speedRatio defines the speed ratio to apply to all animations
  79113. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79114. * @param onAnimationLoop defines the callback to call when an animation loops
  79115. * @returns the list of created animatables
  79116. */
  79117. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79118. /**
  79119. * Begin a new animation on a given node and its hierarchy
  79120. * @param target defines the root node where the animation will take place
  79121. * @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.
  79122. * @param animations defines the list of animations to start
  79123. * @param from defines the initial value
  79124. * @param to defines the final value
  79125. * @param loop defines if you want animation to loop (off by default)
  79126. * @param speedRatio defines the speed ratio to apply to all animations
  79127. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79128. * @param onAnimationLoop defines the callback to call when an animation loops
  79129. * @returns the list of animatables created for all nodes
  79130. */
  79131. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79132. /**
  79133. * Gets the animatable associated with a specific target
  79134. * @param target defines the target of the animatable
  79135. * @returns the required animatable if found
  79136. */
  79137. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79138. /**
  79139. * Gets all animatables associated with a given target
  79140. * @param target defines the target to look animatables for
  79141. * @returns an array of Animatables
  79142. */
  79143. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79144. /**
  79145. * Stops and removes all animations that have been applied to the scene
  79146. */
  79147. stopAllAnimations(): void;
  79148. }
  79149. interface Bone {
  79150. /**
  79151. * Copy an animation range from another bone
  79152. * @param source defines the source bone
  79153. * @param rangeName defines the range name to copy
  79154. * @param frameOffset defines the frame offset
  79155. * @param rescaleAsRequired defines if rescaling must be applied if required
  79156. * @param skelDimensionsRatio defines the scaling ratio
  79157. * @returns true if operation was successful
  79158. */
  79159. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79160. }
  79161. }
  79162. declare module BABYLON {
  79163. /**
  79164. * Class used to handle skinning animations
  79165. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79166. */
  79167. export class Skeleton implements IAnimatable {
  79168. /** defines the skeleton name */
  79169. name: string;
  79170. /** defines the skeleton Id */
  79171. id: string;
  79172. /**
  79173. * Defines the list of child bones
  79174. */
  79175. bones: Bone[];
  79176. /**
  79177. * Defines an estimate of the dimension of the skeleton at rest
  79178. */
  79179. dimensionsAtRest: Vector3;
  79180. /**
  79181. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79182. */
  79183. needInitialSkinMatrix: boolean;
  79184. /**
  79185. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79186. */
  79187. overrideMesh: Nullable<AbstractMesh>;
  79188. /**
  79189. * Gets the list of animations attached to this skeleton
  79190. */
  79191. animations: Array<Animation>;
  79192. private _scene;
  79193. private _isDirty;
  79194. private _transformMatrices;
  79195. private _transformMatrixTexture;
  79196. private _meshesWithPoseMatrix;
  79197. private _animatables;
  79198. private _identity;
  79199. private _synchronizedWithMesh;
  79200. private _ranges;
  79201. private _lastAbsoluteTransformsUpdateId;
  79202. private _canUseTextureForBones;
  79203. private _uniqueId;
  79204. /** @hidden */
  79205. _numBonesWithLinkedTransformNode: number;
  79206. /** @hidden */
  79207. _hasWaitingData: Nullable<boolean>;
  79208. /**
  79209. * Specifies if the skeleton should be serialized
  79210. */
  79211. doNotSerialize: boolean;
  79212. private _useTextureToStoreBoneMatrices;
  79213. /**
  79214. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79215. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79216. */
  79217. useTextureToStoreBoneMatrices: boolean;
  79218. private _animationPropertiesOverride;
  79219. /**
  79220. * Gets or sets the animation properties override
  79221. */
  79222. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79223. /**
  79224. * List of inspectable custom properties (used by the Inspector)
  79225. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79226. */
  79227. inspectableCustomProperties: IInspectable[];
  79228. /**
  79229. * An observable triggered before computing the skeleton's matrices
  79230. */
  79231. onBeforeComputeObservable: Observable<Skeleton>;
  79232. /**
  79233. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79234. */
  79235. readonly isUsingTextureForMatrices: boolean;
  79236. /**
  79237. * Gets the unique ID of this skeleton
  79238. */
  79239. readonly uniqueId: number;
  79240. /**
  79241. * Creates a new skeleton
  79242. * @param name defines the skeleton name
  79243. * @param id defines the skeleton Id
  79244. * @param scene defines the hosting scene
  79245. */
  79246. constructor(
  79247. /** defines the skeleton name */
  79248. name: string,
  79249. /** defines the skeleton Id */
  79250. id: string, scene: Scene);
  79251. /**
  79252. * Gets the current object class name.
  79253. * @return the class name
  79254. */
  79255. getClassName(): string;
  79256. /**
  79257. * Returns an array containing the root bones
  79258. * @returns an array containing the root bones
  79259. */
  79260. getChildren(): Array<Bone>;
  79261. /**
  79262. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79263. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79264. * @returns a Float32Array containing matrices data
  79265. */
  79266. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79267. /**
  79268. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79269. * @returns a raw texture containing the data
  79270. */
  79271. getTransformMatrixTexture(): Nullable<RawTexture>;
  79272. /**
  79273. * Gets the current hosting scene
  79274. * @returns a scene object
  79275. */
  79276. getScene(): Scene;
  79277. /**
  79278. * Gets a string representing the current skeleton data
  79279. * @param fullDetails defines a boolean indicating if we want a verbose version
  79280. * @returns a string representing the current skeleton data
  79281. */
  79282. toString(fullDetails?: boolean): string;
  79283. /**
  79284. * Get bone's index searching by name
  79285. * @param name defines bone's name to search for
  79286. * @return the indice of the bone. Returns -1 if not found
  79287. */
  79288. getBoneIndexByName(name: string): number;
  79289. /**
  79290. * Creater a new animation range
  79291. * @param name defines the name of the range
  79292. * @param from defines the start key
  79293. * @param to defines the end key
  79294. */
  79295. createAnimationRange(name: string, from: number, to: number): void;
  79296. /**
  79297. * Delete a specific animation range
  79298. * @param name defines the name of the range
  79299. * @param deleteFrames defines if frames must be removed as well
  79300. */
  79301. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79302. /**
  79303. * Gets a specific animation range
  79304. * @param name defines the name of the range to look for
  79305. * @returns the requested animation range or null if not found
  79306. */
  79307. getAnimationRange(name: string): Nullable<AnimationRange>;
  79308. /**
  79309. * Gets the list of all animation ranges defined on this skeleton
  79310. * @returns an array
  79311. */
  79312. getAnimationRanges(): Nullable<AnimationRange>[];
  79313. /**
  79314. * Copy animation range from a source skeleton.
  79315. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79316. * @param source defines the source skeleton
  79317. * @param name defines the name of the range to copy
  79318. * @param rescaleAsRequired defines if rescaling must be applied if required
  79319. * @returns true if operation was successful
  79320. */
  79321. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79322. /**
  79323. * Forces the skeleton to go to rest pose
  79324. */
  79325. returnToRest(): void;
  79326. private _getHighestAnimationFrame;
  79327. /**
  79328. * Begin a specific animation range
  79329. * @param name defines the name of the range to start
  79330. * @param loop defines if looping must be turned on (false by default)
  79331. * @param speedRatio defines the speed ratio to apply (1 by default)
  79332. * @param onAnimationEnd defines a callback which will be called when animation will end
  79333. * @returns a new animatable
  79334. */
  79335. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79336. /** @hidden */
  79337. _markAsDirty(): void;
  79338. /** @hidden */
  79339. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79340. /** @hidden */
  79341. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79342. private _computeTransformMatrices;
  79343. /**
  79344. * Build all resources required to render a skeleton
  79345. */
  79346. prepare(): void;
  79347. /**
  79348. * Gets the list of animatables currently running for this skeleton
  79349. * @returns an array of animatables
  79350. */
  79351. getAnimatables(): IAnimatable[];
  79352. /**
  79353. * Clone the current skeleton
  79354. * @param name defines the name of the new skeleton
  79355. * @param id defines the id of the new skeleton
  79356. * @returns the new skeleton
  79357. */
  79358. clone(name: string, id: string): Skeleton;
  79359. /**
  79360. * Enable animation blending for this skeleton
  79361. * @param blendingSpeed defines the blending speed to apply
  79362. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79363. */
  79364. enableBlending(blendingSpeed?: number): void;
  79365. /**
  79366. * Releases all resources associated with the current skeleton
  79367. */
  79368. dispose(): void;
  79369. /**
  79370. * Serialize the skeleton in a JSON object
  79371. * @returns a JSON object
  79372. */
  79373. serialize(): any;
  79374. /**
  79375. * Creates a new skeleton from serialized data
  79376. * @param parsedSkeleton defines the serialized data
  79377. * @param scene defines the hosting scene
  79378. * @returns a new skeleton
  79379. */
  79380. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79381. /**
  79382. * Compute all node absolute transforms
  79383. * @param forceUpdate defines if computation must be done even if cache is up to date
  79384. */
  79385. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79386. /**
  79387. * Gets the root pose matrix
  79388. * @returns a matrix
  79389. */
  79390. getPoseMatrix(): Nullable<Matrix>;
  79391. /**
  79392. * Sorts bones per internal index
  79393. */
  79394. sortBones(): void;
  79395. private _sortBones;
  79396. }
  79397. }
  79398. declare module BABYLON {
  79399. /**
  79400. * Defines a target to use with MorphTargetManager
  79401. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79402. */
  79403. export class MorphTarget implements IAnimatable {
  79404. /** defines the name of the target */
  79405. name: string;
  79406. /**
  79407. * Gets or sets the list of animations
  79408. */
  79409. animations: Animation[];
  79410. private _scene;
  79411. private _positions;
  79412. private _normals;
  79413. private _tangents;
  79414. private _influence;
  79415. /**
  79416. * Observable raised when the influence changes
  79417. */
  79418. onInfluenceChanged: Observable<boolean>;
  79419. /** @hidden */
  79420. _onDataLayoutChanged: Observable<void>;
  79421. /**
  79422. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79423. */
  79424. influence: number;
  79425. /**
  79426. * Gets or sets the id of the morph Target
  79427. */
  79428. id: string;
  79429. private _animationPropertiesOverride;
  79430. /**
  79431. * Gets or sets the animation properties override
  79432. */
  79433. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79434. /**
  79435. * Creates a new MorphTarget
  79436. * @param name defines the name of the target
  79437. * @param influence defines the influence to use
  79438. * @param scene defines the scene the morphtarget belongs to
  79439. */
  79440. constructor(
  79441. /** defines the name of the target */
  79442. name: string, influence?: number, scene?: Nullable<Scene>);
  79443. /**
  79444. * Gets a boolean defining if the target contains position data
  79445. */
  79446. readonly hasPositions: boolean;
  79447. /**
  79448. * Gets a boolean defining if the target contains normal data
  79449. */
  79450. readonly hasNormals: boolean;
  79451. /**
  79452. * Gets a boolean defining if the target contains tangent data
  79453. */
  79454. readonly hasTangents: boolean;
  79455. /**
  79456. * Affects position data to this target
  79457. * @param data defines the position data to use
  79458. */
  79459. setPositions(data: Nullable<FloatArray>): void;
  79460. /**
  79461. * Gets the position data stored in this target
  79462. * @returns a FloatArray containing the position data (or null if not present)
  79463. */
  79464. getPositions(): Nullable<FloatArray>;
  79465. /**
  79466. * Affects normal data to this target
  79467. * @param data defines the normal data to use
  79468. */
  79469. setNormals(data: Nullable<FloatArray>): void;
  79470. /**
  79471. * Gets the normal data stored in this target
  79472. * @returns a FloatArray containing the normal data (or null if not present)
  79473. */
  79474. getNormals(): Nullable<FloatArray>;
  79475. /**
  79476. * Affects tangent data to this target
  79477. * @param data defines the tangent data to use
  79478. */
  79479. setTangents(data: Nullable<FloatArray>): void;
  79480. /**
  79481. * Gets the tangent data stored in this target
  79482. * @returns a FloatArray containing the tangent data (or null if not present)
  79483. */
  79484. getTangents(): Nullable<FloatArray>;
  79485. /**
  79486. * Serializes the current target into a Serialization object
  79487. * @returns the serialized object
  79488. */
  79489. serialize(): any;
  79490. /**
  79491. * Returns the string "MorphTarget"
  79492. * @returns "MorphTarget"
  79493. */
  79494. getClassName(): string;
  79495. /**
  79496. * Creates a new target from serialized data
  79497. * @param serializationObject defines the serialized data to use
  79498. * @returns a new MorphTarget
  79499. */
  79500. static Parse(serializationObject: any): MorphTarget;
  79501. /**
  79502. * Creates a MorphTarget from mesh data
  79503. * @param mesh defines the source mesh
  79504. * @param name defines the name to use for the new target
  79505. * @param influence defines the influence to attach to the target
  79506. * @returns a new MorphTarget
  79507. */
  79508. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79509. }
  79510. }
  79511. declare module BABYLON {
  79512. /**
  79513. * This class is used to deform meshes using morphing between different targets
  79514. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79515. */
  79516. export class MorphTargetManager {
  79517. private _targets;
  79518. private _targetInfluenceChangedObservers;
  79519. private _targetDataLayoutChangedObservers;
  79520. private _activeTargets;
  79521. private _scene;
  79522. private _influences;
  79523. private _supportsNormals;
  79524. private _supportsTangents;
  79525. private _vertexCount;
  79526. private _uniqueId;
  79527. private _tempInfluences;
  79528. /**
  79529. * Creates a new MorphTargetManager
  79530. * @param scene defines the current scene
  79531. */
  79532. constructor(scene?: Nullable<Scene>);
  79533. /**
  79534. * Gets the unique ID of this manager
  79535. */
  79536. readonly uniqueId: number;
  79537. /**
  79538. * Gets the number of vertices handled by this manager
  79539. */
  79540. readonly vertexCount: number;
  79541. /**
  79542. * Gets a boolean indicating if this manager supports morphing of normals
  79543. */
  79544. readonly supportsNormals: boolean;
  79545. /**
  79546. * Gets a boolean indicating if this manager supports morphing of tangents
  79547. */
  79548. readonly supportsTangents: boolean;
  79549. /**
  79550. * Gets the number of targets stored in this manager
  79551. */
  79552. readonly numTargets: number;
  79553. /**
  79554. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79555. */
  79556. readonly numInfluencers: number;
  79557. /**
  79558. * Gets the list of influences (one per target)
  79559. */
  79560. readonly influences: Float32Array;
  79561. /**
  79562. * Gets the active target at specified index. An active target is a target with an influence > 0
  79563. * @param index defines the index to check
  79564. * @returns the requested target
  79565. */
  79566. getActiveTarget(index: number): MorphTarget;
  79567. /**
  79568. * Gets the target at specified index
  79569. * @param index defines the index to check
  79570. * @returns the requested target
  79571. */
  79572. getTarget(index: number): MorphTarget;
  79573. /**
  79574. * Add a new target to this manager
  79575. * @param target defines the target to add
  79576. */
  79577. addTarget(target: MorphTarget): void;
  79578. /**
  79579. * Removes a target from the manager
  79580. * @param target defines the target to remove
  79581. */
  79582. removeTarget(target: MorphTarget): void;
  79583. /**
  79584. * Serializes the current manager into a Serialization object
  79585. * @returns the serialized object
  79586. */
  79587. serialize(): any;
  79588. private _syncActiveTargets;
  79589. /**
  79590. * Syncrhonize the targets with all the meshes using this morph target manager
  79591. */
  79592. synchronize(): void;
  79593. /**
  79594. * Creates a new MorphTargetManager from serialized data
  79595. * @param serializationObject defines the serialized data
  79596. * @param scene defines the hosting scene
  79597. * @returns the new MorphTargetManager
  79598. */
  79599. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79600. }
  79601. }
  79602. declare module BABYLON {
  79603. /**
  79604. * Class used to represent a specific level of detail of a mesh
  79605. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79606. */
  79607. export class MeshLODLevel {
  79608. /** Defines the distance where this level should star being displayed */
  79609. distance: number;
  79610. /** Defines the mesh to use to render this level */
  79611. mesh: Nullable<Mesh>;
  79612. /**
  79613. * Creates a new LOD level
  79614. * @param distance defines the distance where this level should star being displayed
  79615. * @param mesh defines the mesh to use to render this level
  79616. */
  79617. constructor(
  79618. /** Defines the distance where this level should star being displayed */
  79619. distance: number,
  79620. /** Defines the mesh to use to render this level */
  79621. mesh: Nullable<Mesh>);
  79622. }
  79623. }
  79624. declare module BABYLON {
  79625. /**
  79626. * Mesh representing the gorund
  79627. */
  79628. export class GroundMesh extends Mesh {
  79629. /** If octree should be generated */
  79630. generateOctree: boolean;
  79631. private _heightQuads;
  79632. /** @hidden */
  79633. _subdivisionsX: number;
  79634. /** @hidden */
  79635. _subdivisionsY: number;
  79636. /** @hidden */
  79637. _width: number;
  79638. /** @hidden */
  79639. _height: number;
  79640. /** @hidden */
  79641. _minX: number;
  79642. /** @hidden */
  79643. _maxX: number;
  79644. /** @hidden */
  79645. _minZ: number;
  79646. /** @hidden */
  79647. _maxZ: number;
  79648. constructor(name: string, scene: Scene);
  79649. /**
  79650. * "GroundMesh"
  79651. * @returns "GroundMesh"
  79652. */
  79653. getClassName(): string;
  79654. /**
  79655. * The minimum of x and y subdivisions
  79656. */
  79657. readonly subdivisions: number;
  79658. /**
  79659. * X subdivisions
  79660. */
  79661. readonly subdivisionsX: number;
  79662. /**
  79663. * Y subdivisions
  79664. */
  79665. readonly subdivisionsY: number;
  79666. /**
  79667. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79668. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79669. * @param chunksCount the number of subdivisions for x and y
  79670. * @param octreeBlocksSize (Default: 32)
  79671. */
  79672. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79673. /**
  79674. * Returns a height (y) value in the Worl system :
  79675. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79676. * @param x x coordinate
  79677. * @param z z coordinate
  79678. * @returns the ground y position if (x, z) are outside the ground surface.
  79679. */
  79680. getHeightAtCoordinates(x: number, z: number): number;
  79681. /**
  79682. * Returns a normalized vector (Vector3) orthogonal to the ground
  79683. * at the ground coordinates (x, z) expressed in the World system.
  79684. * @param x x coordinate
  79685. * @param z z coordinate
  79686. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79687. */
  79688. getNormalAtCoordinates(x: number, z: number): Vector3;
  79689. /**
  79690. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79691. * at the ground coordinates (x, z) expressed in the World system.
  79692. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79693. * @param x x coordinate
  79694. * @param z z coordinate
  79695. * @param ref vector to store the result
  79696. * @returns the GroundMesh.
  79697. */
  79698. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79699. /**
  79700. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79701. * if the ground has been updated.
  79702. * This can be used in the render loop.
  79703. * @returns the GroundMesh.
  79704. */
  79705. updateCoordinateHeights(): GroundMesh;
  79706. private _getFacetAt;
  79707. private _initHeightQuads;
  79708. private _computeHeightQuads;
  79709. /**
  79710. * Serializes this ground mesh
  79711. * @param serializationObject object to write serialization to
  79712. */
  79713. serialize(serializationObject: any): void;
  79714. /**
  79715. * Parses a serialized ground mesh
  79716. * @param parsedMesh the serialized mesh
  79717. * @param scene the scene to create the ground mesh in
  79718. * @returns the created ground mesh
  79719. */
  79720. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79721. }
  79722. }
  79723. declare module BABYLON {
  79724. /**
  79725. * Interface for Physics-Joint data
  79726. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79727. */
  79728. export interface PhysicsJointData {
  79729. /**
  79730. * The main pivot of the joint
  79731. */
  79732. mainPivot?: Vector3;
  79733. /**
  79734. * The connected pivot of the joint
  79735. */
  79736. connectedPivot?: Vector3;
  79737. /**
  79738. * The main axis of the joint
  79739. */
  79740. mainAxis?: Vector3;
  79741. /**
  79742. * The connected axis of the joint
  79743. */
  79744. connectedAxis?: Vector3;
  79745. /**
  79746. * The collision of the joint
  79747. */
  79748. collision?: boolean;
  79749. /**
  79750. * Native Oimo/Cannon/Energy data
  79751. */
  79752. nativeParams?: any;
  79753. }
  79754. /**
  79755. * This is a holder class for the physics joint created by the physics plugin
  79756. * It holds a set of functions to control the underlying joint
  79757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79758. */
  79759. export class PhysicsJoint {
  79760. /**
  79761. * The type of the physics joint
  79762. */
  79763. type: number;
  79764. /**
  79765. * The data for the physics joint
  79766. */
  79767. jointData: PhysicsJointData;
  79768. private _physicsJoint;
  79769. protected _physicsPlugin: IPhysicsEnginePlugin;
  79770. /**
  79771. * Initializes the physics joint
  79772. * @param type The type of the physics joint
  79773. * @param jointData The data for the physics joint
  79774. */
  79775. constructor(
  79776. /**
  79777. * The type of the physics joint
  79778. */
  79779. type: number,
  79780. /**
  79781. * The data for the physics joint
  79782. */
  79783. jointData: PhysicsJointData);
  79784. /**
  79785. * Gets the physics joint
  79786. */
  79787. /**
  79788. * Sets the physics joint
  79789. */
  79790. physicsJoint: any;
  79791. /**
  79792. * Sets the physics plugin
  79793. */
  79794. physicsPlugin: IPhysicsEnginePlugin;
  79795. /**
  79796. * Execute a function that is physics-plugin specific.
  79797. * @param {Function} func the function that will be executed.
  79798. * It accepts two parameters: the physics world and the physics joint
  79799. */
  79800. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79801. /**
  79802. * Distance-Joint type
  79803. */
  79804. static DistanceJoint: number;
  79805. /**
  79806. * Hinge-Joint type
  79807. */
  79808. static HingeJoint: number;
  79809. /**
  79810. * Ball-and-Socket joint type
  79811. */
  79812. static BallAndSocketJoint: number;
  79813. /**
  79814. * Wheel-Joint type
  79815. */
  79816. static WheelJoint: number;
  79817. /**
  79818. * Slider-Joint type
  79819. */
  79820. static SliderJoint: number;
  79821. /**
  79822. * Prismatic-Joint type
  79823. */
  79824. static PrismaticJoint: number;
  79825. /**
  79826. * Universal-Joint type
  79827. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79828. */
  79829. static UniversalJoint: number;
  79830. /**
  79831. * Hinge-Joint 2 type
  79832. */
  79833. static Hinge2Joint: number;
  79834. /**
  79835. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79836. */
  79837. static PointToPointJoint: number;
  79838. /**
  79839. * Spring-Joint type
  79840. */
  79841. static SpringJoint: number;
  79842. /**
  79843. * Lock-Joint type
  79844. */
  79845. static LockJoint: number;
  79846. }
  79847. /**
  79848. * A class representing a physics distance joint
  79849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79850. */
  79851. export class DistanceJoint extends PhysicsJoint {
  79852. /**
  79853. *
  79854. * @param jointData The data for the Distance-Joint
  79855. */
  79856. constructor(jointData: DistanceJointData);
  79857. /**
  79858. * Update the predefined distance.
  79859. * @param maxDistance The maximum preferred distance
  79860. * @param minDistance The minimum preferred distance
  79861. */
  79862. updateDistance(maxDistance: number, minDistance?: number): void;
  79863. }
  79864. /**
  79865. * Represents a Motor-Enabled Joint
  79866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79867. */
  79868. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79869. /**
  79870. * Initializes the Motor-Enabled Joint
  79871. * @param type The type of the joint
  79872. * @param jointData The physica joint data for the joint
  79873. */
  79874. constructor(type: number, jointData: PhysicsJointData);
  79875. /**
  79876. * Set the motor values.
  79877. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79878. * @param force the force to apply
  79879. * @param maxForce max force for this motor.
  79880. */
  79881. setMotor(force?: number, maxForce?: number): void;
  79882. /**
  79883. * Set the motor's limits.
  79884. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79885. * @param upperLimit The upper limit of the motor
  79886. * @param lowerLimit The lower limit of the motor
  79887. */
  79888. setLimit(upperLimit: number, lowerLimit?: number): void;
  79889. }
  79890. /**
  79891. * This class represents a single physics Hinge-Joint
  79892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79893. */
  79894. export class HingeJoint extends MotorEnabledJoint {
  79895. /**
  79896. * Initializes the Hinge-Joint
  79897. * @param jointData The joint data for the Hinge-Joint
  79898. */
  79899. constructor(jointData: PhysicsJointData);
  79900. /**
  79901. * Set the motor values.
  79902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79903. * @param {number} force the force to apply
  79904. * @param {number} maxForce max force for this motor.
  79905. */
  79906. setMotor(force?: number, maxForce?: number): void;
  79907. /**
  79908. * Set the motor's limits.
  79909. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79910. * @param upperLimit The upper limit of the motor
  79911. * @param lowerLimit The lower limit of the motor
  79912. */
  79913. setLimit(upperLimit: number, lowerLimit?: number): void;
  79914. }
  79915. /**
  79916. * This class represents a dual hinge physics joint (same as wheel joint)
  79917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79918. */
  79919. export class Hinge2Joint extends MotorEnabledJoint {
  79920. /**
  79921. * Initializes the Hinge2-Joint
  79922. * @param jointData The joint data for the Hinge2-Joint
  79923. */
  79924. constructor(jointData: PhysicsJointData);
  79925. /**
  79926. * Set the motor values.
  79927. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79928. * @param {number} targetSpeed the speed the motor is to reach
  79929. * @param {number} maxForce max force for this motor.
  79930. * @param {motorIndex} the motor's index, 0 or 1.
  79931. */
  79932. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79933. /**
  79934. * Set the motor limits.
  79935. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79936. * @param {number} upperLimit the upper limit
  79937. * @param {number} lowerLimit lower limit
  79938. * @param {motorIndex} the motor's index, 0 or 1.
  79939. */
  79940. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79941. }
  79942. /**
  79943. * Interface for a motor enabled joint
  79944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79945. */
  79946. export interface IMotorEnabledJoint {
  79947. /**
  79948. * Physics joint
  79949. */
  79950. physicsJoint: any;
  79951. /**
  79952. * Sets the motor of the motor-enabled joint
  79953. * @param force The force of the motor
  79954. * @param maxForce The maximum force of the motor
  79955. * @param motorIndex The index of the motor
  79956. */
  79957. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79958. /**
  79959. * Sets the limit of the motor
  79960. * @param upperLimit The upper limit of the motor
  79961. * @param lowerLimit The lower limit of the motor
  79962. * @param motorIndex The index of the motor
  79963. */
  79964. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79965. }
  79966. /**
  79967. * Joint data for a Distance-Joint
  79968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79969. */
  79970. export interface DistanceJointData extends PhysicsJointData {
  79971. /**
  79972. * Max distance the 2 joint objects can be apart
  79973. */
  79974. maxDistance: number;
  79975. }
  79976. /**
  79977. * Joint data from a spring joint
  79978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79979. */
  79980. export interface SpringJointData extends PhysicsJointData {
  79981. /**
  79982. * Length of the spring
  79983. */
  79984. length: number;
  79985. /**
  79986. * Stiffness of the spring
  79987. */
  79988. stiffness: number;
  79989. /**
  79990. * Damping of the spring
  79991. */
  79992. damping: number;
  79993. /** this callback will be called when applying the force to the impostors. */
  79994. forceApplicationCallback: () => void;
  79995. }
  79996. }
  79997. declare module BABYLON {
  79998. /**
  79999. * Holds the data for the raycast result
  80000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80001. */
  80002. export class PhysicsRaycastResult {
  80003. private _hasHit;
  80004. private _hitDistance;
  80005. private _hitNormalWorld;
  80006. private _hitPointWorld;
  80007. private _rayFromWorld;
  80008. private _rayToWorld;
  80009. /**
  80010. * Gets if there was a hit
  80011. */
  80012. readonly hasHit: boolean;
  80013. /**
  80014. * Gets the distance from the hit
  80015. */
  80016. readonly hitDistance: number;
  80017. /**
  80018. * Gets the hit normal/direction in the world
  80019. */
  80020. readonly hitNormalWorld: Vector3;
  80021. /**
  80022. * Gets the hit point in the world
  80023. */
  80024. readonly hitPointWorld: Vector3;
  80025. /**
  80026. * Gets the ray "start point" of the ray in the world
  80027. */
  80028. readonly rayFromWorld: Vector3;
  80029. /**
  80030. * Gets the ray "end point" of the ray in the world
  80031. */
  80032. readonly rayToWorld: Vector3;
  80033. /**
  80034. * Sets the hit data (normal & point in world space)
  80035. * @param hitNormalWorld defines the normal in world space
  80036. * @param hitPointWorld defines the point in world space
  80037. */
  80038. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  80039. /**
  80040. * Sets the distance from the start point to the hit point
  80041. * @param distance
  80042. */
  80043. setHitDistance(distance: number): void;
  80044. /**
  80045. * Calculates the distance manually
  80046. */
  80047. calculateHitDistance(): void;
  80048. /**
  80049. * Resets all the values to default
  80050. * @param from The from point on world space
  80051. * @param to The to point on world space
  80052. */
  80053. reset(from?: Vector3, to?: Vector3): void;
  80054. }
  80055. /**
  80056. * Interface for the size containing width and height
  80057. */
  80058. interface IXYZ {
  80059. /**
  80060. * X
  80061. */
  80062. x: number;
  80063. /**
  80064. * Y
  80065. */
  80066. y: number;
  80067. /**
  80068. * Z
  80069. */
  80070. z: number;
  80071. }
  80072. }
  80073. declare module BABYLON {
  80074. /**
  80075. * Interface used to describe a physics joint
  80076. */
  80077. export interface PhysicsImpostorJoint {
  80078. /** Defines the main impostor to which the joint is linked */
  80079. mainImpostor: PhysicsImpostor;
  80080. /** Defines the impostor that is connected to the main impostor using this joint */
  80081. connectedImpostor: PhysicsImpostor;
  80082. /** Defines the joint itself */
  80083. joint: PhysicsJoint;
  80084. }
  80085. /** @hidden */
  80086. export interface IPhysicsEnginePlugin {
  80087. world: any;
  80088. name: string;
  80089. setGravity(gravity: Vector3): void;
  80090. setTimeStep(timeStep: number): void;
  80091. getTimeStep(): number;
  80092. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  80093. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80094. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80095. generatePhysicsBody(impostor: PhysicsImpostor): void;
  80096. removePhysicsBody(impostor: PhysicsImpostor): void;
  80097. generateJoint(joint: PhysicsImpostorJoint): void;
  80098. removeJoint(joint: PhysicsImpostorJoint): void;
  80099. isSupported(): boolean;
  80100. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  80101. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  80102. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80103. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80104. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80105. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80106. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  80107. getBodyMass(impostor: PhysicsImpostor): number;
  80108. getBodyFriction(impostor: PhysicsImpostor): number;
  80109. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  80110. getBodyRestitution(impostor: PhysicsImpostor): number;
  80111. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  80112. getBodyPressure?(impostor: PhysicsImpostor): number;
  80113. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80114. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80115. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80116. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80117. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80118. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80119. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80120. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80121. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80122. sleepBody(impostor: PhysicsImpostor): void;
  80123. wakeUpBody(impostor: PhysicsImpostor): void;
  80124. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80125. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80126. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80127. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80128. getRadius(impostor: PhysicsImpostor): number;
  80129. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80130. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80131. dispose(): void;
  80132. }
  80133. /**
  80134. * Interface used to define a physics engine
  80135. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80136. */
  80137. export interface IPhysicsEngine {
  80138. /**
  80139. * Gets the gravity vector used by the simulation
  80140. */
  80141. gravity: Vector3;
  80142. /**
  80143. * Sets the gravity vector used by the simulation
  80144. * @param gravity defines the gravity vector to use
  80145. */
  80146. setGravity(gravity: Vector3): void;
  80147. /**
  80148. * Set the time step of the physics engine.
  80149. * Default is 1/60.
  80150. * To slow it down, enter 1/600 for example.
  80151. * To speed it up, 1/30
  80152. * @param newTimeStep the new timestep to apply to this world.
  80153. */
  80154. setTimeStep(newTimeStep: number): void;
  80155. /**
  80156. * Get the time step of the physics engine.
  80157. * @returns the current time step
  80158. */
  80159. getTimeStep(): number;
  80160. /**
  80161. * Release all resources
  80162. */
  80163. dispose(): void;
  80164. /**
  80165. * Gets the name of the current physics plugin
  80166. * @returns the name of the plugin
  80167. */
  80168. getPhysicsPluginName(): string;
  80169. /**
  80170. * Adding a new impostor for the impostor tracking.
  80171. * This will be done by the impostor itself.
  80172. * @param impostor the impostor to add
  80173. */
  80174. addImpostor(impostor: PhysicsImpostor): void;
  80175. /**
  80176. * Remove an impostor from the engine.
  80177. * This impostor and its mesh will not longer be updated by the physics engine.
  80178. * @param impostor the impostor to remove
  80179. */
  80180. removeImpostor(impostor: PhysicsImpostor): void;
  80181. /**
  80182. * Add a joint to the physics engine
  80183. * @param mainImpostor defines the main impostor to which the joint is added.
  80184. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80185. * @param joint defines the joint that will connect both impostors.
  80186. */
  80187. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80188. /**
  80189. * Removes a joint from the simulation
  80190. * @param mainImpostor defines the impostor used with the joint
  80191. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80192. * @param joint defines the joint to remove
  80193. */
  80194. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80195. /**
  80196. * Gets the current plugin used to run the simulation
  80197. * @returns current plugin
  80198. */
  80199. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80200. /**
  80201. * Gets the list of physic impostors
  80202. * @returns an array of PhysicsImpostor
  80203. */
  80204. getImpostors(): Array<PhysicsImpostor>;
  80205. /**
  80206. * Gets the impostor for a physics enabled object
  80207. * @param object defines the object impersonated by the impostor
  80208. * @returns the PhysicsImpostor or null if not found
  80209. */
  80210. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80211. /**
  80212. * Gets the impostor for a physics body object
  80213. * @param body defines physics body used by the impostor
  80214. * @returns the PhysicsImpostor or null if not found
  80215. */
  80216. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80217. /**
  80218. * Does a raycast in the physics world
  80219. * @param from when should the ray start?
  80220. * @param to when should the ray end?
  80221. * @returns PhysicsRaycastResult
  80222. */
  80223. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80224. /**
  80225. * Called by the scene. No need to call it.
  80226. * @param delta defines the timespam between frames
  80227. */
  80228. _step(delta: number): void;
  80229. }
  80230. }
  80231. declare module BABYLON {
  80232. /**
  80233. * The interface for the physics imposter parameters
  80234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80235. */
  80236. export interface PhysicsImpostorParameters {
  80237. /**
  80238. * The mass of the physics imposter
  80239. */
  80240. mass: number;
  80241. /**
  80242. * The friction of the physics imposter
  80243. */
  80244. friction?: number;
  80245. /**
  80246. * The coefficient of restitution of the physics imposter
  80247. */
  80248. restitution?: number;
  80249. /**
  80250. * The native options of the physics imposter
  80251. */
  80252. nativeOptions?: any;
  80253. /**
  80254. * Specifies if the parent should be ignored
  80255. */
  80256. ignoreParent?: boolean;
  80257. /**
  80258. * Specifies if bi-directional transformations should be disabled
  80259. */
  80260. disableBidirectionalTransformation?: boolean;
  80261. /**
  80262. * The pressure inside the physics imposter, soft object only
  80263. */
  80264. pressure?: number;
  80265. /**
  80266. * The stiffness the physics imposter, soft object only
  80267. */
  80268. stiffness?: number;
  80269. /**
  80270. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80271. */
  80272. velocityIterations?: number;
  80273. /**
  80274. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80275. */
  80276. positionIterations?: number;
  80277. /**
  80278. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80279. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80280. * Add to fix multiple points
  80281. */
  80282. fixedPoints?: number;
  80283. /**
  80284. * The collision margin around a soft object
  80285. */
  80286. margin?: number;
  80287. /**
  80288. * The collision margin around a soft object
  80289. */
  80290. damping?: number;
  80291. /**
  80292. * The path for a rope based on an extrusion
  80293. */
  80294. path?: any;
  80295. /**
  80296. * The shape of an extrusion used for a rope based on an extrusion
  80297. */
  80298. shape?: any;
  80299. }
  80300. /**
  80301. * Interface for a physics-enabled object
  80302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80303. */
  80304. export interface IPhysicsEnabledObject {
  80305. /**
  80306. * The position of the physics-enabled object
  80307. */
  80308. position: Vector3;
  80309. /**
  80310. * The rotation of the physics-enabled object
  80311. */
  80312. rotationQuaternion: Nullable<Quaternion>;
  80313. /**
  80314. * The scale of the physics-enabled object
  80315. */
  80316. scaling: Vector3;
  80317. /**
  80318. * The rotation of the physics-enabled object
  80319. */
  80320. rotation?: Vector3;
  80321. /**
  80322. * The parent of the physics-enabled object
  80323. */
  80324. parent?: any;
  80325. /**
  80326. * The bounding info of the physics-enabled object
  80327. * @returns The bounding info of the physics-enabled object
  80328. */
  80329. getBoundingInfo(): BoundingInfo;
  80330. /**
  80331. * Computes the world matrix
  80332. * @param force Specifies if the world matrix should be computed by force
  80333. * @returns A world matrix
  80334. */
  80335. computeWorldMatrix(force: boolean): Matrix;
  80336. /**
  80337. * Gets the world matrix
  80338. * @returns A world matrix
  80339. */
  80340. getWorldMatrix?(): Matrix;
  80341. /**
  80342. * Gets the child meshes
  80343. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80344. * @returns An array of abstract meshes
  80345. */
  80346. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80347. /**
  80348. * Gets the vertex data
  80349. * @param kind The type of vertex data
  80350. * @returns A nullable array of numbers, or a float32 array
  80351. */
  80352. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80353. /**
  80354. * Gets the indices from the mesh
  80355. * @returns A nullable array of index arrays
  80356. */
  80357. getIndices?(): Nullable<IndicesArray>;
  80358. /**
  80359. * Gets the scene from the mesh
  80360. * @returns the indices array or null
  80361. */
  80362. getScene?(): Scene;
  80363. /**
  80364. * Gets the absolute position from the mesh
  80365. * @returns the absolute position
  80366. */
  80367. getAbsolutePosition(): Vector3;
  80368. /**
  80369. * Gets the absolute pivot point from the mesh
  80370. * @returns the absolute pivot point
  80371. */
  80372. getAbsolutePivotPoint(): Vector3;
  80373. /**
  80374. * Rotates the mesh
  80375. * @param axis The axis of rotation
  80376. * @param amount The amount of rotation
  80377. * @param space The space of the rotation
  80378. * @returns The rotation transform node
  80379. */
  80380. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80381. /**
  80382. * Translates the mesh
  80383. * @param axis The axis of translation
  80384. * @param distance The distance of translation
  80385. * @param space The space of the translation
  80386. * @returns The transform node
  80387. */
  80388. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80389. /**
  80390. * Sets the absolute position of the mesh
  80391. * @param absolutePosition The absolute position of the mesh
  80392. * @returns The transform node
  80393. */
  80394. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80395. /**
  80396. * Gets the class name of the mesh
  80397. * @returns The class name
  80398. */
  80399. getClassName(): string;
  80400. }
  80401. /**
  80402. * Represents a physics imposter
  80403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80404. */
  80405. export class PhysicsImpostor {
  80406. /**
  80407. * The physics-enabled object used as the physics imposter
  80408. */
  80409. object: IPhysicsEnabledObject;
  80410. /**
  80411. * The type of the physics imposter
  80412. */
  80413. type: number;
  80414. private _options;
  80415. private _scene?;
  80416. /**
  80417. * The default object size of the imposter
  80418. */
  80419. static DEFAULT_OBJECT_SIZE: Vector3;
  80420. /**
  80421. * The identity quaternion of the imposter
  80422. */
  80423. static IDENTITY_QUATERNION: Quaternion;
  80424. /** @hidden */
  80425. _pluginData: any;
  80426. private _physicsEngine;
  80427. private _physicsBody;
  80428. private _bodyUpdateRequired;
  80429. private _onBeforePhysicsStepCallbacks;
  80430. private _onAfterPhysicsStepCallbacks;
  80431. /** @hidden */
  80432. _onPhysicsCollideCallbacks: Array<{
  80433. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80434. otherImpostors: Array<PhysicsImpostor>;
  80435. }>;
  80436. private _deltaPosition;
  80437. private _deltaRotation;
  80438. private _deltaRotationConjugated;
  80439. /** hidden */
  80440. _isFromLine: boolean;
  80441. private _parent;
  80442. private _isDisposed;
  80443. private static _tmpVecs;
  80444. private static _tmpQuat;
  80445. /**
  80446. * Specifies if the physics imposter is disposed
  80447. */
  80448. readonly isDisposed: boolean;
  80449. /**
  80450. * Gets the mass of the physics imposter
  80451. */
  80452. mass: number;
  80453. /**
  80454. * Gets the coefficient of friction
  80455. */
  80456. /**
  80457. * Sets the coefficient of friction
  80458. */
  80459. friction: number;
  80460. /**
  80461. * Gets the coefficient of restitution
  80462. */
  80463. /**
  80464. * Sets the coefficient of restitution
  80465. */
  80466. restitution: number;
  80467. /**
  80468. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80469. */
  80470. /**
  80471. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80472. */
  80473. pressure: number;
  80474. /**
  80475. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80476. */
  80477. /**
  80478. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80479. */
  80480. stiffness: number;
  80481. /**
  80482. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80483. */
  80484. /**
  80485. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80486. */
  80487. velocityIterations: number;
  80488. /**
  80489. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80490. */
  80491. /**
  80492. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80493. */
  80494. positionIterations: number;
  80495. /**
  80496. * The unique id of the physics imposter
  80497. * set by the physics engine when adding this impostor to the array
  80498. */
  80499. uniqueId: number;
  80500. /**
  80501. * @hidden
  80502. */
  80503. soft: boolean;
  80504. /**
  80505. * @hidden
  80506. */
  80507. segments: number;
  80508. private _joints;
  80509. /**
  80510. * Initializes the physics imposter
  80511. * @param object The physics-enabled object used as the physics imposter
  80512. * @param type The type of the physics imposter
  80513. * @param _options The options for the physics imposter
  80514. * @param _scene The Babylon scene
  80515. */
  80516. constructor(
  80517. /**
  80518. * The physics-enabled object used as the physics imposter
  80519. */
  80520. object: IPhysicsEnabledObject,
  80521. /**
  80522. * The type of the physics imposter
  80523. */
  80524. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80525. /**
  80526. * This function will completly initialize this impostor.
  80527. * It will create a new body - but only if this mesh has no parent.
  80528. * If it has, this impostor will not be used other than to define the impostor
  80529. * of the child mesh.
  80530. * @hidden
  80531. */
  80532. _init(): void;
  80533. private _getPhysicsParent;
  80534. /**
  80535. * Should a new body be generated.
  80536. * @returns boolean specifying if body initialization is required
  80537. */
  80538. isBodyInitRequired(): boolean;
  80539. /**
  80540. * Sets the updated scaling
  80541. * @param updated Specifies if the scaling is updated
  80542. */
  80543. setScalingUpdated(): void;
  80544. /**
  80545. * Force a regeneration of this or the parent's impostor's body.
  80546. * Use under cautious - This will remove all joints already implemented.
  80547. */
  80548. forceUpdate(): void;
  80549. /**
  80550. * Gets the body that holds this impostor. Either its own, or its parent.
  80551. */
  80552. /**
  80553. * Set the physics body. Used mainly by the physics engine/plugin
  80554. */
  80555. physicsBody: any;
  80556. /**
  80557. * Get the parent of the physics imposter
  80558. * @returns Physics imposter or null
  80559. */
  80560. /**
  80561. * Sets the parent of the physics imposter
  80562. */
  80563. parent: Nullable<PhysicsImpostor>;
  80564. /**
  80565. * Resets the update flags
  80566. */
  80567. resetUpdateFlags(): void;
  80568. /**
  80569. * Gets the object extend size
  80570. * @returns the object extend size
  80571. */
  80572. getObjectExtendSize(): Vector3;
  80573. /**
  80574. * Gets the object center
  80575. * @returns The object center
  80576. */
  80577. getObjectCenter(): Vector3;
  80578. /**
  80579. * Get a specific parametes from the options parameter
  80580. * @param paramName The object parameter name
  80581. * @returns The object parameter
  80582. */
  80583. getParam(paramName: string): any;
  80584. /**
  80585. * Sets a specific parameter in the options given to the physics plugin
  80586. * @param paramName The parameter name
  80587. * @param value The value of the parameter
  80588. */
  80589. setParam(paramName: string, value: number): void;
  80590. /**
  80591. * Specifically change the body's mass option. Won't recreate the physics body object
  80592. * @param mass The mass of the physics imposter
  80593. */
  80594. setMass(mass: number): void;
  80595. /**
  80596. * Gets the linear velocity
  80597. * @returns linear velocity or null
  80598. */
  80599. getLinearVelocity(): Nullable<Vector3>;
  80600. /**
  80601. * Sets the linear velocity
  80602. * @param velocity linear velocity or null
  80603. */
  80604. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80605. /**
  80606. * Gets the angular velocity
  80607. * @returns angular velocity or null
  80608. */
  80609. getAngularVelocity(): Nullable<Vector3>;
  80610. /**
  80611. * Sets the angular velocity
  80612. * @param velocity The velocity or null
  80613. */
  80614. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80615. /**
  80616. * Execute a function with the physics plugin native code
  80617. * Provide a function the will have two variables - the world object and the physics body object
  80618. * @param func The function to execute with the physics plugin native code
  80619. */
  80620. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80621. /**
  80622. * Register a function that will be executed before the physics world is stepping forward
  80623. * @param func The function to execute before the physics world is stepped forward
  80624. */
  80625. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80626. /**
  80627. * Unregister a function that will be executed before the physics world is stepping forward
  80628. * @param func The function to execute before the physics world is stepped forward
  80629. */
  80630. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80631. /**
  80632. * Register a function that will be executed after the physics step
  80633. * @param func The function to execute after physics step
  80634. */
  80635. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80636. /**
  80637. * Unregisters a function that will be executed after the physics step
  80638. * @param func The function to execute after physics step
  80639. */
  80640. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80641. /**
  80642. * register a function that will be executed when this impostor collides against a different body
  80643. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80644. * @param func Callback that is executed on collision
  80645. */
  80646. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80647. /**
  80648. * Unregisters the physics imposter on contact
  80649. * @param collideAgainst The physics object to collide against
  80650. * @param func Callback to execute on collision
  80651. */
  80652. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80653. private _tmpQuat;
  80654. private _tmpQuat2;
  80655. /**
  80656. * Get the parent rotation
  80657. * @returns The parent rotation
  80658. */
  80659. getParentsRotation(): Quaternion;
  80660. /**
  80661. * this function is executed by the physics engine.
  80662. */
  80663. beforeStep: () => void;
  80664. /**
  80665. * this function is executed by the physics engine
  80666. */
  80667. afterStep: () => void;
  80668. /**
  80669. * Legacy collision detection event support
  80670. */
  80671. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80672. /**
  80673. * event and body object due to cannon's event-based architecture.
  80674. */
  80675. onCollide: (e: {
  80676. body: any;
  80677. }) => void;
  80678. /**
  80679. * Apply a force
  80680. * @param force The force to apply
  80681. * @param contactPoint The contact point for the force
  80682. * @returns The physics imposter
  80683. */
  80684. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80685. /**
  80686. * Apply an impulse
  80687. * @param force The impulse force
  80688. * @param contactPoint The contact point for the impulse force
  80689. * @returns The physics imposter
  80690. */
  80691. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80692. /**
  80693. * A help function to create a joint
  80694. * @param otherImpostor A physics imposter used to create a joint
  80695. * @param jointType The type of joint
  80696. * @param jointData The data for the joint
  80697. * @returns The physics imposter
  80698. */
  80699. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80700. /**
  80701. * Add a joint to this impostor with a different impostor
  80702. * @param otherImpostor A physics imposter used to add a joint
  80703. * @param joint The joint to add
  80704. * @returns The physics imposter
  80705. */
  80706. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80707. /**
  80708. * Add an anchor to a cloth impostor
  80709. * @param otherImpostor rigid impostor to anchor to
  80710. * @param width ratio across width from 0 to 1
  80711. * @param height ratio up height from 0 to 1
  80712. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80713. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80714. * @returns impostor the soft imposter
  80715. */
  80716. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80717. /**
  80718. * Add a hook to a rope impostor
  80719. * @param otherImpostor rigid impostor to anchor to
  80720. * @param length ratio across rope from 0 to 1
  80721. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80722. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80723. * @returns impostor the rope imposter
  80724. */
  80725. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80726. /**
  80727. * Will keep this body still, in a sleep mode.
  80728. * @returns the physics imposter
  80729. */
  80730. sleep(): PhysicsImpostor;
  80731. /**
  80732. * Wake the body up.
  80733. * @returns The physics imposter
  80734. */
  80735. wakeUp(): PhysicsImpostor;
  80736. /**
  80737. * Clones the physics imposter
  80738. * @param newObject The physics imposter clones to this physics-enabled object
  80739. * @returns A nullable physics imposter
  80740. */
  80741. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80742. /**
  80743. * Disposes the physics imposter
  80744. */
  80745. dispose(): void;
  80746. /**
  80747. * Sets the delta position
  80748. * @param position The delta position amount
  80749. */
  80750. setDeltaPosition(position: Vector3): void;
  80751. /**
  80752. * Sets the delta rotation
  80753. * @param rotation The delta rotation amount
  80754. */
  80755. setDeltaRotation(rotation: Quaternion): void;
  80756. /**
  80757. * Gets the box size of the physics imposter and stores the result in the input parameter
  80758. * @param result Stores the box size
  80759. * @returns The physics imposter
  80760. */
  80761. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80762. /**
  80763. * Gets the radius of the physics imposter
  80764. * @returns Radius of the physics imposter
  80765. */
  80766. getRadius(): number;
  80767. /**
  80768. * Sync a bone with this impostor
  80769. * @param bone The bone to sync to the impostor.
  80770. * @param boneMesh The mesh that the bone is influencing.
  80771. * @param jointPivot The pivot of the joint / bone in local space.
  80772. * @param distToJoint Optional distance from the impostor to the joint.
  80773. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80774. */
  80775. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80776. /**
  80777. * Sync impostor to a bone
  80778. * @param bone The bone that the impostor will be synced to.
  80779. * @param boneMesh The mesh that the bone is influencing.
  80780. * @param jointPivot The pivot of the joint / bone in local space.
  80781. * @param distToJoint Optional distance from the impostor to the joint.
  80782. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80783. * @param boneAxis Optional vector3 axis the bone is aligned with
  80784. */
  80785. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80786. /**
  80787. * No-Imposter type
  80788. */
  80789. static NoImpostor: number;
  80790. /**
  80791. * Sphere-Imposter type
  80792. */
  80793. static SphereImpostor: number;
  80794. /**
  80795. * Box-Imposter type
  80796. */
  80797. static BoxImpostor: number;
  80798. /**
  80799. * Plane-Imposter type
  80800. */
  80801. static PlaneImpostor: number;
  80802. /**
  80803. * Mesh-imposter type
  80804. */
  80805. static MeshImpostor: number;
  80806. /**
  80807. * Cylinder-Imposter type
  80808. */
  80809. static CylinderImpostor: number;
  80810. /**
  80811. * Particle-Imposter type
  80812. */
  80813. static ParticleImpostor: number;
  80814. /**
  80815. * Heightmap-Imposter type
  80816. */
  80817. static HeightmapImpostor: number;
  80818. /**
  80819. * ConvexHull-Impostor type (Ammo.js plugin only)
  80820. */
  80821. static ConvexHullImpostor: number;
  80822. /**
  80823. * Rope-Imposter type
  80824. */
  80825. static RopeImpostor: number;
  80826. /**
  80827. * Cloth-Imposter type
  80828. */
  80829. static ClothImpostor: number;
  80830. /**
  80831. * Softbody-Imposter type
  80832. */
  80833. static SoftbodyImpostor: number;
  80834. }
  80835. }
  80836. declare module BABYLON {
  80837. /**
  80838. * @hidden
  80839. **/
  80840. export class _CreationDataStorage {
  80841. closePath?: boolean;
  80842. closeArray?: boolean;
  80843. idx: number[];
  80844. dashSize: number;
  80845. gapSize: number;
  80846. path3D: Path3D;
  80847. pathArray: Vector3[][];
  80848. arc: number;
  80849. radius: number;
  80850. cap: number;
  80851. tessellation: number;
  80852. }
  80853. /**
  80854. * @hidden
  80855. **/
  80856. class _InstanceDataStorage {
  80857. visibleInstances: any;
  80858. batchCache: _InstancesBatch;
  80859. instancesBufferSize: number;
  80860. instancesBuffer: Nullable<Buffer>;
  80861. instancesData: Float32Array;
  80862. overridenInstanceCount: number;
  80863. isFrozen: boolean;
  80864. previousBatch: _InstancesBatch;
  80865. hardwareInstancedRendering: boolean;
  80866. sideOrientation: number;
  80867. }
  80868. /**
  80869. * @hidden
  80870. **/
  80871. export class _InstancesBatch {
  80872. mustReturn: boolean;
  80873. visibleInstances: Nullable<InstancedMesh[]>[];
  80874. renderSelf: boolean[];
  80875. hardwareInstancedRendering: boolean[];
  80876. }
  80877. /**
  80878. * Class used to represent renderable models
  80879. */
  80880. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80881. /**
  80882. * Mesh side orientation : usually the external or front surface
  80883. */
  80884. static readonly FRONTSIDE: number;
  80885. /**
  80886. * Mesh side orientation : usually the internal or back surface
  80887. */
  80888. static readonly BACKSIDE: number;
  80889. /**
  80890. * Mesh side orientation : both internal and external or front and back surfaces
  80891. */
  80892. static readonly DOUBLESIDE: number;
  80893. /**
  80894. * Mesh side orientation : by default, `FRONTSIDE`
  80895. */
  80896. static readonly DEFAULTSIDE: number;
  80897. /**
  80898. * Mesh cap setting : no cap
  80899. */
  80900. static readonly NO_CAP: number;
  80901. /**
  80902. * Mesh cap setting : one cap at the beginning of the mesh
  80903. */
  80904. static readonly CAP_START: number;
  80905. /**
  80906. * Mesh cap setting : one cap at the end of the mesh
  80907. */
  80908. static readonly CAP_END: number;
  80909. /**
  80910. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80911. */
  80912. static readonly CAP_ALL: number;
  80913. /**
  80914. * Gets the default side orientation.
  80915. * @param orientation the orientation to value to attempt to get
  80916. * @returns the default orientation
  80917. * @hidden
  80918. */
  80919. static _GetDefaultSideOrientation(orientation?: number): number;
  80920. private _internalMeshDataInfo;
  80921. /**
  80922. * An event triggered before rendering the mesh
  80923. */
  80924. readonly onBeforeRenderObservable: Observable<Mesh>;
  80925. /**
  80926. * An event triggered before binding the mesh
  80927. */
  80928. readonly onBeforeBindObservable: Observable<Mesh>;
  80929. /**
  80930. * An event triggered after rendering the mesh
  80931. */
  80932. readonly onAfterRenderObservable: Observable<Mesh>;
  80933. /**
  80934. * An event triggered before drawing the mesh
  80935. */
  80936. readonly onBeforeDrawObservable: Observable<Mesh>;
  80937. private _onBeforeDrawObserver;
  80938. /**
  80939. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80940. */
  80941. onBeforeDraw: () => void;
  80942. /**
  80943. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80944. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80945. */
  80946. delayLoadState: number;
  80947. /**
  80948. * Gets the list of instances created from this mesh
  80949. * it is not supposed to be modified manually.
  80950. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80951. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80952. */
  80953. instances: InstancedMesh[];
  80954. /**
  80955. * Gets the file containing delay loading data for this mesh
  80956. */
  80957. delayLoadingFile: string;
  80958. /** @hidden */
  80959. _binaryInfo: any;
  80960. /**
  80961. * User defined function used to change how LOD level selection is done
  80962. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80963. */
  80964. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80965. /**
  80966. * Gets or sets the morph target manager
  80967. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80968. */
  80969. morphTargetManager: Nullable<MorphTargetManager>;
  80970. /** @hidden */
  80971. _creationDataStorage: Nullable<_CreationDataStorage>;
  80972. /** @hidden */
  80973. _geometry: Nullable<Geometry>;
  80974. /** @hidden */
  80975. _delayInfo: Array<string>;
  80976. /** @hidden */
  80977. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80978. /** @hidden */
  80979. _instanceDataStorage: _InstanceDataStorage;
  80980. private _effectiveMaterial;
  80981. /** @hidden */
  80982. _shouldGenerateFlatShading: boolean;
  80983. /** @hidden */
  80984. _originalBuilderSideOrientation: number;
  80985. /**
  80986. * Use this property to change the original side orientation defined at construction time
  80987. */
  80988. overrideMaterialSideOrientation: Nullable<number>;
  80989. /**
  80990. * Gets the source mesh (the one used to clone this one from)
  80991. */
  80992. readonly source: Nullable<Mesh>;
  80993. /**
  80994. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80995. */
  80996. isUnIndexed: boolean;
  80997. /**
  80998. * @constructor
  80999. * @param name The value used by scene.getMeshByName() to do a lookup.
  81000. * @param scene The scene to add this mesh to.
  81001. * @param parent The parent of this mesh, if it has one
  81002. * @param source An optional Mesh from which geometry is shared, cloned.
  81003. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  81004. * When false, achieved by calling a clone(), also passing False.
  81005. * This will make creation of children, recursive.
  81006. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  81007. */
  81008. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  81009. /**
  81010. * Gets the class name
  81011. * @returns the string "Mesh".
  81012. */
  81013. getClassName(): string;
  81014. /** @hidden */
  81015. readonly _isMesh: boolean;
  81016. /**
  81017. * Returns a description of this mesh
  81018. * @param fullDetails define if full details about this mesh must be used
  81019. * @returns a descriptive string representing this mesh
  81020. */
  81021. toString(fullDetails?: boolean): string;
  81022. /** @hidden */
  81023. _unBindEffect(): void;
  81024. /**
  81025. * Gets a boolean indicating if this mesh has LOD
  81026. */
  81027. readonly hasLODLevels: boolean;
  81028. /**
  81029. * Gets the list of MeshLODLevel associated with the current mesh
  81030. * @returns an array of MeshLODLevel
  81031. */
  81032. getLODLevels(): MeshLODLevel[];
  81033. private _sortLODLevels;
  81034. /**
  81035. * Add a mesh as LOD level triggered at the given distance.
  81036. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  81037. * @param distance The distance from the center of the object to show this level
  81038. * @param mesh The mesh to be added as LOD level (can be null)
  81039. * @return This mesh (for chaining)
  81040. */
  81041. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  81042. /**
  81043. * Returns the LOD level mesh at the passed distance or null if not found.
  81044. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  81045. * @param distance The distance from the center of the object to show this level
  81046. * @returns a Mesh or `null`
  81047. */
  81048. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  81049. /**
  81050. * Remove a mesh from the LOD array
  81051. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  81052. * @param mesh defines the mesh to be removed
  81053. * @return This mesh (for chaining)
  81054. */
  81055. removeLODLevel(mesh: Mesh): Mesh;
  81056. /**
  81057. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  81058. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  81059. * @param camera defines the camera to use to compute distance
  81060. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  81061. * @return This mesh (for chaining)
  81062. */
  81063. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  81064. /**
  81065. * Gets the mesh internal Geometry object
  81066. */
  81067. readonly geometry: Nullable<Geometry>;
  81068. /**
  81069. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  81070. * @returns the total number of vertices
  81071. */
  81072. getTotalVertices(): number;
  81073. /**
  81074. * Returns the content of an associated vertex buffer
  81075. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81076. * - VertexBuffer.PositionKind
  81077. * - VertexBuffer.UVKind
  81078. * - VertexBuffer.UV2Kind
  81079. * - VertexBuffer.UV3Kind
  81080. * - VertexBuffer.UV4Kind
  81081. * - VertexBuffer.UV5Kind
  81082. * - VertexBuffer.UV6Kind
  81083. * - VertexBuffer.ColorKind
  81084. * - VertexBuffer.MatricesIndicesKind
  81085. * - VertexBuffer.MatricesIndicesExtraKind
  81086. * - VertexBuffer.MatricesWeightsKind
  81087. * - VertexBuffer.MatricesWeightsExtraKind
  81088. * @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
  81089. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  81090. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  81091. */
  81092. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81093. /**
  81094. * Returns the mesh VertexBuffer object from the requested `kind`
  81095. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81096. * - VertexBuffer.PositionKind
  81097. * - VertexBuffer.UVKind
  81098. * - VertexBuffer.UV2Kind
  81099. * - VertexBuffer.UV3Kind
  81100. * - VertexBuffer.UV4Kind
  81101. * - VertexBuffer.UV5Kind
  81102. * - VertexBuffer.UV6Kind
  81103. * - VertexBuffer.ColorKind
  81104. * - VertexBuffer.MatricesIndicesKind
  81105. * - VertexBuffer.MatricesIndicesExtraKind
  81106. * - VertexBuffer.MatricesWeightsKind
  81107. * - VertexBuffer.MatricesWeightsExtraKind
  81108. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81109. */
  81110. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81111. /**
  81112. * Tests if a specific vertex buffer is associated with this mesh
  81113. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81114. * - VertexBuffer.PositionKind
  81115. * - VertexBuffer.UVKind
  81116. * - VertexBuffer.UV2Kind
  81117. * - VertexBuffer.UV3Kind
  81118. * - VertexBuffer.UV4Kind
  81119. * - VertexBuffer.UV5Kind
  81120. * - VertexBuffer.UV6Kind
  81121. * - VertexBuffer.ColorKind
  81122. * - VertexBuffer.MatricesIndicesKind
  81123. * - VertexBuffer.MatricesIndicesExtraKind
  81124. * - VertexBuffer.MatricesWeightsKind
  81125. * - VertexBuffer.MatricesWeightsExtraKind
  81126. * @returns a boolean
  81127. */
  81128. isVerticesDataPresent(kind: string): boolean;
  81129. /**
  81130. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81131. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81132. * - VertexBuffer.PositionKind
  81133. * - VertexBuffer.UVKind
  81134. * - VertexBuffer.UV2Kind
  81135. * - VertexBuffer.UV3Kind
  81136. * - VertexBuffer.UV4Kind
  81137. * - VertexBuffer.UV5Kind
  81138. * - VertexBuffer.UV6Kind
  81139. * - VertexBuffer.ColorKind
  81140. * - VertexBuffer.MatricesIndicesKind
  81141. * - VertexBuffer.MatricesIndicesExtraKind
  81142. * - VertexBuffer.MatricesWeightsKind
  81143. * - VertexBuffer.MatricesWeightsExtraKind
  81144. * @returns a boolean
  81145. */
  81146. isVertexBufferUpdatable(kind: string): boolean;
  81147. /**
  81148. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81149. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81150. * - VertexBuffer.PositionKind
  81151. * - VertexBuffer.UVKind
  81152. * - VertexBuffer.UV2Kind
  81153. * - VertexBuffer.UV3Kind
  81154. * - VertexBuffer.UV4Kind
  81155. * - VertexBuffer.UV5Kind
  81156. * - VertexBuffer.UV6Kind
  81157. * - VertexBuffer.ColorKind
  81158. * - VertexBuffer.MatricesIndicesKind
  81159. * - VertexBuffer.MatricesIndicesExtraKind
  81160. * - VertexBuffer.MatricesWeightsKind
  81161. * - VertexBuffer.MatricesWeightsExtraKind
  81162. * @returns an array of strings
  81163. */
  81164. getVerticesDataKinds(): string[];
  81165. /**
  81166. * Returns a positive integer : the total number of indices in this mesh geometry.
  81167. * @returns the numner of indices or zero if the mesh has no geometry.
  81168. */
  81169. getTotalIndices(): number;
  81170. /**
  81171. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81172. * @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.
  81173. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81174. * @returns the indices array or an empty array if the mesh has no geometry
  81175. */
  81176. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81177. readonly isBlocked: boolean;
  81178. /**
  81179. * Determine if the current mesh is ready to be rendered
  81180. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81181. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81182. * @returns true if all associated assets are ready (material, textures, shaders)
  81183. */
  81184. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81185. /**
  81186. * 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.
  81187. */
  81188. readonly areNormalsFrozen: boolean;
  81189. /**
  81190. * 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.
  81191. * @returns the current mesh
  81192. */
  81193. freezeNormals(): Mesh;
  81194. /**
  81195. * 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
  81196. * @returns the current mesh
  81197. */
  81198. unfreezeNormals(): Mesh;
  81199. /**
  81200. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81201. */
  81202. overridenInstanceCount: number;
  81203. /** @hidden */
  81204. _preActivate(): Mesh;
  81205. /** @hidden */
  81206. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81207. /** @hidden */
  81208. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81209. /**
  81210. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81211. * This means the mesh underlying bounding box and sphere are recomputed.
  81212. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81213. * @returns the current mesh
  81214. */
  81215. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81216. /** @hidden */
  81217. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81218. /**
  81219. * This function will subdivide the mesh into multiple submeshes
  81220. * @param count defines the expected number of submeshes
  81221. */
  81222. subdivide(count: number): void;
  81223. /**
  81224. * Copy a FloatArray into a specific associated vertex buffer
  81225. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81226. * - VertexBuffer.PositionKind
  81227. * - VertexBuffer.UVKind
  81228. * - VertexBuffer.UV2Kind
  81229. * - VertexBuffer.UV3Kind
  81230. * - VertexBuffer.UV4Kind
  81231. * - VertexBuffer.UV5Kind
  81232. * - VertexBuffer.UV6Kind
  81233. * - VertexBuffer.ColorKind
  81234. * - VertexBuffer.MatricesIndicesKind
  81235. * - VertexBuffer.MatricesIndicesExtraKind
  81236. * - VertexBuffer.MatricesWeightsKind
  81237. * - VertexBuffer.MatricesWeightsExtraKind
  81238. * @param data defines the data source
  81239. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81240. * @param stride defines the data stride size (can be null)
  81241. * @returns the current mesh
  81242. */
  81243. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81244. /**
  81245. * Flags an associated vertex buffer as updatable
  81246. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81247. * - VertexBuffer.PositionKind
  81248. * - VertexBuffer.UVKind
  81249. * - VertexBuffer.UV2Kind
  81250. * - VertexBuffer.UV3Kind
  81251. * - VertexBuffer.UV4Kind
  81252. * - VertexBuffer.UV5Kind
  81253. * - VertexBuffer.UV6Kind
  81254. * - VertexBuffer.ColorKind
  81255. * - VertexBuffer.MatricesIndicesKind
  81256. * - VertexBuffer.MatricesIndicesExtraKind
  81257. * - VertexBuffer.MatricesWeightsKind
  81258. * - VertexBuffer.MatricesWeightsExtraKind
  81259. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81260. */
  81261. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81262. /**
  81263. * Sets the mesh global Vertex Buffer
  81264. * @param buffer defines the buffer to use
  81265. * @returns the current mesh
  81266. */
  81267. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81268. /**
  81269. * Update a specific associated vertex buffer
  81270. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81271. * - VertexBuffer.PositionKind
  81272. * - VertexBuffer.UVKind
  81273. * - VertexBuffer.UV2Kind
  81274. * - VertexBuffer.UV3Kind
  81275. * - VertexBuffer.UV4Kind
  81276. * - VertexBuffer.UV5Kind
  81277. * - VertexBuffer.UV6Kind
  81278. * - VertexBuffer.ColorKind
  81279. * - VertexBuffer.MatricesIndicesKind
  81280. * - VertexBuffer.MatricesIndicesExtraKind
  81281. * - VertexBuffer.MatricesWeightsKind
  81282. * - VertexBuffer.MatricesWeightsExtraKind
  81283. * @param data defines the data source
  81284. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81285. * @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)
  81286. * @returns the current mesh
  81287. */
  81288. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81289. /**
  81290. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81291. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81292. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81293. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81294. * @returns the current mesh
  81295. */
  81296. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81297. /**
  81298. * Creates a un-shared specific occurence of the geometry for the mesh.
  81299. * @returns the current mesh
  81300. */
  81301. makeGeometryUnique(): Mesh;
  81302. /**
  81303. * Set the index buffer of this mesh
  81304. * @param indices defines the source data
  81305. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81306. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81307. * @returns the current mesh
  81308. */
  81309. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81310. /**
  81311. * Update the current index buffer
  81312. * @param indices defines the source data
  81313. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81314. * @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)
  81315. * @returns the current mesh
  81316. */
  81317. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81318. /**
  81319. * Invert the geometry to move from a right handed system to a left handed one.
  81320. * @returns the current mesh
  81321. */
  81322. toLeftHanded(): Mesh;
  81323. /** @hidden */
  81324. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81325. /** @hidden */
  81326. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81327. /**
  81328. * Registers for this mesh a javascript function called just before the rendering process
  81329. * @param func defines the function to call before rendering this mesh
  81330. * @returns the current mesh
  81331. */
  81332. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81333. /**
  81334. * Disposes a previously registered javascript function called before the rendering
  81335. * @param func defines the function to remove
  81336. * @returns the current mesh
  81337. */
  81338. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81339. /**
  81340. * Registers for this mesh a javascript function called just after the rendering is complete
  81341. * @param func defines the function to call after rendering this mesh
  81342. * @returns the current mesh
  81343. */
  81344. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81345. /**
  81346. * Disposes a previously registered javascript function called after the rendering.
  81347. * @param func defines the function to remove
  81348. * @returns the current mesh
  81349. */
  81350. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81351. /** @hidden */
  81352. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81353. /** @hidden */
  81354. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81355. /** @hidden */
  81356. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81357. /** @hidden */
  81358. _freeze(): void;
  81359. /** @hidden */
  81360. _unFreeze(): void;
  81361. /**
  81362. * 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
  81363. * @param subMesh defines the subMesh to render
  81364. * @param enableAlphaMode defines if alpha mode can be changed
  81365. * @returns the current mesh
  81366. */
  81367. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81368. private _onBeforeDraw;
  81369. /**
  81370. * Renormalize the mesh and patch it up if there are no weights
  81371. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81372. * However in the case of zero weights then we set just a single influence to 1.
  81373. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81374. */
  81375. cleanMatrixWeights(): void;
  81376. private normalizeSkinFourWeights;
  81377. private normalizeSkinWeightsAndExtra;
  81378. /**
  81379. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81380. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81381. * the user know there was an issue with importing the mesh
  81382. * @returns a validation object with skinned, valid and report string
  81383. */
  81384. validateSkinning(): {
  81385. skinned: boolean;
  81386. valid: boolean;
  81387. report: string;
  81388. };
  81389. /** @hidden */
  81390. _checkDelayState(): Mesh;
  81391. private _queueLoad;
  81392. /**
  81393. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81394. * A mesh is in the frustum if its bounding box intersects the frustum
  81395. * @param frustumPlanes defines the frustum to test
  81396. * @returns true if the mesh is in the frustum planes
  81397. */
  81398. isInFrustum(frustumPlanes: Plane[]): boolean;
  81399. /**
  81400. * Sets the mesh material by the material or multiMaterial `id` property
  81401. * @param id is a string identifying the material or the multiMaterial
  81402. * @returns the current mesh
  81403. */
  81404. setMaterialByID(id: string): Mesh;
  81405. /**
  81406. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81407. * @returns an array of IAnimatable
  81408. */
  81409. getAnimatables(): IAnimatable[];
  81410. /**
  81411. * Modifies the mesh geometry according to the passed transformation matrix.
  81412. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81413. * The mesh normals are modified using the same transformation.
  81414. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81415. * @param transform defines the transform matrix to use
  81416. * @see http://doc.babylonjs.com/resources/baking_transformations
  81417. * @returns the current mesh
  81418. */
  81419. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81420. /**
  81421. * Modifies the mesh geometry according to its own current World Matrix.
  81422. * The mesh World Matrix is then reset.
  81423. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81424. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81425. * @see http://doc.babylonjs.com/resources/baking_transformations
  81426. * @returns the current mesh
  81427. */
  81428. bakeCurrentTransformIntoVertices(): Mesh;
  81429. /** @hidden */
  81430. readonly _positions: Nullable<Vector3[]>;
  81431. /** @hidden */
  81432. _resetPointsArrayCache(): Mesh;
  81433. /** @hidden */
  81434. _generatePointsArray(): boolean;
  81435. /**
  81436. * Returns a new Mesh object generated from the current mesh properties.
  81437. * This method must not get confused with createInstance()
  81438. * @param name is a string, the name given to the new mesh
  81439. * @param newParent can be any Node object (default `null`)
  81440. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81441. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81442. * @returns a new mesh
  81443. */
  81444. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81445. /**
  81446. * Releases resources associated with this mesh.
  81447. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81448. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81449. */
  81450. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81451. /**
  81452. * Modifies the mesh geometry according to a displacement map.
  81453. * 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.
  81454. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81455. * @param url is a string, the URL from the image file is to be downloaded.
  81456. * @param minHeight is the lower limit of the displacement.
  81457. * @param maxHeight is the upper limit of the displacement.
  81458. * @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.
  81459. * @param uvOffset is an optional vector2 used to offset UV.
  81460. * @param uvScale is an optional vector2 used to scale UV.
  81461. * @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.
  81462. * @returns the Mesh.
  81463. */
  81464. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81465. /**
  81466. * Modifies the mesh geometry according to a displacementMap buffer.
  81467. * 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.
  81468. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81469. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81470. * @param heightMapWidth is the width of the buffer image.
  81471. * @param heightMapHeight is the height of the buffer image.
  81472. * @param minHeight is the lower limit of the displacement.
  81473. * @param maxHeight is the upper limit of the displacement.
  81474. * @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.
  81475. * @param uvOffset is an optional vector2 used to offset UV.
  81476. * @param uvScale is an optional vector2 used to scale UV.
  81477. * @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.
  81478. * @returns the Mesh.
  81479. */
  81480. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81481. /**
  81482. * Modify the mesh to get a flat shading rendering.
  81483. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81484. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81485. * @returns current mesh
  81486. */
  81487. convertToFlatShadedMesh(): Mesh;
  81488. /**
  81489. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81490. * In other words, more vertices, no more indices and a single bigger VBO.
  81491. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81492. * @returns current mesh
  81493. */
  81494. convertToUnIndexedMesh(): Mesh;
  81495. /**
  81496. * Inverses facet orientations.
  81497. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81498. * @param flipNormals will also inverts the normals
  81499. * @returns current mesh
  81500. */
  81501. flipFaces(flipNormals?: boolean): Mesh;
  81502. /**
  81503. * Increase the number of facets and hence vertices in a mesh
  81504. * Vertex normals are interpolated from existing vertex normals
  81505. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81506. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81507. */
  81508. increaseVertices(numberPerEdge: number): void;
  81509. /**
  81510. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81511. * This will undo any application of covertToFlatShadedMesh
  81512. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81513. */
  81514. forceSharedVertices(): void;
  81515. /** @hidden */
  81516. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81517. /** @hidden */
  81518. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81519. /**
  81520. * Creates a new InstancedMesh object from the mesh model.
  81521. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81522. * @param name defines the name of the new instance
  81523. * @returns a new InstancedMesh
  81524. */
  81525. createInstance(name: string): InstancedMesh;
  81526. /**
  81527. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81528. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81529. * @returns the current mesh
  81530. */
  81531. synchronizeInstances(): Mesh;
  81532. /**
  81533. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81534. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81535. * This should be used together with the simplification to avoid disappearing triangles.
  81536. * @param successCallback an optional success callback to be called after the optimization finished.
  81537. * @returns the current mesh
  81538. */
  81539. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81540. /**
  81541. * Serialize current mesh
  81542. * @param serializationObject defines the object which will receive the serialization data
  81543. */
  81544. serialize(serializationObject: any): void;
  81545. /** @hidden */
  81546. _syncGeometryWithMorphTargetManager(): void;
  81547. /** @hidden */
  81548. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81549. /**
  81550. * Returns a new Mesh object parsed from the source provided.
  81551. * @param parsedMesh is the source
  81552. * @param scene defines the hosting scene
  81553. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81554. * @returns a new Mesh
  81555. */
  81556. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81557. /**
  81558. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81559. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81560. * @param name defines the name of the mesh to create
  81561. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81562. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81563. * @param closePath creates a seam between the first and the last points of each path of the path array
  81564. * @param offset is taken in account only if the `pathArray` is containing a single path
  81565. * @param scene defines the hosting scene
  81566. * @param updatable defines if the mesh must be flagged as updatable
  81567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81568. * @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)
  81569. * @returns a new Mesh
  81570. */
  81571. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81572. /**
  81573. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81574. * @param name defines the name of the mesh to create
  81575. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81576. * @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
  81577. * @param scene defines the hosting scene
  81578. * @param updatable defines if the mesh must be flagged as updatable
  81579. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81580. * @returns a new Mesh
  81581. */
  81582. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81583. /**
  81584. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81585. * @param name defines the name of the mesh to create
  81586. * @param size sets the size (float) of each box side (default 1)
  81587. * @param scene defines the hosting scene
  81588. * @param updatable defines if the mesh must be flagged as updatable
  81589. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81590. * @returns a new Mesh
  81591. */
  81592. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81593. /**
  81594. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81595. * @param name defines the name of the mesh to create
  81596. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81597. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81598. * @param scene defines the hosting scene
  81599. * @param updatable defines if the mesh must be flagged as updatable
  81600. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81601. * @returns a new Mesh
  81602. */
  81603. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81604. /**
  81605. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81606. * @param name defines the name of the mesh to create
  81607. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81608. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81609. * @param scene defines the hosting scene
  81610. * @returns a new Mesh
  81611. */
  81612. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81613. /**
  81614. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81615. * @param name defines the name of the mesh to create
  81616. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81617. * @param diameterTop set the top cap diameter (floats, default 1)
  81618. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81619. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81620. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81621. * @param scene defines the hosting scene
  81622. * @param updatable defines if the mesh must be flagged as updatable
  81623. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81624. * @returns a new Mesh
  81625. */
  81626. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81627. /**
  81628. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81629. * @param name defines the name of the mesh to create
  81630. * @param diameter sets the diameter size (float) of the torus (default 1)
  81631. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81632. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81633. * @param scene defines the hosting scene
  81634. * @param updatable defines if the mesh must be flagged as updatable
  81635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81636. * @returns a new Mesh
  81637. */
  81638. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81639. /**
  81640. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81641. * @param name defines the name of the mesh to create
  81642. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81643. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81644. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81645. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81646. * @param p the number of windings on X axis (positive integers, default 2)
  81647. * @param q the number of windings on Y axis (positive integers, default 3)
  81648. * @param scene defines the hosting scene
  81649. * @param updatable defines if the mesh must be flagged as updatable
  81650. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81651. * @returns a new Mesh
  81652. */
  81653. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81654. /**
  81655. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81656. * @param name defines the name of the mesh to create
  81657. * @param points is an array successive Vector3
  81658. * @param scene defines the hosting scene
  81659. * @param updatable defines if the mesh must be flagged as updatable
  81660. * @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).
  81661. * @returns a new Mesh
  81662. */
  81663. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81664. /**
  81665. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81666. * @param name defines the name of the mesh to create
  81667. * @param points is an array successive Vector3
  81668. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81669. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81670. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81671. * @param scene defines the hosting scene
  81672. * @param updatable defines if the mesh must be flagged as updatable
  81673. * @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)
  81674. * @returns a new Mesh
  81675. */
  81676. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81677. /**
  81678. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81679. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81680. * 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.
  81681. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81682. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81683. * Remember you can only change the shape positions, not their number when updating a polygon.
  81684. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81685. * @param name defines the name of the mesh to create
  81686. * @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
  81687. * @param scene defines the hosting scene
  81688. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81689. * @param updatable defines if the mesh must be flagged as updatable
  81690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81691. * @param earcutInjection can be used to inject your own earcut reference
  81692. * @returns a new Mesh
  81693. */
  81694. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81695. /**
  81696. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81697. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81698. * @param name defines the name of the mesh to create
  81699. * @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
  81700. * @param depth defines the height of extrusion
  81701. * @param scene defines the hosting scene
  81702. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81703. * @param updatable defines if the mesh must be flagged as updatable
  81704. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81705. * @param earcutInjection can be used to inject your own earcut reference
  81706. * @returns a new Mesh
  81707. */
  81708. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81709. /**
  81710. * Creates an extruded shape mesh.
  81711. * 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
  81712. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81713. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81714. * @param name defines the name of the mesh to create
  81715. * @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
  81716. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81717. * @param scale is the value to scale the shape
  81718. * @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
  81719. * @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
  81720. * @param scene defines the hosting scene
  81721. * @param updatable defines if the mesh must be flagged as updatable
  81722. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81723. * @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)
  81724. * @returns a new Mesh
  81725. */
  81726. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81727. /**
  81728. * Creates an custom extruded shape mesh.
  81729. * The custom extrusion is a parametric shape.
  81730. * It has no predefined shape. Its final shape will depend on the input parameters.
  81731. * Please consider using the same method from the MeshBuilder class instead
  81732. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81733. * @param name defines the name of the mesh to create
  81734. * @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
  81735. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81736. * @param scaleFunction is a custom Javascript function called on each path point
  81737. * @param rotationFunction is a custom Javascript function called on each path point
  81738. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81739. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81740. * @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
  81741. * @param scene defines the hosting scene
  81742. * @param updatable defines if the mesh must be flagged as updatable
  81743. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81744. * @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)
  81745. * @returns a new Mesh
  81746. */
  81747. 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;
  81748. /**
  81749. * Creates lathe mesh.
  81750. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81751. * Please consider using the same method from the MeshBuilder class instead
  81752. * @param name defines the name of the mesh to create
  81753. * @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
  81754. * @param radius is the radius value of the lathe
  81755. * @param tessellation is the side number of the lathe.
  81756. * @param scene defines the hosting scene
  81757. * @param updatable defines if the mesh must be flagged as updatable
  81758. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81759. * @returns a new Mesh
  81760. */
  81761. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81762. /**
  81763. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81764. * @param name defines the name of the mesh to create
  81765. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81766. * @param scene defines the hosting scene
  81767. * @param updatable defines if the mesh must be flagged as updatable
  81768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81769. * @returns a new Mesh
  81770. */
  81771. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81772. /**
  81773. * Creates a ground mesh.
  81774. * Please consider using the same method from the MeshBuilder class instead
  81775. * @param name defines the name of the mesh to create
  81776. * @param width set the width of the ground
  81777. * @param height set the height of the ground
  81778. * @param subdivisions sets the number of subdivisions per side
  81779. * @param scene defines the hosting scene
  81780. * @param updatable defines if the mesh must be flagged as updatable
  81781. * @returns a new Mesh
  81782. */
  81783. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81784. /**
  81785. * Creates a tiled ground mesh.
  81786. * Please consider using the same method from the MeshBuilder class instead
  81787. * @param name defines the name of the mesh to create
  81788. * @param xmin set the ground minimum X coordinate
  81789. * @param zmin set the ground minimum Y coordinate
  81790. * @param xmax set the ground maximum X coordinate
  81791. * @param zmax set the ground maximum Z coordinate
  81792. * @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
  81793. * @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
  81794. * @param scene defines the hosting scene
  81795. * @param updatable defines if the mesh must be flagged as updatable
  81796. * @returns a new Mesh
  81797. */
  81798. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81799. w: number;
  81800. h: number;
  81801. }, precision: {
  81802. w: number;
  81803. h: number;
  81804. }, scene: Scene, updatable?: boolean): Mesh;
  81805. /**
  81806. * Creates a ground mesh from a height map.
  81807. * Please consider using the same method from the MeshBuilder class instead
  81808. * @see http://doc.babylonjs.com/babylon101/height_map
  81809. * @param name defines the name of the mesh to create
  81810. * @param url sets the URL of the height map image resource
  81811. * @param width set the ground width size
  81812. * @param height set the ground height size
  81813. * @param subdivisions sets the number of subdivision per side
  81814. * @param minHeight is the minimum altitude on the ground
  81815. * @param maxHeight is the maximum altitude on the ground
  81816. * @param scene defines the hosting scene
  81817. * @param updatable defines if the mesh must be flagged as updatable
  81818. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81819. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81820. * @returns a new Mesh
  81821. */
  81822. 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;
  81823. /**
  81824. * Creates a tube mesh.
  81825. * The tube is a parametric shape.
  81826. * It has no predefined shape. Its final shape will depend on the input parameters.
  81827. * Please consider using the same method from the MeshBuilder class instead
  81828. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81829. * @param name defines the name of the mesh to create
  81830. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81831. * @param radius sets the tube radius size
  81832. * @param tessellation is the number of sides on the tubular surface
  81833. * @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
  81834. * @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
  81835. * @param scene defines the hosting scene
  81836. * @param updatable defines if the mesh must be flagged as updatable
  81837. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81838. * @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)
  81839. * @returns a new Mesh
  81840. */
  81841. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81842. (i: number, distance: number): number;
  81843. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81844. /**
  81845. * Creates a polyhedron mesh.
  81846. * Please consider using the same method from the MeshBuilder class instead.
  81847. * * 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
  81848. * * The parameter `size` (positive float, default 1) sets the polygon size
  81849. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81850. * * 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`
  81851. * * 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
  81852. * * 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)`)
  81853. * * 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
  81854. * * 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
  81855. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81856. * * If you create a double-sided mesh, you can choose what parts of 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
  81857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81858. * @param name defines the name of the mesh to create
  81859. * @param options defines the options used to create the mesh
  81860. * @param scene defines the hosting scene
  81861. * @returns a new Mesh
  81862. */
  81863. static CreatePolyhedron(name: string, options: {
  81864. type?: number;
  81865. size?: number;
  81866. sizeX?: number;
  81867. sizeY?: number;
  81868. sizeZ?: number;
  81869. custom?: any;
  81870. faceUV?: Vector4[];
  81871. faceColors?: Color4[];
  81872. updatable?: boolean;
  81873. sideOrientation?: number;
  81874. }, scene: Scene): Mesh;
  81875. /**
  81876. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81877. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81878. * * 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`)
  81879. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81880. * * 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
  81881. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81882. * * If you create a double-sided mesh, you can choose what parts of 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
  81883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81884. * @param name defines the name of the mesh
  81885. * @param options defines the options used to create the mesh
  81886. * @param scene defines the hosting scene
  81887. * @returns a new Mesh
  81888. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81889. */
  81890. static CreateIcoSphere(name: string, options: {
  81891. radius?: number;
  81892. flat?: boolean;
  81893. subdivisions?: number;
  81894. sideOrientation?: number;
  81895. updatable?: boolean;
  81896. }, scene: Scene): Mesh;
  81897. /**
  81898. * Creates a decal mesh.
  81899. * Please consider using the same method from the MeshBuilder class instead.
  81900. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81901. * @param name defines the name of the mesh
  81902. * @param sourceMesh defines the mesh receiving the decal
  81903. * @param position sets the position of the decal in world coordinates
  81904. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81905. * @param size sets the decal scaling
  81906. * @param angle sets the angle to rotate the decal
  81907. * @returns a new Mesh
  81908. */
  81909. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81910. /**
  81911. * Prepare internal position array for software CPU skinning
  81912. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81913. */
  81914. setPositionsForCPUSkinning(): Float32Array;
  81915. /**
  81916. * Prepare internal normal array for software CPU skinning
  81917. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81918. */
  81919. setNormalsForCPUSkinning(): Float32Array;
  81920. /**
  81921. * Updates the vertex buffer by applying transformation from the bones
  81922. * @param skeleton defines the skeleton to apply to current mesh
  81923. * @returns the current mesh
  81924. */
  81925. applySkeleton(skeleton: Skeleton): Mesh;
  81926. /**
  81927. * 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
  81928. * @param meshes defines the list of meshes to scan
  81929. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81930. */
  81931. static MinMax(meshes: AbstractMesh[]): {
  81932. min: Vector3;
  81933. max: Vector3;
  81934. };
  81935. /**
  81936. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81937. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81938. * @returns a vector3
  81939. */
  81940. static Center(meshesOrMinMaxVector: {
  81941. min: Vector3;
  81942. max: Vector3;
  81943. } | AbstractMesh[]): Vector3;
  81944. /**
  81945. * Merge the array of meshes into a single mesh for performance reasons.
  81946. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81947. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81948. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81949. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81950. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81951. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81952. * @returns a new mesh
  81953. */
  81954. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81955. /** @hidden */
  81956. addInstance(instance: InstancedMesh): void;
  81957. /** @hidden */
  81958. removeInstance(instance: InstancedMesh): void;
  81959. }
  81960. }
  81961. declare module BABYLON {
  81962. /**
  81963. * Base class for the main features of a material in Babylon.js
  81964. */
  81965. export class Material implements IAnimatable {
  81966. /**
  81967. * Returns the triangle fill mode
  81968. */
  81969. static readonly TriangleFillMode: number;
  81970. /**
  81971. * Returns the wireframe mode
  81972. */
  81973. static readonly WireFrameFillMode: number;
  81974. /**
  81975. * Returns the point fill mode
  81976. */
  81977. static readonly PointFillMode: number;
  81978. /**
  81979. * Returns the point list draw mode
  81980. */
  81981. static readonly PointListDrawMode: number;
  81982. /**
  81983. * Returns the line list draw mode
  81984. */
  81985. static readonly LineListDrawMode: number;
  81986. /**
  81987. * Returns the line loop draw mode
  81988. */
  81989. static readonly LineLoopDrawMode: number;
  81990. /**
  81991. * Returns the line strip draw mode
  81992. */
  81993. static readonly LineStripDrawMode: number;
  81994. /**
  81995. * Returns the triangle strip draw mode
  81996. */
  81997. static readonly TriangleStripDrawMode: number;
  81998. /**
  81999. * Returns the triangle fan draw mode
  82000. */
  82001. static readonly TriangleFanDrawMode: number;
  82002. /**
  82003. * Stores the clock-wise side orientation
  82004. */
  82005. static readonly ClockWiseSideOrientation: number;
  82006. /**
  82007. * Stores the counter clock-wise side orientation
  82008. */
  82009. static readonly CounterClockWiseSideOrientation: number;
  82010. /**
  82011. * The dirty texture flag value
  82012. */
  82013. static readonly TextureDirtyFlag: number;
  82014. /**
  82015. * The dirty light flag value
  82016. */
  82017. static readonly LightDirtyFlag: number;
  82018. /**
  82019. * The dirty fresnel flag value
  82020. */
  82021. static readonly FresnelDirtyFlag: number;
  82022. /**
  82023. * The dirty attribute flag value
  82024. */
  82025. static readonly AttributesDirtyFlag: number;
  82026. /**
  82027. * The dirty misc flag value
  82028. */
  82029. static readonly MiscDirtyFlag: number;
  82030. /**
  82031. * The all dirty flag value
  82032. */
  82033. static readonly AllDirtyFlag: number;
  82034. /**
  82035. * The ID of the material
  82036. */
  82037. id: string;
  82038. /**
  82039. * Gets or sets the unique id of the material
  82040. */
  82041. uniqueId: number;
  82042. /**
  82043. * The name of the material
  82044. */
  82045. name: string;
  82046. /**
  82047. * Gets or sets user defined metadata
  82048. */
  82049. metadata: any;
  82050. /**
  82051. * For internal use only. Please do not use.
  82052. */
  82053. reservedDataStore: any;
  82054. /**
  82055. * Specifies if the ready state should be checked on each call
  82056. */
  82057. checkReadyOnEveryCall: boolean;
  82058. /**
  82059. * Specifies if the ready state should be checked once
  82060. */
  82061. checkReadyOnlyOnce: boolean;
  82062. /**
  82063. * The state of the material
  82064. */
  82065. state: string;
  82066. /**
  82067. * The alpha value of the material
  82068. */
  82069. protected _alpha: number;
  82070. /**
  82071. * List of inspectable custom properties (used by the Inspector)
  82072. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82073. */
  82074. inspectableCustomProperties: IInspectable[];
  82075. /**
  82076. * Sets the alpha value of the material
  82077. */
  82078. /**
  82079. * Gets the alpha value of the material
  82080. */
  82081. alpha: number;
  82082. /**
  82083. * Specifies if back face culling is enabled
  82084. */
  82085. protected _backFaceCulling: boolean;
  82086. /**
  82087. * Sets the back-face culling state
  82088. */
  82089. /**
  82090. * Gets the back-face culling state
  82091. */
  82092. backFaceCulling: boolean;
  82093. /**
  82094. * Stores the value for side orientation
  82095. */
  82096. sideOrientation: number;
  82097. /**
  82098. * Callback triggered when the material is compiled
  82099. */
  82100. onCompiled: Nullable<(effect: Effect) => void>;
  82101. /**
  82102. * Callback triggered when an error occurs
  82103. */
  82104. onError: Nullable<(effect: Effect, errors: string) => void>;
  82105. /**
  82106. * Callback triggered to get the render target textures
  82107. */
  82108. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82109. /**
  82110. * Gets a boolean indicating that current material needs to register RTT
  82111. */
  82112. readonly hasRenderTargetTextures: boolean;
  82113. /**
  82114. * Specifies if the material should be serialized
  82115. */
  82116. doNotSerialize: boolean;
  82117. /**
  82118. * @hidden
  82119. */
  82120. _storeEffectOnSubMeshes: boolean;
  82121. /**
  82122. * Stores the animations for the material
  82123. */
  82124. animations: Nullable<Array<Animation>>;
  82125. /**
  82126. * An event triggered when the material is disposed
  82127. */
  82128. onDisposeObservable: Observable<Material>;
  82129. /**
  82130. * An observer which watches for dispose events
  82131. */
  82132. private _onDisposeObserver;
  82133. private _onUnBindObservable;
  82134. /**
  82135. * Called during a dispose event
  82136. */
  82137. onDispose: () => void;
  82138. private _onBindObservable;
  82139. /**
  82140. * An event triggered when the material is bound
  82141. */
  82142. readonly onBindObservable: Observable<AbstractMesh>;
  82143. /**
  82144. * An observer which watches for bind events
  82145. */
  82146. private _onBindObserver;
  82147. /**
  82148. * Called during a bind event
  82149. */
  82150. onBind: (Mesh: AbstractMesh) => void;
  82151. /**
  82152. * An event triggered when the material is unbound
  82153. */
  82154. readonly onUnBindObservable: Observable<Material>;
  82155. /**
  82156. * Stores the value of the alpha mode
  82157. */
  82158. private _alphaMode;
  82159. /**
  82160. * Sets the value of the alpha mode.
  82161. *
  82162. * | Value | Type | Description |
  82163. * | --- | --- | --- |
  82164. * | 0 | ALPHA_DISABLE | |
  82165. * | 1 | ALPHA_ADD | |
  82166. * | 2 | ALPHA_COMBINE | |
  82167. * | 3 | ALPHA_SUBTRACT | |
  82168. * | 4 | ALPHA_MULTIPLY | |
  82169. * | 5 | ALPHA_MAXIMIZED | |
  82170. * | 6 | ALPHA_ONEONE | |
  82171. * | 7 | ALPHA_PREMULTIPLIED | |
  82172. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82173. * | 9 | ALPHA_INTERPOLATE | |
  82174. * | 10 | ALPHA_SCREENMODE | |
  82175. *
  82176. */
  82177. /**
  82178. * Gets the value of the alpha mode
  82179. */
  82180. alphaMode: number;
  82181. /**
  82182. * Stores the state of the need depth pre-pass value
  82183. */
  82184. private _needDepthPrePass;
  82185. /**
  82186. * Sets the need depth pre-pass value
  82187. */
  82188. /**
  82189. * Gets the depth pre-pass value
  82190. */
  82191. needDepthPrePass: boolean;
  82192. /**
  82193. * Specifies if depth writing should be disabled
  82194. */
  82195. disableDepthWrite: boolean;
  82196. /**
  82197. * Specifies if depth writing should be forced
  82198. */
  82199. forceDepthWrite: boolean;
  82200. /**
  82201. * Specifies if there should be a separate pass for culling
  82202. */
  82203. separateCullingPass: boolean;
  82204. /**
  82205. * Stores the state specifing if fog should be enabled
  82206. */
  82207. private _fogEnabled;
  82208. /**
  82209. * Sets the state for enabling fog
  82210. */
  82211. /**
  82212. * Gets the value of the fog enabled state
  82213. */
  82214. fogEnabled: boolean;
  82215. /**
  82216. * Stores the size of points
  82217. */
  82218. pointSize: number;
  82219. /**
  82220. * Stores the z offset value
  82221. */
  82222. zOffset: number;
  82223. /**
  82224. * Gets a value specifying if wireframe mode is enabled
  82225. */
  82226. /**
  82227. * Sets the state of wireframe mode
  82228. */
  82229. wireframe: boolean;
  82230. /**
  82231. * Gets the value specifying if point clouds are enabled
  82232. */
  82233. /**
  82234. * Sets the state of point cloud mode
  82235. */
  82236. pointsCloud: boolean;
  82237. /**
  82238. * Gets the material fill mode
  82239. */
  82240. /**
  82241. * Sets the material fill mode
  82242. */
  82243. fillMode: number;
  82244. /**
  82245. * @hidden
  82246. * Stores the effects for the material
  82247. */
  82248. _effect: Nullable<Effect>;
  82249. /**
  82250. * @hidden
  82251. * Specifies if the material was previously ready
  82252. */
  82253. _wasPreviouslyReady: boolean;
  82254. /**
  82255. * Specifies if uniform buffers should be used
  82256. */
  82257. private _useUBO;
  82258. /**
  82259. * Stores a reference to the scene
  82260. */
  82261. private _scene;
  82262. /**
  82263. * Stores the fill mode state
  82264. */
  82265. private _fillMode;
  82266. /**
  82267. * Specifies if the depth write state should be cached
  82268. */
  82269. private _cachedDepthWriteState;
  82270. /**
  82271. * Stores the uniform buffer
  82272. */
  82273. protected _uniformBuffer: UniformBuffer;
  82274. /** @hidden */
  82275. _indexInSceneMaterialArray: number;
  82276. /** @hidden */
  82277. meshMap: Nullable<{
  82278. [id: string]: AbstractMesh | undefined;
  82279. }>;
  82280. /**
  82281. * Creates a material instance
  82282. * @param name defines the name of the material
  82283. * @param scene defines the scene to reference
  82284. * @param doNotAdd specifies if the material should be added to the scene
  82285. */
  82286. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82287. /**
  82288. * Returns a string representation of the current material
  82289. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82290. * @returns a string with material information
  82291. */
  82292. toString(fullDetails?: boolean): string;
  82293. /**
  82294. * Gets the class name of the material
  82295. * @returns a string with the class name of the material
  82296. */
  82297. getClassName(): string;
  82298. /**
  82299. * Specifies if updates for the material been locked
  82300. */
  82301. readonly isFrozen: boolean;
  82302. /**
  82303. * Locks updates for the material
  82304. */
  82305. freeze(): void;
  82306. /**
  82307. * Unlocks updates for the material
  82308. */
  82309. unfreeze(): void;
  82310. /**
  82311. * Specifies if the material is ready to be used
  82312. * @param mesh defines the mesh to check
  82313. * @param useInstances specifies if instances should be used
  82314. * @returns a boolean indicating if the material is ready to be used
  82315. */
  82316. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82317. /**
  82318. * Specifies that the submesh is ready to be used
  82319. * @param mesh defines the mesh to check
  82320. * @param subMesh defines which submesh to check
  82321. * @param useInstances specifies that instances should be used
  82322. * @returns a boolean indicating that the submesh is ready or not
  82323. */
  82324. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82325. /**
  82326. * Returns the material effect
  82327. * @returns the effect associated with the material
  82328. */
  82329. getEffect(): Nullable<Effect>;
  82330. /**
  82331. * Returns the current scene
  82332. * @returns a Scene
  82333. */
  82334. getScene(): Scene;
  82335. /**
  82336. * Specifies if the material will require alpha blending
  82337. * @returns a boolean specifying if alpha blending is needed
  82338. */
  82339. needAlphaBlending(): boolean;
  82340. /**
  82341. * Specifies if the mesh will require alpha blending
  82342. * @param mesh defines the mesh to check
  82343. * @returns a boolean specifying if alpha blending is needed for the mesh
  82344. */
  82345. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82346. /**
  82347. * Specifies if this material should be rendered in alpha test mode
  82348. * @returns a boolean specifying if an alpha test is needed.
  82349. */
  82350. needAlphaTesting(): boolean;
  82351. /**
  82352. * Gets the texture used for the alpha test
  82353. * @returns the texture to use for alpha testing
  82354. */
  82355. getAlphaTestTexture(): Nullable<BaseTexture>;
  82356. /**
  82357. * Marks the material to indicate that it needs to be re-calculated
  82358. */
  82359. markDirty(): void;
  82360. /** @hidden */
  82361. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82362. /**
  82363. * Binds the material to the mesh
  82364. * @param world defines the world transformation matrix
  82365. * @param mesh defines the mesh to bind the material to
  82366. */
  82367. bind(world: Matrix, mesh?: Mesh): void;
  82368. /**
  82369. * Binds the submesh to the material
  82370. * @param world defines the world transformation matrix
  82371. * @param mesh defines the mesh containing the submesh
  82372. * @param subMesh defines the submesh to bind the material to
  82373. */
  82374. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82375. /**
  82376. * Binds the world matrix to the material
  82377. * @param world defines the world transformation matrix
  82378. */
  82379. bindOnlyWorldMatrix(world: Matrix): void;
  82380. /**
  82381. * Binds the scene's uniform buffer to the effect.
  82382. * @param effect defines the effect to bind to the scene uniform buffer
  82383. * @param sceneUbo defines the uniform buffer storing scene data
  82384. */
  82385. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82386. /**
  82387. * Binds the view matrix to the effect
  82388. * @param effect defines the effect to bind the view matrix to
  82389. */
  82390. bindView(effect: Effect): void;
  82391. /**
  82392. * Binds the view projection matrix to the effect
  82393. * @param effect defines the effect to bind the view projection matrix to
  82394. */
  82395. bindViewProjection(effect: Effect): void;
  82396. /**
  82397. * Specifies if material alpha testing should be turned on for the mesh
  82398. * @param mesh defines the mesh to check
  82399. */
  82400. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82401. /**
  82402. * Processes to execute after binding the material to a mesh
  82403. * @param mesh defines the rendered mesh
  82404. */
  82405. protected _afterBind(mesh?: Mesh): void;
  82406. /**
  82407. * Unbinds the material from the mesh
  82408. */
  82409. unbind(): void;
  82410. /**
  82411. * Gets the active textures from the material
  82412. * @returns an array of textures
  82413. */
  82414. getActiveTextures(): BaseTexture[];
  82415. /**
  82416. * Specifies if the material uses a texture
  82417. * @param texture defines the texture to check against the material
  82418. * @returns a boolean specifying if the material uses the texture
  82419. */
  82420. hasTexture(texture: BaseTexture): boolean;
  82421. /**
  82422. * Makes a duplicate of the material, and gives it a new name
  82423. * @param name defines the new name for the duplicated material
  82424. * @returns the cloned material
  82425. */
  82426. clone(name: string): Nullable<Material>;
  82427. /**
  82428. * Gets the meshes bound to the material
  82429. * @returns an array of meshes bound to the material
  82430. */
  82431. getBindedMeshes(): AbstractMesh[];
  82432. /**
  82433. * Force shader compilation
  82434. * @param mesh defines the mesh associated with this material
  82435. * @param onCompiled defines a function to execute once the material is compiled
  82436. * @param options defines the options to configure the compilation
  82437. */
  82438. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82439. clipPlane: boolean;
  82440. }>): void;
  82441. /**
  82442. * Force shader compilation
  82443. * @param mesh defines the mesh that will use this material
  82444. * @param options defines additional options for compiling the shaders
  82445. * @returns a promise that resolves when the compilation completes
  82446. */
  82447. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82448. clipPlane: boolean;
  82449. }>): Promise<void>;
  82450. private static readonly _ImageProcessingDirtyCallBack;
  82451. private static readonly _TextureDirtyCallBack;
  82452. private static readonly _FresnelDirtyCallBack;
  82453. private static readonly _MiscDirtyCallBack;
  82454. private static readonly _LightsDirtyCallBack;
  82455. private static readonly _AttributeDirtyCallBack;
  82456. private static _FresnelAndMiscDirtyCallBack;
  82457. private static _TextureAndMiscDirtyCallBack;
  82458. private static readonly _DirtyCallbackArray;
  82459. private static readonly _RunDirtyCallBacks;
  82460. /**
  82461. * Marks a define in the material to indicate that it needs to be re-computed
  82462. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82463. */
  82464. markAsDirty(flag: number): void;
  82465. /**
  82466. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82467. * @param func defines a function which checks material defines against the submeshes
  82468. */
  82469. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82470. /**
  82471. * Indicates that image processing needs to be re-calculated for all submeshes
  82472. */
  82473. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82474. /**
  82475. * Indicates that textures need to be re-calculated for all submeshes
  82476. */
  82477. protected _markAllSubMeshesAsTexturesDirty(): void;
  82478. /**
  82479. * Indicates that fresnel needs to be re-calculated for all submeshes
  82480. */
  82481. protected _markAllSubMeshesAsFresnelDirty(): void;
  82482. /**
  82483. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82484. */
  82485. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82486. /**
  82487. * Indicates that lights need to be re-calculated for all submeshes
  82488. */
  82489. protected _markAllSubMeshesAsLightsDirty(): void;
  82490. /**
  82491. * Indicates that attributes need to be re-calculated for all submeshes
  82492. */
  82493. protected _markAllSubMeshesAsAttributesDirty(): void;
  82494. /**
  82495. * Indicates that misc needs to be re-calculated for all submeshes
  82496. */
  82497. protected _markAllSubMeshesAsMiscDirty(): void;
  82498. /**
  82499. * Indicates that textures and misc need to be re-calculated for all submeshes
  82500. */
  82501. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82502. /**
  82503. * Disposes the material
  82504. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82505. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82506. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82507. */
  82508. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82509. /** @hidden */
  82510. private releaseVertexArrayObject;
  82511. /**
  82512. * Serializes this material
  82513. * @returns the serialized material object
  82514. */
  82515. serialize(): any;
  82516. /**
  82517. * Creates a material from parsed material data
  82518. * @param parsedMaterial defines parsed material data
  82519. * @param scene defines the hosting scene
  82520. * @param rootUrl defines the root URL to use to load textures
  82521. * @returns a new material
  82522. */
  82523. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82524. }
  82525. }
  82526. declare module BABYLON {
  82527. /**
  82528. * Base class for submeshes
  82529. */
  82530. export class BaseSubMesh {
  82531. /** @hidden */
  82532. _materialDefines: Nullable<MaterialDefines>;
  82533. /** @hidden */
  82534. _materialEffect: Nullable<Effect>;
  82535. /**
  82536. * Gets associated effect
  82537. */
  82538. readonly effect: Nullable<Effect>;
  82539. /**
  82540. * Sets associated effect (effect used to render this submesh)
  82541. * @param effect defines the effect to associate with
  82542. * @param defines defines the set of defines used to compile this effect
  82543. */
  82544. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82545. }
  82546. /**
  82547. * Defines a subdivision inside a mesh
  82548. */
  82549. export class SubMesh extends BaseSubMesh implements ICullable {
  82550. /** the material index to use */
  82551. materialIndex: number;
  82552. /** vertex index start */
  82553. verticesStart: number;
  82554. /** vertices count */
  82555. verticesCount: number;
  82556. /** index start */
  82557. indexStart: number;
  82558. /** indices count */
  82559. indexCount: number;
  82560. /** @hidden */
  82561. _linesIndexCount: number;
  82562. private _mesh;
  82563. private _renderingMesh;
  82564. private _boundingInfo;
  82565. private _linesIndexBuffer;
  82566. /** @hidden */
  82567. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82568. /** @hidden */
  82569. _trianglePlanes: Plane[];
  82570. /** @hidden */
  82571. _lastColliderTransformMatrix: Nullable<Matrix>;
  82572. /** @hidden */
  82573. _renderId: number;
  82574. /** @hidden */
  82575. _alphaIndex: number;
  82576. /** @hidden */
  82577. _distanceToCamera: number;
  82578. /** @hidden */
  82579. _id: number;
  82580. private _currentMaterial;
  82581. /**
  82582. * Add a new submesh to a mesh
  82583. * @param materialIndex defines the material index to use
  82584. * @param verticesStart defines vertex index start
  82585. * @param verticesCount defines vertices count
  82586. * @param indexStart defines index start
  82587. * @param indexCount defines indices count
  82588. * @param mesh defines the parent mesh
  82589. * @param renderingMesh defines an optional rendering mesh
  82590. * @param createBoundingBox defines if bounding box should be created for this submesh
  82591. * @returns the new submesh
  82592. */
  82593. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82594. /**
  82595. * Creates a new submesh
  82596. * @param materialIndex defines the material index to use
  82597. * @param verticesStart defines vertex index start
  82598. * @param verticesCount defines vertices count
  82599. * @param indexStart defines index start
  82600. * @param indexCount defines indices count
  82601. * @param mesh defines the parent mesh
  82602. * @param renderingMesh defines an optional rendering mesh
  82603. * @param createBoundingBox defines if bounding box should be created for this submesh
  82604. */
  82605. constructor(
  82606. /** the material index to use */
  82607. materialIndex: number,
  82608. /** vertex index start */
  82609. verticesStart: number,
  82610. /** vertices count */
  82611. verticesCount: number,
  82612. /** index start */
  82613. indexStart: number,
  82614. /** indices count */
  82615. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82616. /**
  82617. * Returns true if this submesh covers the entire parent mesh
  82618. * @ignorenaming
  82619. */
  82620. readonly IsGlobal: boolean;
  82621. /**
  82622. * Returns the submesh BoudingInfo object
  82623. * @returns current bounding info (or mesh's one if the submesh is global)
  82624. */
  82625. getBoundingInfo(): BoundingInfo;
  82626. /**
  82627. * Sets the submesh BoundingInfo
  82628. * @param boundingInfo defines the new bounding info to use
  82629. * @returns the SubMesh
  82630. */
  82631. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82632. /**
  82633. * Returns the mesh of the current submesh
  82634. * @return the parent mesh
  82635. */
  82636. getMesh(): AbstractMesh;
  82637. /**
  82638. * Returns the rendering mesh of the submesh
  82639. * @returns the rendering mesh (could be different from parent mesh)
  82640. */
  82641. getRenderingMesh(): Mesh;
  82642. /**
  82643. * Returns the submesh material
  82644. * @returns null or the current material
  82645. */
  82646. getMaterial(): Nullable<Material>;
  82647. /**
  82648. * Sets a new updated BoundingInfo object to the submesh
  82649. * @param data defines an optional position array to use to determine the bounding info
  82650. * @returns the SubMesh
  82651. */
  82652. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82653. /** @hidden */
  82654. _checkCollision(collider: Collider): boolean;
  82655. /**
  82656. * Updates the submesh BoundingInfo
  82657. * @param world defines the world matrix to use to update the bounding info
  82658. * @returns the submesh
  82659. */
  82660. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82661. /**
  82662. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82663. * @param frustumPlanes defines the frustum planes
  82664. * @returns true if the submesh is intersecting with the frustum
  82665. */
  82666. isInFrustum(frustumPlanes: Plane[]): boolean;
  82667. /**
  82668. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82669. * @param frustumPlanes defines the frustum planes
  82670. * @returns true if the submesh is inside the frustum
  82671. */
  82672. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82673. /**
  82674. * Renders the submesh
  82675. * @param enableAlphaMode defines if alpha needs to be used
  82676. * @returns the submesh
  82677. */
  82678. render(enableAlphaMode: boolean): SubMesh;
  82679. /**
  82680. * @hidden
  82681. */
  82682. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82683. /**
  82684. * Checks if the submesh intersects with a ray
  82685. * @param ray defines the ray to test
  82686. * @returns true is the passed ray intersects the submesh bounding box
  82687. */
  82688. canIntersects(ray: Ray): boolean;
  82689. /**
  82690. * Intersects current submesh with a ray
  82691. * @param ray defines the ray to test
  82692. * @param positions defines mesh's positions array
  82693. * @param indices defines mesh's indices array
  82694. * @param fastCheck defines if only bounding info should be used
  82695. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82696. * @returns intersection info or null if no intersection
  82697. */
  82698. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82699. /** @hidden */
  82700. private _intersectLines;
  82701. /** @hidden */
  82702. private _intersectUnIndexedLines;
  82703. /** @hidden */
  82704. private _intersectTriangles;
  82705. /** @hidden */
  82706. private _intersectUnIndexedTriangles;
  82707. /** @hidden */
  82708. _rebuild(): void;
  82709. /**
  82710. * Creates a new submesh from the passed mesh
  82711. * @param newMesh defines the new hosting mesh
  82712. * @param newRenderingMesh defines an optional rendering mesh
  82713. * @returns the new submesh
  82714. */
  82715. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82716. /**
  82717. * Release associated resources
  82718. */
  82719. dispose(): void;
  82720. /**
  82721. * Gets the class name
  82722. * @returns the string "SubMesh".
  82723. */
  82724. getClassName(): string;
  82725. /**
  82726. * Creates a new submesh from indices data
  82727. * @param materialIndex the index of the main mesh material
  82728. * @param startIndex the index where to start the copy in the mesh indices array
  82729. * @param indexCount the number of indices to copy then from the startIndex
  82730. * @param mesh the main mesh to create the submesh from
  82731. * @param renderingMesh the optional rendering mesh
  82732. * @returns a new submesh
  82733. */
  82734. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82735. }
  82736. }
  82737. declare module BABYLON {
  82738. /**
  82739. * Class used to store geometry data (vertex buffers + index buffer)
  82740. */
  82741. export class Geometry implements IGetSetVerticesData {
  82742. /**
  82743. * Gets or sets the ID of the geometry
  82744. */
  82745. id: string;
  82746. /**
  82747. * Gets or sets the unique ID of the geometry
  82748. */
  82749. uniqueId: number;
  82750. /**
  82751. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82752. */
  82753. delayLoadState: number;
  82754. /**
  82755. * Gets the file containing the data to load when running in delay load state
  82756. */
  82757. delayLoadingFile: Nullable<string>;
  82758. /**
  82759. * Callback called when the geometry is updated
  82760. */
  82761. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82762. private _scene;
  82763. private _engine;
  82764. private _meshes;
  82765. private _totalVertices;
  82766. /** @hidden */
  82767. _indices: IndicesArray;
  82768. /** @hidden */
  82769. _vertexBuffers: {
  82770. [key: string]: VertexBuffer;
  82771. };
  82772. private _isDisposed;
  82773. private _extend;
  82774. private _boundingBias;
  82775. /** @hidden */
  82776. _delayInfo: Array<string>;
  82777. private _indexBuffer;
  82778. private _indexBufferIsUpdatable;
  82779. /** @hidden */
  82780. _boundingInfo: Nullable<BoundingInfo>;
  82781. /** @hidden */
  82782. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82783. /** @hidden */
  82784. _softwareSkinningFrameId: number;
  82785. private _vertexArrayObjects;
  82786. private _updatable;
  82787. /** @hidden */
  82788. _positions: Nullable<Vector3[]>;
  82789. /**
  82790. * 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
  82791. */
  82792. /**
  82793. * 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
  82794. */
  82795. boundingBias: Vector2;
  82796. /**
  82797. * Static function used to attach a new empty geometry to a mesh
  82798. * @param mesh defines the mesh to attach the geometry to
  82799. * @returns the new Geometry
  82800. */
  82801. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82802. /**
  82803. * Creates a new geometry
  82804. * @param id defines the unique ID
  82805. * @param scene defines the hosting scene
  82806. * @param vertexData defines the VertexData used to get geometry data
  82807. * @param updatable defines if geometry must be updatable (false by default)
  82808. * @param mesh defines the mesh that will be associated with the geometry
  82809. */
  82810. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82811. /**
  82812. * Gets the current extend of the geometry
  82813. */
  82814. readonly extend: {
  82815. minimum: Vector3;
  82816. maximum: Vector3;
  82817. };
  82818. /**
  82819. * Gets the hosting scene
  82820. * @returns the hosting Scene
  82821. */
  82822. getScene(): Scene;
  82823. /**
  82824. * Gets the hosting engine
  82825. * @returns the hosting Engine
  82826. */
  82827. getEngine(): Engine;
  82828. /**
  82829. * Defines if the geometry is ready to use
  82830. * @returns true if the geometry is ready to be used
  82831. */
  82832. isReady(): boolean;
  82833. /**
  82834. * Gets a value indicating that the geometry should not be serialized
  82835. */
  82836. readonly doNotSerialize: boolean;
  82837. /** @hidden */
  82838. _rebuild(): void;
  82839. /**
  82840. * Affects all geometry data in one call
  82841. * @param vertexData defines the geometry data
  82842. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82843. */
  82844. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82845. /**
  82846. * Set specific vertex data
  82847. * @param kind defines the data kind (Position, normal, etc...)
  82848. * @param data defines the vertex data to use
  82849. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82850. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82851. */
  82852. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82853. /**
  82854. * Removes a specific vertex data
  82855. * @param kind defines the data kind (Position, normal, etc...)
  82856. */
  82857. removeVerticesData(kind: string): void;
  82858. /**
  82859. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82860. * @param buffer defines the vertex buffer to use
  82861. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82862. */
  82863. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82864. /**
  82865. * Update a specific vertex buffer
  82866. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82867. * It will do nothing if the buffer is not updatable
  82868. * @param kind defines the data kind (Position, normal, etc...)
  82869. * @param data defines the data to use
  82870. * @param offset defines the offset in the target buffer where to store the data
  82871. * @param useBytes set to true if the offset is in bytes
  82872. */
  82873. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82874. /**
  82875. * Update a specific vertex buffer
  82876. * This function will create a new buffer if the current one is not updatable
  82877. * @param kind defines the data kind (Position, normal, etc...)
  82878. * @param data defines the data to use
  82879. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82880. */
  82881. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82882. private _updateBoundingInfo;
  82883. /** @hidden */
  82884. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82885. /**
  82886. * Gets total number of vertices
  82887. * @returns the total number of vertices
  82888. */
  82889. getTotalVertices(): number;
  82890. /**
  82891. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82892. * @param kind defines the data kind (Position, normal, etc...)
  82893. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82894. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82895. * @returns a float array containing vertex data
  82896. */
  82897. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82898. /**
  82899. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82900. * @param kind defines the data kind (Position, normal, etc...)
  82901. * @returns true if the vertex buffer with the specified kind is updatable
  82902. */
  82903. isVertexBufferUpdatable(kind: string): boolean;
  82904. /**
  82905. * Gets a specific vertex buffer
  82906. * @param kind defines the data kind (Position, normal, etc...)
  82907. * @returns a VertexBuffer
  82908. */
  82909. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82910. /**
  82911. * Returns all vertex buffers
  82912. * @return an object holding all vertex buffers indexed by kind
  82913. */
  82914. getVertexBuffers(): Nullable<{
  82915. [key: string]: VertexBuffer;
  82916. }>;
  82917. /**
  82918. * Gets a boolean indicating if specific vertex buffer is present
  82919. * @param kind defines the data kind (Position, normal, etc...)
  82920. * @returns true if data is present
  82921. */
  82922. isVerticesDataPresent(kind: string): boolean;
  82923. /**
  82924. * Gets a list of all attached data kinds (Position, normal, etc...)
  82925. * @returns a list of string containing all kinds
  82926. */
  82927. getVerticesDataKinds(): string[];
  82928. /**
  82929. * Update index buffer
  82930. * @param indices defines the indices to store in the index buffer
  82931. * @param offset defines the offset in the target buffer where to store the data
  82932. * @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)
  82933. */
  82934. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82935. /**
  82936. * Creates a new index buffer
  82937. * @param indices defines the indices to store in the index buffer
  82938. * @param totalVertices defines the total number of vertices (could be null)
  82939. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82940. */
  82941. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82942. /**
  82943. * Return the total number of indices
  82944. * @returns the total number of indices
  82945. */
  82946. getTotalIndices(): number;
  82947. /**
  82948. * Gets the index buffer array
  82949. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82950. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82951. * @returns the index buffer array
  82952. */
  82953. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82954. /**
  82955. * Gets the index buffer
  82956. * @return the index buffer
  82957. */
  82958. getIndexBuffer(): Nullable<DataBuffer>;
  82959. /** @hidden */
  82960. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82961. /**
  82962. * Release the associated resources for a specific mesh
  82963. * @param mesh defines the source mesh
  82964. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82965. */
  82966. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82967. /**
  82968. * Apply current geometry to a given mesh
  82969. * @param mesh defines the mesh to apply geometry to
  82970. */
  82971. applyToMesh(mesh: Mesh): void;
  82972. private _updateExtend;
  82973. private _applyToMesh;
  82974. private notifyUpdate;
  82975. /**
  82976. * Load the geometry if it was flagged as delay loaded
  82977. * @param scene defines the hosting scene
  82978. * @param onLoaded defines a callback called when the geometry is loaded
  82979. */
  82980. load(scene: Scene, onLoaded?: () => void): void;
  82981. private _queueLoad;
  82982. /**
  82983. * Invert the geometry to move from a right handed system to a left handed one.
  82984. */
  82985. toLeftHanded(): void;
  82986. /** @hidden */
  82987. _resetPointsArrayCache(): void;
  82988. /** @hidden */
  82989. _generatePointsArray(): boolean;
  82990. /**
  82991. * Gets a value indicating if the geometry is disposed
  82992. * @returns true if the geometry was disposed
  82993. */
  82994. isDisposed(): boolean;
  82995. private _disposeVertexArrayObjects;
  82996. /**
  82997. * Free all associated resources
  82998. */
  82999. dispose(): void;
  83000. /**
  83001. * Clone the current geometry into a new geometry
  83002. * @param id defines the unique ID of the new geometry
  83003. * @returns a new geometry object
  83004. */
  83005. copy(id: string): Geometry;
  83006. /**
  83007. * Serialize the current geometry info (and not the vertices data) into a JSON object
  83008. * @return a JSON representation of the current geometry data (without the vertices data)
  83009. */
  83010. serialize(): any;
  83011. private toNumberArray;
  83012. /**
  83013. * Serialize all vertices data into a JSON oject
  83014. * @returns a JSON representation of the current geometry data
  83015. */
  83016. serializeVerticeData(): any;
  83017. /**
  83018. * Extracts a clone of a mesh geometry
  83019. * @param mesh defines the source mesh
  83020. * @param id defines the unique ID of the new geometry object
  83021. * @returns the new geometry object
  83022. */
  83023. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  83024. /**
  83025. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  83026. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  83027. * Be aware Math.random() could cause collisions, but:
  83028. * "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"
  83029. * @returns a string containing a new GUID
  83030. */
  83031. static RandomId(): string;
  83032. /** @hidden */
  83033. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  83034. private static _CleanMatricesWeights;
  83035. /**
  83036. * Create a new geometry from persisted data (Using .babylon file format)
  83037. * @param parsedVertexData defines the persisted data
  83038. * @param scene defines the hosting scene
  83039. * @param rootUrl defines the root url to use to load assets (like delayed data)
  83040. * @returns the new geometry object
  83041. */
  83042. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  83043. }
  83044. }
  83045. declare module BABYLON {
  83046. /**
  83047. * Define an interface for all classes that will get and set the data on vertices
  83048. */
  83049. export interface IGetSetVerticesData {
  83050. /**
  83051. * Gets a boolean indicating if specific vertex data is present
  83052. * @param kind defines the vertex data kind to use
  83053. * @returns true is data kind is present
  83054. */
  83055. isVerticesDataPresent(kind: string): boolean;
  83056. /**
  83057. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  83058. * @param kind defines the data kind (Position, normal, etc...)
  83059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  83060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83061. * @returns a float array containing vertex data
  83062. */
  83063. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  83064. /**
  83065. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83066. * @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.
  83067. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83068. * @returns the indices array or an empty array if the mesh has no geometry
  83069. */
  83070. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  83071. /**
  83072. * Set specific vertex data
  83073. * @param kind defines the data kind (Position, normal, etc...)
  83074. * @param data defines the vertex data to use
  83075. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  83076. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  83077. */
  83078. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  83079. /**
  83080. * Update a specific associated vertex buffer
  83081. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83082. * - VertexBuffer.PositionKind
  83083. * - VertexBuffer.UVKind
  83084. * - VertexBuffer.UV2Kind
  83085. * - VertexBuffer.UV3Kind
  83086. * - VertexBuffer.UV4Kind
  83087. * - VertexBuffer.UV5Kind
  83088. * - VertexBuffer.UV6Kind
  83089. * - VertexBuffer.ColorKind
  83090. * - VertexBuffer.MatricesIndicesKind
  83091. * - VertexBuffer.MatricesIndicesExtraKind
  83092. * - VertexBuffer.MatricesWeightsKind
  83093. * - VertexBuffer.MatricesWeightsExtraKind
  83094. * @param data defines the data source
  83095. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83096. * @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)
  83097. */
  83098. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  83099. /**
  83100. * Creates a new index buffer
  83101. * @param indices defines the indices to store in the index buffer
  83102. * @param totalVertices defines the total number of vertices (could be null)
  83103. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83104. */
  83105. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  83106. }
  83107. /**
  83108. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83109. */
  83110. export class VertexData {
  83111. /**
  83112. * Mesh side orientation : usually the external or front surface
  83113. */
  83114. static readonly FRONTSIDE: number;
  83115. /**
  83116. * Mesh side orientation : usually the internal or back surface
  83117. */
  83118. static readonly BACKSIDE: number;
  83119. /**
  83120. * Mesh side orientation : both internal and external or front and back surfaces
  83121. */
  83122. static readonly DOUBLESIDE: number;
  83123. /**
  83124. * Mesh side orientation : by default, `FRONTSIDE`
  83125. */
  83126. static readonly DEFAULTSIDE: number;
  83127. /**
  83128. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83129. */
  83130. positions: Nullable<FloatArray>;
  83131. /**
  83132. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83133. */
  83134. normals: Nullable<FloatArray>;
  83135. /**
  83136. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83137. */
  83138. tangents: Nullable<FloatArray>;
  83139. /**
  83140. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83141. */
  83142. uvs: Nullable<FloatArray>;
  83143. /**
  83144. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83145. */
  83146. uvs2: Nullable<FloatArray>;
  83147. /**
  83148. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83149. */
  83150. uvs3: Nullable<FloatArray>;
  83151. /**
  83152. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83153. */
  83154. uvs4: Nullable<FloatArray>;
  83155. /**
  83156. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83157. */
  83158. uvs5: Nullable<FloatArray>;
  83159. /**
  83160. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83161. */
  83162. uvs6: Nullable<FloatArray>;
  83163. /**
  83164. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83165. */
  83166. colors: Nullable<FloatArray>;
  83167. /**
  83168. * 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).
  83169. */
  83170. matricesIndices: Nullable<FloatArray>;
  83171. /**
  83172. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83173. */
  83174. matricesWeights: Nullable<FloatArray>;
  83175. /**
  83176. * An array extending the number of possible indices
  83177. */
  83178. matricesIndicesExtra: Nullable<FloatArray>;
  83179. /**
  83180. * An array extending the number of possible weights when the number of indices is extended
  83181. */
  83182. matricesWeightsExtra: Nullable<FloatArray>;
  83183. /**
  83184. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83185. */
  83186. indices: Nullable<IndicesArray>;
  83187. /**
  83188. * Uses the passed data array to set the set the values for the specified kind of data
  83189. * @param data a linear array of floating numbers
  83190. * @param kind the type of data that is being set, eg positions, colors etc
  83191. */
  83192. set(data: FloatArray, kind: string): void;
  83193. /**
  83194. * Associates the vertexData to the passed Mesh.
  83195. * Sets it as updatable or not (default `false`)
  83196. * @param mesh the mesh the vertexData is applied to
  83197. * @param updatable when used and having the value true allows new data to update the vertexData
  83198. * @returns the VertexData
  83199. */
  83200. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83201. /**
  83202. * Associates the vertexData to the passed Geometry.
  83203. * Sets it as updatable or not (default `false`)
  83204. * @param geometry the geometry the vertexData is applied to
  83205. * @param updatable when used and having the value true allows new data to update the vertexData
  83206. * @returns VertexData
  83207. */
  83208. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83209. /**
  83210. * Updates the associated mesh
  83211. * @param mesh the mesh to be updated
  83212. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83213. * @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
  83214. * @returns VertexData
  83215. */
  83216. updateMesh(mesh: Mesh): VertexData;
  83217. /**
  83218. * Updates the associated geometry
  83219. * @param geometry the geometry to be updated
  83220. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83221. * @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
  83222. * @returns VertexData.
  83223. */
  83224. updateGeometry(geometry: Geometry): VertexData;
  83225. private _applyTo;
  83226. private _update;
  83227. /**
  83228. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83229. * @param matrix the transforming matrix
  83230. * @returns the VertexData
  83231. */
  83232. transform(matrix: Matrix): VertexData;
  83233. /**
  83234. * Merges the passed VertexData into the current one
  83235. * @param other the VertexData to be merged into the current one
  83236. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83237. * @returns the modified VertexData
  83238. */
  83239. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83240. private _mergeElement;
  83241. private _validate;
  83242. /**
  83243. * Serializes the VertexData
  83244. * @returns a serialized object
  83245. */
  83246. serialize(): any;
  83247. /**
  83248. * Extracts the vertexData from a mesh
  83249. * @param mesh the mesh from which to extract the VertexData
  83250. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83251. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83252. * @returns the object VertexData associated to the passed mesh
  83253. */
  83254. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83255. /**
  83256. * Extracts the vertexData from the geometry
  83257. * @param geometry the geometry from which to extract the VertexData
  83258. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83259. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83260. * @returns the object VertexData associated to the passed mesh
  83261. */
  83262. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83263. private static _ExtractFrom;
  83264. /**
  83265. * Creates the VertexData for a Ribbon
  83266. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83267. * * pathArray array of paths, each of which an array of successive Vector3
  83268. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83269. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83270. * * 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
  83271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83272. * * 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)
  83273. * * 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)
  83274. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83275. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83276. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83277. * @returns the VertexData of the ribbon
  83278. */
  83279. static CreateRibbon(options: {
  83280. pathArray: Vector3[][];
  83281. closeArray?: boolean;
  83282. closePath?: boolean;
  83283. offset?: number;
  83284. sideOrientation?: number;
  83285. frontUVs?: Vector4;
  83286. backUVs?: Vector4;
  83287. invertUV?: boolean;
  83288. uvs?: Vector2[];
  83289. colors?: Color4[];
  83290. }): VertexData;
  83291. /**
  83292. * Creates the VertexData for a box
  83293. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83294. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83295. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83296. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83297. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83298. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83299. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83301. * * 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)
  83302. * * 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)
  83303. * @returns the VertexData of the box
  83304. */
  83305. static CreateBox(options: {
  83306. size?: number;
  83307. width?: number;
  83308. height?: number;
  83309. depth?: number;
  83310. faceUV?: Vector4[];
  83311. faceColors?: Color4[];
  83312. sideOrientation?: number;
  83313. frontUVs?: Vector4;
  83314. backUVs?: Vector4;
  83315. }): VertexData;
  83316. /**
  83317. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83318. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83319. * * segments sets the number of horizontal strips optional, default 32
  83320. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83321. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83322. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83323. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83324. * * 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
  83325. * * 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
  83326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83327. * * 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)
  83328. * * 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)
  83329. * @returns the VertexData of the ellipsoid
  83330. */
  83331. static CreateSphere(options: {
  83332. segments?: number;
  83333. diameter?: number;
  83334. diameterX?: number;
  83335. diameterY?: number;
  83336. diameterZ?: number;
  83337. arc?: number;
  83338. slice?: number;
  83339. sideOrientation?: number;
  83340. frontUVs?: Vector4;
  83341. backUVs?: Vector4;
  83342. }): VertexData;
  83343. /**
  83344. * Creates the VertexData for a cylinder, cone or prism
  83345. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83346. * * height sets the height (y direction) of the cylinder, optional, default 2
  83347. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83348. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83349. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83350. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83351. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83352. * * 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
  83353. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83354. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83355. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83356. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83357. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83358. * * 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)
  83359. * * 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)
  83360. * @returns the VertexData of the cylinder, cone or prism
  83361. */
  83362. static CreateCylinder(options: {
  83363. height?: number;
  83364. diameterTop?: number;
  83365. diameterBottom?: number;
  83366. diameter?: number;
  83367. tessellation?: number;
  83368. subdivisions?: number;
  83369. arc?: number;
  83370. faceColors?: Color4[];
  83371. faceUV?: Vector4[];
  83372. hasRings?: boolean;
  83373. enclose?: boolean;
  83374. sideOrientation?: number;
  83375. frontUVs?: Vector4;
  83376. backUVs?: Vector4;
  83377. }): VertexData;
  83378. /**
  83379. * Creates the VertexData for a torus
  83380. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83381. * * diameter the diameter of the torus, optional default 1
  83382. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83383. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83385. * * 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)
  83386. * * 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)
  83387. * @returns the VertexData of the torus
  83388. */
  83389. static CreateTorus(options: {
  83390. diameter?: number;
  83391. thickness?: number;
  83392. tessellation?: number;
  83393. sideOrientation?: number;
  83394. frontUVs?: Vector4;
  83395. backUVs?: Vector4;
  83396. }): VertexData;
  83397. /**
  83398. * Creates the VertexData of the LineSystem
  83399. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83400. * - lines an array of lines, each line being an array of successive Vector3
  83401. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83402. * @returns the VertexData of the LineSystem
  83403. */
  83404. static CreateLineSystem(options: {
  83405. lines: Vector3[][];
  83406. colors?: Nullable<Color4[][]>;
  83407. }): VertexData;
  83408. /**
  83409. * Create the VertexData for a DashedLines
  83410. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83411. * - points an array successive Vector3
  83412. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83413. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83414. * - dashNb the intended total number of dashes, optional, default 200
  83415. * @returns the VertexData for the DashedLines
  83416. */
  83417. static CreateDashedLines(options: {
  83418. points: Vector3[];
  83419. dashSize?: number;
  83420. gapSize?: number;
  83421. dashNb?: number;
  83422. }): VertexData;
  83423. /**
  83424. * Creates the VertexData for a Ground
  83425. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83426. * - width the width (x direction) of the ground, optional, default 1
  83427. * - height the height (z direction) of the ground, optional, default 1
  83428. * - subdivisions the number of subdivisions per side, optional, default 1
  83429. * @returns the VertexData of the Ground
  83430. */
  83431. static CreateGround(options: {
  83432. width?: number;
  83433. height?: number;
  83434. subdivisions?: number;
  83435. subdivisionsX?: number;
  83436. subdivisionsY?: number;
  83437. }): VertexData;
  83438. /**
  83439. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83440. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83441. * * xmin the ground minimum X coordinate, optional, default -1
  83442. * * zmin the ground minimum Z coordinate, optional, default -1
  83443. * * xmax the ground maximum X coordinate, optional, default 1
  83444. * * zmax the ground maximum Z coordinate, optional, default 1
  83445. * * 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}
  83446. * * 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}
  83447. * @returns the VertexData of the TiledGround
  83448. */
  83449. static CreateTiledGround(options: {
  83450. xmin: number;
  83451. zmin: number;
  83452. xmax: number;
  83453. zmax: number;
  83454. subdivisions?: {
  83455. w: number;
  83456. h: number;
  83457. };
  83458. precision?: {
  83459. w: number;
  83460. h: number;
  83461. };
  83462. }): VertexData;
  83463. /**
  83464. * Creates the VertexData of the Ground designed from a heightmap
  83465. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83466. * * width the width (x direction) of the ground
  83467. * * height the height (z direction) of the ground
  83468. * * subdivisions the number of subdivisions per side
  83469. * * minHeight the minimum altitude on the ground, optional, default 0
  83470. * * maxHeight the maximum altitude on the ground, optional default 1
  83471. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83472. * * buffer the array holding the image color data
  83473. * * bufferWidth the width of image
  83474. * * bufferHeight the height of image
  83475. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83476. * @returns the VertexData of the Ground designed from a heightmap
  83477. */
  83478. static CreateGroundFromHeightMap(options: {
  83479. width: number;
  83480. height: number;
  83481. subdivisions: number;
  83482. minHeight: number;
  83483. maxHeight: number;
  83484. colorFilter: Color3;
  83485. buffer: Uint8Array;
  83486. bufferWidth: number;
  83487. bufferHeight: number;
  83488. alphaFilter: number;
  83489. }): VertexData;
  83490. /**
  83491. * Creates the VertexData for a Plane
  83492. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83493. * * size sets the width and height of the plane to the value of size, optional default 1
  83494. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83495. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83497. * * 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)
  83498. * * 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)
  83499. * @returns the VertexData of the box
  83500. */
  83501. static CreatePlane(options: {
  83502. size?: number;
  83503. width?: number;
  83504. height?: number;
  83505. sideOrientation?: number;
  83506. frontUVs?: Vector4;
  83507. backUVs?: Vector4;
  83508. }): VertexData;
  83509. /**
  83510. * Creates the VertexData of the Disc or regular Polygon
  83511. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83512. * * radius the radius of the disc, optional default 0.5
  83513. * * tessellation the number of polygon sides, optional, default 64
  83514. * * 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
  83515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83516. * * 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)
  83517. * * 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)
  83518. * @returns the VertexData of the box
  83519. */
  83520. static CreateDisc(options: {
  83521. radius?: number;
  83522. tessellation?: number;
  83523. arc?: number;
  83524. sideOrientation?: number;
  83525. frontUVs?: Vector4;
  83526. backUVs?: Vector4;
  83527. }): VertexData;
  83528. /**
  83529. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83530. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83531. * @param polygon a mesh built from polygonTriangulation.build()
  83532. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83533. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83534. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83535. * @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)
  83536. * @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)
  83537. * @returns the VertexData of the Polygon
  83538. */
  83539. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83540. /**
  83541. * Creates the VertexData of the IcoSphere
  83542. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83543. * * radius the radius of the IcoSphere, optional default 1
  83544. * * radiusX allows stretching in the x direction, optional, default radius
  83545. * * radiusY allows stretching in the y direction, optional, default radius
  83546. * * radiusZ allows stretching in the z direction, optional, default radius
  83547. * * flat when true creates a flat shaded mesh, optional, default true
  83548. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83550. * * 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)
  83551. * * 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)
  83552. * @returns the VertexData of the IcoSphere
  83553. */
  83554. static CreateIcoSphere(options: {
  83555. radius?: number;
  83556. radiusX?: number;
  83557. radiusY?: number;
  83558. radiusZ?: number;
  83559. flat?: boolean;
  83560. subdivisions?: number;
  83561. sideOrientation?: number;
  83562. frontUVs?: Vector4;
  83563. backUVs?: Vector4;
  83564. }): VertexData;
  83565. /**
  83566. * Creates the VertexData for a Polyhedron
  83567. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83568. * * type provided types are:
  83569. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83570. * * 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)
  83571. * * size the size of the IcoSphere, optional default 1
  83572. * * sizeX allows stretching in the x direction, optional, default size
  83573. * * sizeY allows stretching in the y direction, optional, default size
  83574. * * sizeZ allows stretching in the z direction, optional, default size
  83575. * * 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
  83576. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83577. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83578. * * flat when true creates a flat shaded mesh, optional, default true
  83579. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83581. * * 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)
  83582. * * 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)
  83583. * @returns the VertexData of the Polyhedron
  83584. */
  83585. static CreatePolyhedron(options: {
  83586. type?: number;
  83587. size?: number;
  83588. sizeX?: number;
  83589. sizeY?: number;
  83590. sizeZ?: number;
  83591. custom?: any;
  83592. faceUV?: Vector4[];
  83593. faceColors?: Color4[];
  83594. flat?: boolean;
  83595. sideOrientation?: number;
  83596. frontUVs?: Vector4;
  83597. backUVs?: Vector4;
  83598. }): VertexData;
  83599. /**
  83600. * Creates the VertexData for a TorusKnot
  83601. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83602. * * radius the radius of the torus knot, optional, default 2
  83603. * * tube the thickness of the tube, optional, default 0.5
  83604. * * radialSegments the number of sides on each tube segments, optional, default 32
  83605. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83606. * * p the number of windings around the z axis, optional, default 2
  83607. * * q the number of windings around the x axis, optional, default 3
  83608. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83609. * * 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)
  83610. * * 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)
  83611. * @returns the VertexData of the Torus Knot
  83612. */
  83613. static CreateTorusKnot(options: {
  83614. radius?: number;
  83615. tube?: number;
  83616. radialSegments?: number;
  83617. tubularSegments?: number;
  83618. p?: number;
  83619. q?: number;
  83620. sideOrientation?: number;
  83621. frontUVs?: Vector4;
  83622. backUVs?: Vector4;
  83623. }): VertexData;
  83624. /**
  83625. * Compute normals for given positions and indices
  83626. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83627. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83628. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83629. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83630. * * facetNormals : optional array of facet normals (vector3)
  83631. * * facetPositions : optional array of facet positions (vector3)
  83632. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83633. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83634. * * bInfo : optional bounding info, required for facetPartitioning computation
  83635. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83636. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83637. * * useRightHandedSystem: optional boolean to for right handed system computation
  83638. * * depthSort : optional boolean to enable the facet depth sort computation
  83639. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83640. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83641. */
  83642. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83643. facetNormals?: any;
  83644. facetPositions?: any;
  83645. facetPartitioning?: any;
  83646. ratio?: number;
  83647. bInfo?: any;
  83648. bbSize?: Vector3;
  83649. subDiv?: any;
  83650. useRightHandedSystem?: boolean;
  83651. depthSort?: boolean;
  83652. distanceTo?: Vector3;
  83653. depthSortedFacets?: any;
  83654. }): void;
  83655. /** @hidden */
  83656. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83657. /**
  83658. * Applies VertexData created from the imported parameters to the geometry
  83659. * @param parsedVertexData the parsed data from an imported file
  83660. * @param geometry the geometry to apply the VertexData to
  83661. */
  83662. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83663. }
  83664. }
  83665. declare module BABYLON {
  83666. /**
  83667. * Class containing static functions to help procedurally build meshes
  83668. */
  83669. export class DiscBuilder {
  83670. /**
  83671. * Creates a plane polygonal mesh. By default, this is a disc
  83672. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83673. * * 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
  83674. * * 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
  83675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83678. * @param name defines the name of the mesh
  83679. * @param options defines the options used to create the mesh
  83680. * @param scene defines the hosting scene
  83681. * @returns the plane polygonal mesh
  83682. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83683. */
  83684. static CreateDisc(name: string, options: {
  83685. radius?: number;
  83686. tessellation?: number;
  83687. arc?: number;
  83688. updatable?: boolean;
  83689. sideOrientation?: number;
  83690. frontUVs?: Vector4;
  83691. backUVs?: Vector4;
  83692. }, scene?: Nullable<Scene>): Mesh;
  83693. }
  83694. }
  83695. declare module BABYLON {
  83696. /**
  83697. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83698. *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.
  83699. * The SPS is also a particle system. It provides some methods to manage the particles.
  83700. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83701. *
  83702. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83703. */
  83704. export class SolidParticleSystem implements IDisposable {
  83705. /**
  83706. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83707. * Example : var p = SPS.particles[i];
  83708. */
  83709. particles: SolidParticle[];
  83710. /**
  83711. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83712. */
  83713. nbParticles: number;
  83714. /**
  83715. * If the particles must ever face the camera (default false). Useful for planar particles.
  83716. */
  83717. billboard: boolean;
  83718. /**
  83719. * Recompute normals when adding a shape
  83720. */
  83721. recomputeNormals: boolean;
  83722. /**
  83723. * This a counter ofr your own usage. It's not set by any SPS functions.
  83724. */
  83725. counter: number;
  83726. /**
  83727. * The SPS name. This name is also given to the underlying mesh.
  83728. */
  83729. name: string;
  83730. /**
  83731. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83732. */
  83733. mesh: Mesh;
  83734. /**
  83735. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83736. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83737. */
  83738. vars: any;
  83739. /**
  83740. * This array is populated when the SPS is set as 'pickable'.
  83741. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83742. * Each element of this array is an object `{idx: int, faceId: int}`.
  83743. * `idx` is the picked particle index in the `SPS.particles` array
  83744. * `faceId` is the picked face index counted within this particle.
  83745. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83746. */
  83747. pickedParticles: {
  83748. idx: number;
  83749. faceId: number;
  83750. }[];
  83751. /**
  83752. * This array is populated when `enableDepthSort` is set to true.
  83753. * Each element of this array is an instance of the class DepthSortedParticle.
  83754. */
  83755. depthSortedParticles: DepthSortedParticle[];
  83756. /**
  83757. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83758. * @hidden
  83759. */
  83760. _bSphereOnly: boolean;
  83761. /**
  83762. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83763. * @hidden
  83764. */
  83765. _bSphereRadiusFactor: number;
  83766. private _scene;
  83767. private _positions;
  83768. private _indices;
  83769. private _normals;
  83770. private _colors;
  83771. private _uvs;
  83772. private _indices32;
  83773. private _positions32;
  83774. private _normals32;
  83775. private _fixedNormal32;
  83776. private _colors32;
  83777. private _uvs32;
  83778. private _index;
  83779. private _updatable;
  83780. private _pickable;
  83781. private _isVisibilityBoxLocked;
  83782. private _alwaysVisible;
  83783. private _depthSort;
  83784. private _shapeCounter;
  83785. private _copy;
  83786. private _color;
  83787. private _computeParticleColor;
  83788. private _computeParticleTexture;
  83789. private _computeParticleRotation;
  83790. private _computeParticleVertex;
  83791. private _computeBoundingBox;
  83792. private _depthSortParticles;
  83793. private _camera;
  83794. private _mustUnrotateFixedNormals;
  83795. private _particlesIntersect;
  83796. private _needs32Bits;
  83797. /**
  83798. * Creates a SPS (Solid Particle System) object.
  83799. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83800. * @param scene (Scene) is the scene in which the SPS is added.
  83801. * @param options defines the options of the sps e.g.
  83802. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83803. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83804. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83805. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83806. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83807. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83808. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83809. */
  83810. constructor(name: string, scene: Scene, options?: {
  83811. updatable?: boolean;
  83812. isPickable?: boolean;
  83813. enableDepthSort?: boolean;
  83814. particleIntersection?: boolean;
  83815. boundingSphereOnly?: boolean;
  83816. bSphereRadiusFactor?: number;
  83817. });
  83818. /**
  83819. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83820. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83821. * @returns the created mesh
  83822. */
  83823. buildMesh(): Mesh;
  83824. /**
  83825. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83826. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83827. * Thus the particles generated from `digest()` have their property `position` set yet.
  83828. * @param mesh ( Mesh ) is the mesh to be digested
  83829. * @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
  83830. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83831. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83832. * @returns the current SPS
  83833. */
  83834. digest(mesh: Mesh, options?: {
  83835. facetNb?: number;
  83836. number?: number;
  83837. delta?: number;
  83838. }): SolidParticleSystem;
  83839. private _unrotateFixedNormals;
  83840. private _resetCopy;
  83841. private _meshBuilder;
  83842. private _posToShape;
  83843. private _uvsToShapeUV;
  83844. private _addParticle;
  83845. /**
  83846. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83847. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83848. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83849. * @param nb (positive integer) the number of particles to be created from this model
  83850. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83851. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83852. * @returns the number of shapes in the system
  83853. */
  83854. addShape(mesh: Mesh, nb: number, options?: {
  83855. positionFunction?: any;
  83856. vertexFunction?: any;
  83857. }): number;
  83858. private _rebuildParticle;
  83859. /**
  83860. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83861. * @returns the SPS.
  83862. */
  83863. rebuildMesh(): SolidParticleSystem;
  83864. /**
  83865. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83866. * This method calls `updateParticle()` for each particle of the SPS.
  83867. * For an animated SPS, it is usually called within the render loop.
  83868. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83869. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83870. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83871. * @returns the SPS.
  83872. */
  83873. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83874. /**
  83875. * Disposes the SPS.
  83876. */
  83877. dispose(): void;
  83878. /**
  83879. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83880. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83881. * @returns the SPS.
  83882. */
  83883. refreshVisibleSize(): SolidParticleSystem;
  83884. /**
  83885. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83886. * @param size the size (float) of the visibility box
  83887. * note : this doesn't lock the SPS mesh bounding box.
  83888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83889. */
  83890. setVisibilityBox(size: number): void;
  83891. /**
  83892. * Gets whether the SPS as always visible or not
  83893. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83894. */
  83895. /**
  83896. * Sets the SPS as always visible or not
  83897. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83898. */
  83899. isAlwaysVisible: boolean;
  83900. /**
  83901. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83902. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83903. */
  83904. /**
  83905. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83906. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83907. */
  83908. isVisibilityBoxLocked: boolean;
  83909. /**
  83910. * Tells to `setParticles()` to compute the particle rotations or not.
  83911. * Default value : true. The SPS is faster when it's set to false.
  83912. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83913. */
  83914. /**
  83915. * Gets if `setParticles()` computes the particle rotations or not.
  83916. * Default value : true. The SPS is faster when it's set to false.
  83917. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83918. */
  83919. computeParticleRotation: boolean;
  83920. /**
  83921. * Tells to `setParticles()` to compute the particle colors or not.
  83922. * Default value : true. The SPS is faster when it's set to false.
  83923. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83924. */
  83925. /**
  83926. * Gets if `setParticles()` computes the particle colors or not.
  83927. * Default value : true. The SPS is faster when it's set to false.
  83928. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83929. */
  83930. computeParticleColor: boolean;
  83931. /**
  83932. * Gets if `setParticles()` computes the particle textures or not.
  83933. * Default value : true. The SPS is faster when it's set to false.
  83934. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83935. */
  83936. computeParticleTexture: boolean;
  83937. /**
  83938. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83939. * Default value : false. The SPS is faster when it's set to false.
  83940. * Note : the particle custom vertex positions aren't stored values.
  83941. */
  83942. /**
  83943. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83944. * Default value : false. The SPS is faster when it's set to false.
  83945. * Note : the particle custom vertex positions aren't stored values.
  83946. */
  83947. computeParticleVertex: boolean;
  83948. /**
  83949. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83950. */
  83951. /**
  83952. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83953. */
  83954. computeBoundingBox: boolean;
  83955. /**
  83956. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83957. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83958. * Default : `true`
  83959. */
  83960. /**
  83961. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83962. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83963. * Default : `true`
  83964. */
  83965. depthSortParticles: boolean;
  83966. /**
  83967. * This function does nothing. It may be overwritten to set all the particle first values.
  83968. * The SPS doesn't call this function, you may have to call it by your own.
  83969. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83970. */
  83971. initParticles(): void;
  83972. /**
  83973. * This function does nothing. It may be overwritten to recycle a particle.
  83974. * The SPS doesn't call this function, you may have to call it by your own.
  83975. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83976. * @param particle The particle to recycle
  83977. * @returns the recycled particle
  83978. */
  83979. recycleParticle(particle: SolidParticle): SolidParticle;
  83980. /**
  83981. * Updates a particle : this function should be overwritten by the user.
  83982. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83983. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83984. * @example : just set a particle position or velocity and recycle conditions
  83985. * @param particle The particle to update
  83986. * @returns the updated particle
  83987. */
  83988. updateParticle(particle: SolidParticle): SolidParticle;
  83989. /**
  83990. * Updates a vertex of a particle : it can be overwritten by the user.
  83991. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83992. * @param particle the current particle
  83993. * @param vertex the current index of the current particle
  83994. * @param pt the index of the current vertex in the particle shape
  83995. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83996. * @example : just set a vertex particle position
  83997. * @returns the updated vertex
  83998. */
  83999. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  84000. /**
  84001. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  84002. * This does nothing and may be overwritten by the user.
  84003. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  84004. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  84005. * @param update the boolean update value actually passed to setParticles()
  84006. */
  84007. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  84008. /**
  84009. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  84010. * This will be passed three parameters.
  84011. * This does nothing and may be overwritten by the user.
  84012. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  84013. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  84014. * @param update the boolean update value actually passed to setParticles()
  84015. */
  84016. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  84017. }
  84018. }
  84019. declare module BABYLON {
  84020. /**
  84021. * Represents one particle of a solid particle system.
  84022. */
  84023. export class SolidParticle {
  84024. /**
  84025. * particle global index
  84026. */
  84027. idx: number;
  84028. /**
  84029. * The color of the particle
  84030. */
  84031. color: Nullable<Color4>;
  84032. /**
  84033. * The world space position of the particle.
  84034. */
  84035. position: Vector3;
  84036. /**
  84037. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  84038. */
  84039. rotation: Vector3;
  84040. /**
  84041. * The world space rotation quaternion of the particle.
  84042. */
  84043. rotationQuaternion: Nullable<Quaternion>;
  84044. /**
  84045. * The scaling of the particle.
  84046. */
  84047. scaling: Vector3;
  84048. /**
  84049. * The uvs of the particle.
  84050. */
  84051. uvs: Vector4;
  84052. /**
  84053. * The current speed of the particle.
  84054. */
  84055. velocity: Vector3;
  84056. /**
  84057. * The pivot point in the particle local space.
  84058. */
  84059. pivot: Vector3;
  84060. /**
  84061. * Must the particle be translated from its pivot point in its local space ?
  84062. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  84063. * Default : false
  84064. */
  84065. translateFromPivot: boolean;
  84066. /**
  84067. * Is the particle active or not ?
  84068. */
  84069. alive: boolean;
  84070. /**
  84071. * Is the particle visible or not ?
  84072. */
  84073. isVisible: boolean;
  84074. /**
  84075. * Index of this particle in the global "positions" array (Internal use)
  84076. * @hidden
  84077. */
  84078. _pos: number;
  84079. /**
  84080. * @hidden Index of this particle in the global "indices" array (Internal use)
  84081. */
  84082. _ind: number;
  84083. /**
  84084. * @hidden ModelShape of this particle (Internal use)
  84085. */
  84086. _model: ModelShape;
  84087. /**
  84088. * ModelShape id of this particle
  84089. */
  84090. shapeId: number;
  84091. /**
  84092. * Index of the particle in its shape id (Internal use)
  84093. */
  84094. idxInShape: number;
  84095. /**
  84096. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  84097. */
  84098. _modelBoundingInfo: BoundingInfo;
  84099. /**
  84100. * @hidden Particle BoundingInfo object (Internal use)
  84101. */
  84102. _boundingInfo: BoundingInfo;
  84103. /**
  84104. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  84105. */
  84106. _sps: SolidParticleSystem;
  84107. /**
  84108. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84109. */
  84110. _stillInvisible: boolean;
  84111. /**
  84112. * @hidden Last computed particle rotation matrix
  84113. */
  84114. _rotationMatrix: number[];
  84115. /**
  84116. * Parent particle Id, if any.
  84117. * Default null.
  84118. */
  84119. parentId: Nullable<number>;
  84120. /**
  84121. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84122. * The possible values are :
  84123. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84124. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84125. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84126. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84127. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84128. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84129. * */
  84130. cullingStrategy: number;
  84131. /**
  84132. * @hidden Internal global position in the SPS.
  84133. */
  84134. _globalPosition: Vector3;
  84135. /**
  84136. * Creates a Solid Particle object.
  84137. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84138. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84139. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84140. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84141. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84142. * @param shapeId (integer) is the model shape identifier in the SPS.
  84143. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84144. * @param sps defines the sps it is associated to
  84145. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84146. */
  84147. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84148. /**
  84149. * Legacy support, changed scale to scaling
  84150. */
  84151. /**
  84152. * Legacy support, changed scale to scaling
  84153. */
  84154. scale: Vector3;
  84155. /**
  84156. * Legacy support, changed quaternion to rotationQuaternion
  84157. */
  84158. /**
  84159. * Legacy support, changed quaternion to rotationQuaternion
  84160. */
  84161. quaternion: Nullable<Quaternion>;
  84162. /**
  84163. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84164. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84165. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84166. * @returns true if it intersects
  84167. */
  84168. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84169. /**
  84170. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84171. * A particle is in the frustum if its bounding box intersects the frustum
  84172. * @param frustumPlanes defines the frustum to test
  84173. * @returns true if the particle is in the frustum planes
  84174. */
  84175. isInFrustum(frustumPlanes: Plane[]): boolean;
  84176. /**
  84177. * get the rotation matrix of the particle
  84178. * @hidden
  84179. */
  84180. getRotationMatrix(m: Matrix): void;
  84181. }
  84182. /**
  84183. * Represents the shape of the model used by one particle of a solid particle system.
  84184. * SPS internal tool, don't use it manually.
  84185. */
  84186. export class ModelShape {
  84187. /**
  84188. * The shape id
  84189. * @hidden
  84190. */
  84191. shapeID: number;
  84192. /**
  84193. * flat array of model positions (internal use)
  84194. * @hidden
  84195. */
  84196. _shape: Vector3[];
  84197. /**
  84198. * flat array of model UVs (internal use)
  84199. * @hidden
  84200. */
  84201. _shapeUV: number[];
  84202. /**
  84203. * length of the shape in the model indices array (internal use)
  84204. * @hidden
  84205. */
  84206. _indicesLength: number;
  84207. /**
  84208. * Custom position function (internal use)
  84209. * @hidden
  84210. */
  84211. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84212. /**
  84213. * Custom vertex function (internal use)
  84214. * @hidden
  84215. */
  84216. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84217. /**
  84218. * 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.
  84219. * SPS internal tool, don't use it manually.
  84220. * @hidden
  84221. */
  84222. 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>);
  84223. }
  84224. /**
  84225. * Represents a Depth Sorted Particle in the solid particle system.
  84226. */
  84227. export class DepthSortedParticle {
  84228. /**
  84229. * Index of the particle in the "indices" array
  84230. */
  84231. ind: number;
  84232. /**
  84233. * Length of the particle shape in the "indices" array
  84234. */
  84235. indicesLength: number;
  84236. /**
  84237. * Squared distance from the particle to the camera
  84238. */
  84239. sqDistance: number;
  84240. }
  84241. }
  84242. declare module BABYLON {
  84243. /**
  84244. * @hidden
  84245. */
  84246. export class _MeshCollisionData {
  84247. _checkCollisions: boolean;
  84248. _collisionMask: number;
  84249. _collisionGroup: number;
  84250. _collider: Nullable<Collider>;
  84251. _oldPositionForCollisions: Vector3;
  84252. _diffPositionForCollisions: Vector3;
  84253. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  84254. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  84255. }
  84256. }
  84257. declare module BABYLON {
  84258. /** @hidden */
  84259. class _FacetDataStorage {
  84260. facetPositions: Vector3[];
  84261. facetNormals: Vector3[];
  84262. facetPartitioning: number[][];
  84263. facetNb: number;
  84264. partitioningSubdivisions: number;
  84265. partitioningBBoxRatio: number;
  84266. facetDataEnabled: boolean;
  84267. facetParameters: any;
  84268. bbSize: Vector3;
  84269. subDiv: {
  84270. max: number;
  84271. X: number;
  84272. Y: number;
  84273. Z: number;
  84274. };
  84275. facetDepthSort: boolean;
  84276. facetDepthSortEnabled: boolean;
  84277. depthSortedIndices: IndicesArray;
  84278. depthSortedFacets: {
  84279. ind: number;
  84280. sqDistance: number;
  84281. }[];
  84282. facetDepthSortFunction: (f1: {
  84283. ind: number;
  84284. sqDistance: number;
  84285. }, f2: {
  84286. ind: number;
  84287. sqDistance: number;
  84288. }) => number;
  84289. facetDepthSortFrom: Vector3;
  84290. facetDepthSortOrigin: Vector3;
  84291. invertedMatrix: Matrix;
  84292. }
  84293. /**
  84294. * @hidden
  84295. **/
  84296. class _InternalAbstractMeshDataInfo {
  84297. _hasVertexAlpha: boolean;
  84298. _useVertexColors: boolean;
  84299. _numBoneInfluencers: number;
  84300. _applyFog: boolean;
  84301. _receiveShadows: boolean;
  84302. _facetData: _FacetDataStorage;
  84303. _visibility: number;
  84304. _skeleton: Nullable<Skeleton>;
  84305. _layerMask: number;
  84306. _computeBonesUsingShaders: boolean;
  84307. _isActive: boolean;
  84308. _onlyForInstances: boolean;
  84309. _isActiveIntermediate: boolean;
  84310. _onlyForInstancesIntermediate: boolean;
  84311. }
  84312. /**
  84313. * Class used to store all common mesh properties
  84314. */
  84315. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84316. /** No occlusion */
  84317. static OCCLUSION_TYPE_NONE: number;
  84318. /** Occlusion set to optimisitic */
  84319. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84320. /** Occlusion set to strict */
  84321. static OCCLUSION_TYPE_STRICT: number;
  84322. /** Use an accurante occlusion algorithm */
  84323. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84324. /** Use a conservative occlusion algorithm */
  84325. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84326. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84327. * Test order :
  84328. * Is the bounding sphere outside the frustum ?
  84329. * If not, are the bounding box vertices outside the frustum ?
  84330. * It not, then the cullable object is in the frustum.
  84331. */
  84332. static readonly CULLINGSTRATEGY_STANDARD: number;
  84333. /** Culling strategy : Bounding Sphere Only.
  84334. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84335. * It's also less accurate than the standard because some not visible objects can still be selected.
  84336. * Test : is the bounding sphere outside the frustum ?
  84337. * If not, then the cullable object is in the frustum.
  84338. */
  84339. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84340. /** Culling strategy : Optimistic Inclusion.
  84341. * This in an inclusion test first, then the standard exclusion test.
  84342. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84343. * 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.
  84344. * Anyway, it's as accurate as the standard strategy.
  84345. * Test :
  84346. * Is the cullable object bounding sphere center in the frustum ?
  84347. * If not, apply the default culling strategy.
  84348. */
  84349. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84350. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84351. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84352. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84353. * 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.
  84354. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84355. * Test :
  84356. * Is the cullable object bounding sphere center in the frustum ?
  84357. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84358. */
  84359. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84360. /**
  84361. * No billboard
  84362. */
  84363. static readonly BILLBOARDMODE_NONE: number;
  84364. /** Billboard on X axis */
  84365. static readonly BILLBOARDMODE_X: number;
  84366. /** Billboard on Y axis */
  84367. static readonly BILLBOARDMODE_Y: number;
  84368. /** Billboard on Z axis */
  84369. static readonly BILLBOARDMODE_Z: number;
  84370. /** Billboard on all axes */
  84371. static readonly BILLBOARDMODE_ALL: number;
  84372. /** @hidden */
  84373. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  84374. /**
  84375. * The culling strategy to use to check whether the mesh must be rendered or not.
  84376. * This value can be changed at any time and will be used on the next render mesh selection.
  84377. * The possible values are :
  84378. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84379. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84380. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84381. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84382. * Please read each static variable documentation to get details about the culling process.
  84383. * */
  84384. cullingStrategy: number;
  84385. /**
  84386. * Gets the number of facets in the mesh
  84387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84388. */
  84389. readonly facetNb: number;
  84390. /**
  84391. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84393. */
  84394. partitioningSubdivisions: number;
  84395. /**
  84396. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84397. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84399. */
  84400. partitioningBBoxRatio: number;
  84401. /**
  84402. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84403. * Works only for updatable meshes.
  84404. * Doesn't work with multi-materials
  84405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84406. */
  84407. mustDepthSortFacets: boolean;
  84408. /**
  84409. * The location (Vector3) where the facet depth sort must be computed from.
  84410. * By default, the active camera position.
  84411. * Used only when facet depth sort is enabled
  84412. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84413. */
  84414. facetDepthSortFrom: Vector3;
  84415. /**
  84416. * gets a boolean indicating if facetData is enabled
  84417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84418. */
  84419. readonly isFacetDataEnabled: boolean;
  84420. /** @hidden */
  84421. _updateNonUniformScalingState(value: boolean): boolean;
  84422. /**
  84423. * An event triggered when this mesh collides with another one
  84424. */
  84425. onCollideObservable: Observable<AbstractMesh>;
  84426. /** Set a function to call when this mesh collides with another one */
  84427. onCollide: () => void;
  84428. /**
  84429. * An event triggered when the collision's position changes
  84430. */
  84431. onCollisionPositionChangeObservable: Observable<Vector3>;
  84432. /** Set a function to call when the collision's position changes */
  84433. onCollisionPositionChange: () => void;
  84434. /**
  84435. * An event triggered when material is changed
  84436. */
  84437. onMaterialChangedObservable: Observable<AbstractMesh>;
  84438. /**
  84439. * Gets or sets the orientation for POV movement & rotation
  84440. */
  84441. definedFacingForward: boolean;
  84442. /** @hidden */
  84443. _occlusionQuery: Nullable<WebGLQuery>;
  84444. /** @hidden */
  84445. _renderingGroup: Nullable<RenderingGroup>;
  84446. /**
  84447. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84448. */
  84449. /**
  84450. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84451. */
  84452. visibility: number;
  84453. /** Gets or sets the alpha index used to sort transparent meshes
  84454. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84455. */
  84456. alphaIndex: number;
  84457. /**
  84458. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84459. */
  84460. isVisible: boolean;
  84461. /**
  84462. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84463. */
  84464. isPickable: boolean;
  84465. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84466. showSubMeshesBoundingBox: boolean;
  84467. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84468. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84469. */
  84470. isBlocker: boolean;
  84471. /**
  84472. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84473. */
  84474. enablePointerMoveEvents: boolean;
  84475. /**
  84476. * Specifies the rendering group id for this mesh (0 by default)
  84477. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84478. */
  84479. renderingGroupId: number;
  84480. private _material;
  84481. /** Gets or sets current material */
  84482. material: Nullable<Material>;
  84483. /**
  84484. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84485. * @see http://doc.babylonjs.com/babylon101/shadows
  84486. */
  84487. receiveShadows: boolean;
  84488. /** Defines color to use when rendering outline */
  84489. outlineColor: Color3;
  84490. /** Define width to use when rendering outline */
  84491. outlineWidth: number;
  84492. /** Defines color to use when rendering overlay */
  84493. overlayColor: Color3;
  84494. /** Defines alpha to use when rendering overlay */
  84495. overlayAlpha: number;
  84496. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84497. hasVertexAlpha: boolean;
  84498. /** 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) */
  84499. useVertexColors: boolean;
  84500. /**
  84501. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84502. */
  84503. computeBonesUsingShaders: boolean;
  84504. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84505. numBoneInfluencers: number;
  84506. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84507. applyFog: boolean;
  84508. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84509. useOctreeForRenderingSelection: boolean;
  84510. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84511. useOctreeForPicking: boolean;
  84512. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84513. useOctreeForCollisions: boolean;
  84514. /**
  84515. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84516. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84517. */
  84518. layerMask: number;
  84519. /**
  84520. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84521. */
  84522. alwaysSelectAsActiveMesh: boolean;
  84523. /**
  84524. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84525. */
  84526. doNotSyncBoundingInfo: boolean;
  84527. /**
  84528. * Gets or sets the current action manager
  84529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84530. */
  84531. actionManager: Nullable<AbstractActionManager>;
  84532. private _meshCollisionData;
  84533. /**
  84534. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84535. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84536. */
  84537. ellipsoid: Vector3;
  84538. /**
  84539. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84540. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84541. */
  84542. ellipsoidOffset: Vector3;
  84543. /**
  84544. * Gets or sets a collision mask used to mask collisions (default is -1).
  84545. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84546. */
  84547. collisionMask: number;
  84548. /**
  84549. * Gets or sets the current collision group mask (-1 by default).
  84550. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84551. */
  84552. collisionGroup: number;
  84553. /**
  84554. * Defines edge width used when edgesRenderer is enabled
  84555. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84556. */
  84557. edgesWidth: number;
  84558. /**
  84559. * Defines edge color used when edgesRenderer is enabled
  84560. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84561. */
  84562. edgesColor: Color4;
  84563. /** @hidden */
  84564. _edgesRenderer: Nullable<IEdgesRenderer>;
  84565. /** @hidden */
  84566. _masterMesh: Nullable<AbstractMesh>;
  84567. /** @hidden */
  84568. _boundingInfo: Nullable<BoundingInfo>;
  84569. /** @hidden */
  84570. _renderId: number;
  84571. /**
  84572. * Gets or sets the list of subMeshes
  84573. * @see http://doc.babylonjs.com/how_to/multi_materials
  84574. */
  84575. subMeshes: SubMesh[];
  84576. /** @hidden */
  84577. _intersectionsInProgress: AbstractMesh[];
  84578. /** @hidden */
  84579. _unIndexed: boolean;
  84580. /** @hidden */
  84581. _lightSources: Light[];
  84582. /** Gets the list of lights affecting that mesh */
  84583. readonly lightSources: Light[];
  84584. /** @hidden */
  84585. readonly _positions: Nullable<Vector3[]>;
  84586. /** @hidden */
  84587. _waitingData: {
  84588. lods: Nullable<any>;
  84589. actions: Nullable<any>;
  84590. freezeWorldMatrix: Nullable<boolean>;
  84591. };
  84592. /** @hidden */
  84593. _bonesTransformMatrices: Nullable<Float32Array>;
  84594. /**
  84595. * Gets or sets a skeleton to apply skining transformations
  84596. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84597. */
  84598. skeleton: Nullable<Skeleton>;
  84599. /**
  84600. * An event triggered when the mesh is rebuilt.
  84601. */
  84602. onRebuildObservable: Observable<AbstractMesh>;
  84603. /**
  84604. * Creates a new AbstractMesh
  84605. * @param name defines the name of the mesh
  84606. * @param scene defines the hosting scene
  84607. */
  84608. constructor(name: string, scene?: Nullable<Scene>);
  84609. /**
  84610. * Returns the string "AbstractMesh"
  84611. * @returns "AbstractMesh"
  84612. */
  84613. getClassName(): string;
  84614. /**
  84615. * Gets a string representation of the current mesh
  84616. * @param fullDetails defines a boolean indicating if full details must be included
  84617. * @returns a string representation of the current mesh
  84618. */
  84619. toString(fullDetails?: boolean): string;
  84620. /**
  84621. * @hidden
  84622. */
  84623. protected _getEffectiveParent(): Nullable<Node>;
  84624. /** @hidden */
  84625. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84626. /** @hidden */
  84627. _rebuild(): void;
  84628. /** @hidden */
  84629. _resyncLightSources(): void;
  84630. /** @hidden */
  84631. _resyncLighSource(light: Light): void;
  84632. /** @hidden */
  84633. _unBindEffect(): void;
  84634. /** @hidden */
  84635. _removeLightSource(light: Light): void;
  84636. private _markSubMeshesAsDirty;
  84637. /** @hidden */
  84638. _markSubMeshesAsLightDirty(): void;
  84639. /** @hidden */
  84640. _markSubMeshesAsAttributesDirty(): void;
  84641. /** @hidden */
  84642. _markSubMeshesAsMiscDirty(): void;
  84643. /**
  84644. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84645. */
  84646. scaling: Vector3;
  84647. /**
  84648. * Returns true if the mesh is blocked. Implemented by child classes
  84649. */
  84650. readonly isBlocked: boolean;
  84651. /**
  84652. * Returns the mesh itself by default. Implemented by child classes
  84653. * @param camera defines the camera to use to pick the right LOD level
  84654. * @returns the currentAbstractMesh
  84655. */
  84656. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84657. /**
  84658. * Returns 0 by default. Implemented by child classes
  84659. * @returns an integer
  84660. */
  84661. getTotalVertices(): number;
  84662. /**
  84663. * Returns a positive integer : the total number of indices in this mesh geometry.
  84664. * @returns the numner of indices or zero if the mesh has no geometry.
  84665. */
  84666. getTotalIndices(): number;
  84667. /**
  84668. * Returns null by default. Implemented by child classes
  84669. * @returns null
  84670. */
  84671. getIndices(): Nullable<IndicesArray>;
  84672. /**
  84673. * Returns the array of the requested vertex data kind. Implemented by child classes
  84674. * @param kind defines the vertex data kind to use
  84675. * @returns null
  84676. */
  84677. getVerticesData(kind: string): Nullable<FloatArray>;
  84678. /**
  84679. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84680. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84681. * Note that a new underlying VertexBuffer object is created each call.
  84682. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84683. * @param kind defines vertex data kind:
  84684. * * VertexBuffer.PositionKind
  84685. * * VertexBuffer.UVKind
  84686. * * VertexBuffer.UV2Kind
  84687. * * VertexBuffer.UV3Kind
  84688. * * VertexBuffer.UV4Kind
  84689. * * VertexBuffer.UV5Kind
  84690. * * VertexBuffer.UV6Kind
  84691. * * VertexBuffer.ColorKind
  84692. * * VertexBuffer.MatricesIndicesKind
  84693. * * VertexBuffer.MatricesIndicesExtraKind
  84694. * * VertexBuffer.MatricesWeightsKind
  84695. * * VertexBuffer.MatricesWeightsExtraKind
  84696. * @param data defines the data source
  84697. * @param updatable defines if the data must be flagged as updatable (or static)
  84698. * @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
  84699. * @returns the current mesh
  84700. */
  84701. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84702. /**
  84703. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84704. * If the mesh has no geometry, it is simply returned as it is.
  84705. * @param kind defines vertex data kind:
  84706. * * VertexBuffer.PositionKind
  84707. * * VertexBuffer.UVKind
  84708. * * VertexBuffer.UV2Kind
  84709. * * VertexBuffer.UV3Kind
  84710. * * VertexBuffer.UV4Kind
  84711. * * VertexBuffer.UV5Kind
  84712. * * VertexBuffer.UV6Kind
  84713. * * VertexBuffer.ColorKind
  84714. * * VertexBuffer.MatricesIndicesKind
  84715. * * VertexBuffer.MatricesIndicesExtraKind
  84716. * * VertexBuffer.MatricesWeightsKind
  84717. * * VertexBuffer.MatricesWeightsExtraKind
  84718. * @param data defines the data source
  84719. * @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
  84720. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84721. * @returns the current mesh
  84722. */
  84723. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84724. /**
  84725. * Sets the mesh indices,
  84726. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84727. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84728. * @param totalVertices Defines the total number of vertices
  84729. * @returns the current mesh
  84730. */
  84731. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84732. /**
  84733. * Gets a boolean indicating if specific vertex data is present
  84734. * @param kind defines the vertex data kind to use
  84735. * @returns true is data kind is present
  84736. */
  84737. isVerticesDataPresent(kind: string): boolean;
  84738. /**
  84739. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84740. * @returns a BoundingInfo
  84741. */
  84742. getBoundingInfo(): BoundingInfo;
  84743. /**
  84744. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84745. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84746. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84747. * @returns the current mesh
  84748. */
  84749. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84750. /**
  84751. * Overwrite the current bounding info
  84752. * @param boundingInfo defines the new bounding info
  84753. * @returns the current mesh
  84754. */
  84755. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84756. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84757. readonly useBones: boolean;
  84758. /** @hidden */
  84759. _preActivate(): void;
  84760. /** @hidden */
  84761. _preActivateForIntermediateRendering(renderId: number): void;
  84762. /** @hidden */
  84763. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84764. /** @hidden */
  84765. _postActivate(): void;
  84766. /** @hidden */
  84767. _freeze(): void;
  84768. /** @hidden */
  84769. _unFreeze(): void;
  84770. /**
  84771. * Gets the current world matrix
  84772. * @returns a Matrix
  84773. */
  84774. getWorldMatrix(): Matrix;
  84775. /** @hidden */
  84776. _getWorldMatrixDeterminant(): number;
  84777. /**
  84778. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84779. */
  84780. readonly isAnInstance: boolean;
  84781. /**
  84782. * Perform relative position change from the point of view of behind the front of the mesh.
  84783. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84784. * Supports definition of mesh facing forward or backward
  84785. * @param amountRight defines the distance on the right axis
  84786. * @param amountUp defines the distance on the up axis
  84787. * @param amountForward defines the distance on the forward axis
  84788. * @returns the current mesh
  84789. */
  84790. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84791. /**
  84792. * Calculate relative position change from the point of view of behind the front of the mesh.
  84793. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84794. * Supports definition of mesh facing forward or backward
  84795. * @param amountRight defines the distance on the right axis
  84796. * @param amountUp defines the distance on the up axis
  84797. * @param amountForward defines the distance on the forward axis
  84798. * @returns the new displacement vector
  84799. */
  84800. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84801. /**
  84802. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84803. * Supports definition of mesh facing forward or backward
  84804. * @param flipBack defines the flip
  84805. * @param twirlClockwise defines the twirl
  84806. * @param tiltRight defines the tilt
  84807. * @returns the current mesh
  84808. */
  84809. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84810. /**
  84811. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84812. * Supports definition of mesh facing forward or backward.
  84813. * @param flipBack defines the flip
  84814. * @param twirlClockwise defines the twirl
  84815. * @param tiltRight defines the tilt
  84816. * @returns the new rotation vector
  84817. */
  84818. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84819. /**
  84820. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84821. * This means the mesh underlying bounding box and sphere are recomputed.
  84822. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84823. * @returns the current mesh
  84824. */
  84825. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84826. /** @hidden */
  84827. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84828. /** @hidden */
  84829. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84830. /** @hidden */
  84831. _updateBoundingInfo(): AbstractMesh;
  84832. /** @hidden */
  84833. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84834. /** @hidden */
  84835. protected _afterComputeWorldMatrix(): void;
  84836. /** @hidden */
  84837. readonly _effectiveMesh: AbstractMesh;
  84838. /**
  84839. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84840. * A mesh is in the frustum if its bounding box intersects the frustum
  84841. * @param frustumPlanes defines the frustum to test
  84842. * @returns true if the mesh is in the frustum planes
  84843. */
  84844. isInFrustum(frustumPlanes: Plane[]): boolean;
  84845. /**
  84846. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84847. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84848. * @param frustumPlanes defines the frustum to test
  84849. * @returns true if the mesh is completely in the frustum planes
  84850. */
  84851. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84852. /**
  84853. * True if the mesh intersects another mesh or a SolidParticle object
  84854. * @param mesh defines a target mesh or SolidParticle to test
  84855. * @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)
  84856. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84857. * @returns true if there is an intersection
  84858. */
  84859. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84860. /**
  84861. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84862. * @param point defines the point to test
  84863. * @returns true if there is an intersection
  84864. */
  84865. intersectsPoint(point: Vector3): boolean;
  84866. /**
  84867. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84868. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84869. */
  84870. checkCollisions: boolean;
  84871. /**
  84872. * Gets Collider object used to compute collisions (not physics)
  84873. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84874. */
  84875. readonly collider: Nullable<Collider>;
  84876. /**
  84877. * Move the mesh using collision engine
  84878. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84879. * @param displacement defines the requested displacement vector
  84880. * @returns the current mesh
  84881. */
  84882. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84883. private _onCollisionPositionChange;
  84884. /** @hidden */
  84885. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84886. /** @hidden */
  84887. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84888. /** @hidden */
  84889. _checkCollision(collider: Collider): AbstractMesh;
  84890. /** @hidden */
  84891. _generatePointsArray(): boolean;
  84892. /**
  84893. * Checks if the passed Ray intersects with the mesh
  84894. * @param ray defines the ray to use
  84895. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84896. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84897. * @returns the picking info
  84898. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84899. */
  84900. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84901. /**
  84902. * Clones the current mesh
  84903. * @param name defines the mesh name
  84904. * @param newParent defines the new mesh parent
  84905. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84906. * @returns the new mesh
  84907. */
  84908. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84909. /**
  84910. * Disposes all the submeshes of the current meshnp
  84911. * @returns the current mesh
  84912. */
  84913. releaseSubMeshes(): AbstractMesh;
  84914. /**
  84915. * Releases resources associated with this abstract mesh.
  84916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84918. */
  84919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84920. /**
  84921. * Adds the passed mesh as a child to the current mesh
  84922. * @param mesh defines the child mesh
  84923. * @returns the current mesh
  84924. */
  84925. addChild(mesh: AbstractMesh): AbstractMesh;
  84926. /**
  84927. * Removes the passed mesh from the current mesh children list
  84928. * @param mesh defines the child mesh
  84929. * @returns the current mesh
  84930. */
  84931. removeChild(mesh: AbstractMesh): AbstractMesh;
  84932. /** @hidden */
  84933. private _initFacetData;
  84934. /**
  84935. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84936. * This method can be called within the render loop.
  84937. * 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
  84938. * @returns the current mesh
  84939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84940. */
  84941. updateFacetData(): AbstractMesh;
  84942. /**
  84943. * Returns the facetLocalNormals array.
  84944. * The normals are expressed in the mesh local spac
  84945. * @returns an array of Vector3
  84946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84947. */
  84948. getFacetLocalNormals(): Vector3[];
  84949. /**
  84950. * Returns the facetLocalPositions array.
  84951. * The facet positions are expressed in the mesh local space
  84952. * @returns an array of Vector3
  84953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84954. */
  84955. getFacetLocalPositions(): Vector3[];
  84956. /**
  84957. * Returns the facetLocalPartioning array
  84958. * @returns an array of array of numbers
  84959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84960. */
  84961. getFacetLocalPartitioning(): number[][];
  84962. /**
  84963. * Returns the i-th facet position in the world system.
  84964. * This method allocates a new Vector3 per call
  84965. * @param i defines the facet index
  84966. * @returns a new Vector3
  84967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84968. */
  84969. getFacetPosition(i: number): Vector3;
  84970. /**
  84971. * Sets the reference Vector3 with the i-th facet position in the world system
  84972. * @param i defines the facet index
  84973. * @param ref defines the target vector
  84974. * @returns the current mesh
  84975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84976. */
  84977. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84978. /**
  84979. * Returns the i-th facet normal in the world system.
  84980. * This method allocates a new Vector3 per call
  84981. * @param i defines the facet index
  84982. * @returns a new Vector3
  84983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84984. */
  84985. getFacetNormal(i: number): Vector3;
  84986. /**
  84987. * Sets the reference Vector3 with the i-th facet normal in the world system
  84988. * @param i defines the facet index
  84989. * @param ref defines the target vector
  84990. * @returns the current mesh
  84991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84992. */
  84993. getFacetNormalToRef(i: number, ref: Vector3): this;
  84994. /**
  84995. * 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)
  84996. * @param x defines x coordinate
  84997. * @param y defines y coordinate
  84998. * @param z defines z coordinate
  84999. * @returns the array of facet indexes
  85000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85001. */
  85002. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  85003. /**
  85004. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  85005. * @param projected sets as the (x,y,z) world projection on the facet
  85006. * @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
  85007. * @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
  85008. * @param x defines x coordinate
  85009. * @param y defines y coordinate
  85010. * @param z defines z coordinate
  85011. * @returns the face index if found (or null instead)
  85012. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85013. */
  85014. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  85015. /**
  85016. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  85017. * @param projected sets as the (x,y,z) local projection on the facet
  85018. * @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
  85019. * @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
  85020. * @param x defines x coordinate
  85021. * @param y defines y coordinate
  85022. * @param z defines z coordinate
  85023. * @returns the face index if found (or null instead)
  85024. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85025. */
  85026. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  85027. /**
  85028. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  85029. * @returns the parameters
  85030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85031. */
  85032. getFacetDataParameters(): any;
  85033. /**
  85034. * Disables the feature FacetData and frees the related memory
  85035. * @returns the current mesh
  85036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85037. */
  85038. disableFacetData(): AbstractMesh;
  85039. /**
  85040. * Updates the AbstractMesh indices array
  85041. * @param indices defines the data source
  85042. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  85043. * @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)
  85044. * @returns the current mesh
  85045. */
  85046. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  85047. /**
  85048. * Creates new normals data for the mesh
  85049. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  85050. * @returns the current mesh
  85051. */
  85052. createNormals(updatable: boolean): AbstractMesh;
  85053. /**
  85054. * Align the mesh with a normal
  85055. * @param normal defines the normal to use
  85056. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  85057. * @returns the current mesh
  85058. */
  85059. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  85060. /** @hidden */
  85061. _checkOcclusionQuery(): boolean;
  85062. /**
  85063. * Disables the mesh edge rendering mode
  85064. * @returns the currentAbstractMesh
  85065. */
  85066. disableEdgesRendering(): AbstractMesh;
  85067. /**
  85068. * Enables the edge rendering mode on the mesh.
  85069. * This mode makes the mesh edges visible
  85070. * @param epsilon defines the maximal distance between two angles to detect a face
  85071. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85072. * @returns the currentAbstractMesh
  85073. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85074. */
  85075. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85076. }
  85077. }
  85078. declare module BABYLON {
  85079. /**
  85080. * Interface used to define ActionEvent
  85081. */
  85082. export interface IActionEvent {
  85083. /** The mesh or sprite that triggered the action */
  85084. source: any;
  85085. /** The X mouse cursor position at the time of the event */
  85086. pointerX: number;
  85087. /** The Y mouse cursor position at the time of the event */
  85088. pointerY: number;
  85089. /** The mesh that is currently pointed at (can be null) */
  85090. meshUnderPointer: Nullable<AbstractMesh>;
  85091. /** the original (browser) event that triggered the ActionEvent */
  85092. sourceEvent?: any;
  85093. /** additional data for the event */
  85094. additionalData?: any;
  85095. }
  85096. /**
  85097. * ActionEvent is the event being sent when an action is triggered.
  85098. */
  85099. export class ActionEvent implements IActionEvent {
  85100. /** The mesh or sprite that triggered the action */
  85101. source: any;
  85102. /** The X mouse cursor position at the time of the event */
  85103. pointerX: number;
  85104. /** The Y mouse cursor position at the time of the event */
  85105. pointerY: number;
  85106. /** The mesh that is currently pointed at (can be null) */
  85107. meshUnderPointer: Nullable<AbstractMesh>;
  85108. /** the original (browser) event that triggered the ActionEvent */
  85109. sourceEvent?: any;
  85110. /** additional data for the event */
  85111. additionalData?: any;
  85112. /**
  85113. * Creates a new ActionEvent
  85114. * @param source The mesh or sprite that triggered the action
  85115. * @param pointerX The X mouse cursor position at the time of the event
  85116. * @param pointerY The Y mouse cursor position at the time of the event
  85117. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  85118. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  85119. * @param additionalData additional data for the event
  85120. */
  85121. constructor(
  85122. /** The mesh or sprite that triggered the action */
  85123. source: any,
  85124. /** The X mouse cursor position at the time of the event */
  85125. pointerX: number,
  85126. /** The Y mouse cursor position at the time of the event */
  85127. pointerY: number,
  85128. /** The mesh that is currently pointed at (can be null) */
  85129. meshUnderPointer: Nullable<AbstractMesh>,
  85130. /** the original (browser) event that triggered the ActionEvent */
  85131. sourceEvent?: any,
  85132. /** additional data for the event */
  85133. additionalData?: any);
  85134. /**
  85135. * Helper function to auto-create an ActionEvent from a source mesh.
  85136. * @param source The source mesh that triggered the event
  85137. * @param evt The original (browser) event
  85138. * @param additionalData additional data for the event
  85139. * @returns the new ActionEvent
  85140. */
  85141. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  85142. /**
  85143. * Helper function to auto-create an ActionEvent from a source sprite
  85144. * @param source The source sprite that triggered the event
  85145. * @param scene Scene associated with the sprite
  85146. * @param evt The original (browser) event
  85147. * @param additionalData additional data for the event
  85148. * @returns the new ActionEvent
  85149. */
  85150. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  85151. /**
  85152. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  85153. * @param scene the scene where the event occurred
  85154. * @param evt The original (browser) event
  85155. * @returns the new ActionEvent
  85156. */
  85157. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  85158. /**
  85159. * Helper function to auto-create an ActionEvent from a primitive
  85160. * @param prim defines the target primitive
  85161. * @param pointerPos defines the pointer position
  85162. * @param evt The original (browser) event
  85163. * @param additionalData additional data for the event
  85164. * @returns the new ActionEvent
  85165. */
  85166. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  85167. }
  85168. }
  85169. declare module BABYLON {
  85170. /**
  85171. * Abstract class used to decouple action Manager from scene and meshes.
  85172. * Do not instantiate.
  85173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  85174. */
  85175. export abstract class AbstractActionManager implements IDisposable {
  85176. /** Gets the list of active triggers */
  85177. static Triggers: {
  85178. [key: string]: number;
  85179. };
  85180. /** Gets the cursor to use when hovering items */
  85181. hoverCursor: string;
  85182. /** Gets the list of actions */
  85183. actions: IAction[];
  85184. /**
  85185. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85186. */
  85187. isRecursive: boolean;
  85188. /**
  85189. * Releases all associated resources
  85190. */
  85191. abstract dispose(): void;
  85192. /**
  85193. * Does this action manager has pointer triggers
  85194. */
  85195. abstract readonly hasPointerTriggers: boolean;
  85196. /**
  85197. * Does this action manager has pick triggers
  85198. */
  85199. abstract readonly hasPickTriggers: boolean;
  85200. /**
  85201. * Process a specific trigger
  85202. * @param trigger defines the trigger to process
  85203. * @param evt defines the event details to be processed
  85204. */
  85205. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85206. /**
  85207. * Does this action manager handles actions of any of the given triggers
  85208. * @param triggers defines the triggers to be tested
  85209. * @return a boolean indicating whether one (or more) of the triggers is handled
  85210. */
  85211. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85212. /**
  85213. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85214. * speed.
  85215. * @param triggerA defines the trigger to be tested
  85216. * @param triggerB defines the trigger to be tested
  85217. * @return a boolean indicating whether one (or more) of the triggers is handled
  85218. */
  85219. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85220. /**
  85221. * Does this action manager handles actions of a given trigger
  85222. * @param trigger defines the trigger to be tested
  85223. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85224. * @return whether the trigger is handled
  85225. */
  85226. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85227. /**
  85228. * Serialize this manager to a JSON object
  85229. * @param name defines the property name to store this manager
  85230. * @returns a JSON representation of this manager
  85231. */
  85232. abstract serialize(name: string): any;
  85233. /**
  85234. * Registers an action to this action manager
  85235. * @param action defines the action to be registered
  85236. * @return the action amended (prepared) after registration
  85237. */
  85238. abstract registerAction(action: IAction): Nullable<IAction>;
  85239. /**
  85240. * Unregisters an action to this action manager
  85241. * @param action defines the action to be unregistered
  85242. * @return a boolean indicating whether the action has been unregistered
  85243. */
  85244. abstract unregisterAction(action: IAction): Boolean;
  85245. /**
  85246. * Does exist one action manager with at least one trigger
  85247. **/
  85248. static readonly HasTriggers: boolean;
  85249. /**
  85250. * Does exist one action manager with at least one pick trigger
  85251. **/
  85252. static readonly HasPickTriggers: boolean;
  85253. /**
  85254. * Does exist one action manager that handles actions of a given trigger
  85255. * @param trigger defines the trigger to be tested
  85256. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85257. **/
  85258. static HasSpecificTrigger(trigger: number): boolean;
  85259. }
  85260. }
  85261. declare module BABYLON {
  85262. /**
  85263. * Defines how a node can be built from a string name.
  85264. */
  85265. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85266. /**
  85267. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85268. */
  85269. export class Node implements IBehaviorAware<Node> {
  85270. /** @hidden */
  85271. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85272. private static _NodeConstructors;
  85273. /**
  85274. * Add a new node constructor
  85275. * @param type defines the type name of the node to construct
  85276. * @param constructorFunc defines the constructor function
  85277. */
  85278. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85279. /**
  85280. * Returns a node constructor based on type name
  85281. * @param type defines the type name
  85282. * @param name defines the new node name
  85283. * @param scene defines the hosting scene
  85284. * @param options defines optional options to transmit to constructors
  85285. * @returns the new constructor or null
  85286. */
  85287. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85288. /**
  85289. * Gets or sets the name of the node
  85290. */
  85291. name: string;
  85292. /**
  85293. * Gets or sets the id of the node
  85294. */
  85295. id: string;
  85296. /**
  85297. * Gets or sets the unique id of the node
  85298. */
  85299. uniqueId: number;
  85300. /**
  85301. * Gets or sets a string used to store user defined state for the node
  85302. */
  85303. state: string;
  85304. /**
  85305. * Gets or sets an object used to store user defined information for the node
  85306. */
  85307. metadata: any;
  85308. /**
  85309. * For internal use only. Please do not use.
  85310. */
  85311. reservedDataStore: any;
  85312. /**
  85313. * List of inspectable custom properties (used by the Inspector)
  85314. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85315. */
  85316. inspectableCustomProperties: IInspectable[];
  85317. /**
  85318. * Gets or sets a boolean used to define if the node must be serialized
  85319. */
  85320. doNotSerialize: boolean;
  85321. /** @hidden */
  85322. _isDisposed: boolean;
  85323. /**
  85324. * Gets a list of Animations associated with the node
  85325. */
  85326. animations: Animation[];
  85327. protected _ranges: {
  85328. [name: string]: Nullable<AnimationRange>;
  85329. };
  85330. /**
  85331. * Callback raised when the node is ready to be used
  85332. */
  85333. onReady: Nullable<(node: Node) => void>;
  85334. private _isEnabled;
  85335. private _isParentEnabled;
  85336. private _isReady;
  85337. /** @hidden */
  85338. _currentRenderId: number;
  85339. private _parentUpdateId;
  85340. /** @hidden */
  85341. _childUpdateId: number;
  85342. /** @hidden */
  85343. _waitingParentId: Nullable<string>;
  85344. /** @hidden */
  85345. _scene: Scene;
  85346. /** @hidden */
  85347. _cache: any;
  85348. private _parentNode;
  85349. private _children;
  85350. /** @hidden */
  85351. _worldMatrix: Matrix;
  85352. /** @hidden */
  85353. _worldMatrixDeterminant: number;
  85354. /** @hidden */
  85355. _worldMatrixDeterminantIsDirty: boolean;
  85356. /** @hidden */
  85357. private _sceneRootNodesIndex;
  85358. /**
  85359. * Gets a boolean indicating if the node has been disposed
  85360. * @returns true if the node was disposed
  85361. */
  85362. isDisposed(): boolean;
  85363. /**
  85364. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85365. * @see https://doc.babylonjs.com/how_to/parenting
  85366. */
  85367. parent: Nullable<Node>;
  85368. private addToSceneRootNodes;
  85369. private removeFromSceneRootNodes;
  85370. private _animationPropertiesOverride;
  85371. /**
  85372. * Gets or sets the animation properties override
  85373. */
  85374. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85375. /**
  85376. * Gets a string idenfifying the name of the class
  85377. * @returns "Node" string
  85378. */
  85379. getClassName(): string;
  85380. /** @hidden */
  85381. readonly _isNode: boolean;
  85382. /**
  85383. * An event triggered when the mesh is disposed
  85384. */
  85385. onDisposeObservable: Observable<Node>;
  85386. private _onDisposeObserver;
  85387. /**
  85388. * Sets a callback that will be raised when the node will be disposed
  85389. */
  85390. onDispose: () => void;
  85391. /**
  85392. * Creates a new Node
  85393. * @param name the name and id to be given to this node
  85394. * @param scene the scene this node will be added to
  85395. * @param addToRootNodes the node will be added to scene.rootNodes
  85396. */
  85397. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85398. /**
  85399. * Gets the scene of the node
  85400. * @returns a scene
  85401. */
  85402. getScene(): Scene;
  85403. /**
  85404. * Gets the engine of the node
  85405. * @returns a Engine
  85406. */
  85407. getEngine(): Engine;
  85408. private _behaviors;
  85409. /**
  85410. * Attach a behavior to the node
  85411. * @see http://doc.babylonjs.com/features/behaviour
  85412. * @param behavior defines the behavior to attach
  85413. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85414. * @returns the current Node
  85415. */
  85416. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85417. /**
  85418. * Remove an attached behavior
  85419. * @see http://doc.babylonjs.com/features/behaviour
  85420. * @param behavior defines the behavior to attach
  85421. * @returns the current Node
  85422. */
  85423. removeBehavior(behavior: Behavior<Node>): Node;
  85424. /**
  85425. * Gets the list of attached behaviors
  85426. * @see http://doc.babylonjs.com/features/behaviour
  85427. */
  85428. readonly behaviors: Behavior<Node>[];
  85429. /**
  85430. * Gets an attached behavior by name
  85431. * @param name defines the name of the behavior to look for
  85432. * @see http://doc.babylonjs.com/features/behaviour
  85433. * @returns null if behavior was not found else the requested behavior
  85434. */
  85435. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85436. /**
  85437. * Returns the latest update of the World matrix
  85438. * @returns a Matrix
  85439. */
  85440. getWorldMatrix(): Matrix;
  85441. /** @hidden */
  85442. _getWorldMatrixDeterminant(): number;
  85443. /**
  85444. * Returns directly the latest state of the mesh World matrix.
  85445. * A Matrix is returned.
  85446. */
  85447. readonly worldMatrixFromCache: Matrix;
  85448. /** @hidden */
  85449. _initCache(): void;
  85450. /** @hidden */
  85451. updateCache(force?: boolean): void;
  85452. /** @hidden */
  85453. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85454. /** @hidden */
  85455. _updateCache(ignoreParentClass?: boolean): void;
  85456. /** @hidden */
  85457. _isSynchronized(): boolean;
  85458. /** @hidden */
  85459. _markSyncedWithParent(): void;
  85460. /** @hidden */
  85461. isSynchronizedWithParent(): boolean;
  85462. /** @hidden */
  85463. isSynchronized(): boolean;
  85464. /**
  85465. * Is this node ready to be used/rendered
  85466. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85467. * @return true if the node is ready
  85468. */
  85469. isReady(completeCheck?: boolean): boolean;
  85470. /**
  85471. * Is this node enabled?
  85472. * 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
  85473. * @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
  85474. * @return whether this node (and its parent) is enabled
  85475. */
  85476. isEnabled(checkAncestors?: boolean): boolean;
  85477. /** @hidden */
  85478. protected _syncParentEnabledState(): void;
  85479. /**
  85480. * Set the enabled state of this node
  85481. * @param value defines the new enabled state
  85482. */
  85483. setEnabled(value: boolean): void;
  85484. /**
  85485. * Is this node a descendant of the given node?
  85486. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85487. * @param ancestor defines the parent node to inspect
  85488. * @returns a boolean indicating if this node is a descendant of the given node
  85489. */
  85490. isDescendantOf(ancestor: Node): boolean;
  85491. /** @hidden */
  85492. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85493. /**
  85494. * Will return all nodes that have this node as ascendant
  85495. * @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
  85496. * @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
  85497. * @return all children nodes of all types
  85498. */
  85499. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85500. /**
  85501. * Get all child-meshes of this node
  85502. * @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)
  85503. * @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
  85504. * @returns an array of AbstractMesh
  85505. */
  85506. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85507. /**
  85508. * Get all direct children of this node
  85509. * @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
  85510. * @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)
  85511. * @returns an array of Node
  85512. */
  85513. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85514. /** @hidden */
  85515. _setReady(state: boolean): void;
  85516. /**
  85517. * Get an animation by name
  85518. * @param name defines the name of the animation to look for
  85519. * @returns null if not found else the requested animation
  85520. */
  85521. getAnimationByName(name: string): Nullable<Animation>;
  85522. /**
  85523. * Creates an animation range for this node
  85524. * @param name defines the name of the range
  85525. * @param from defines the starting key
  85526. * @param to defines the end key
  85527. */
  85528. createAnimationRange(name: string, from: number, to: number): void;
  85529. /**
  85530. * Delete a specific animation range
  85531. * @param name defines the name of the range to delete
  85532. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85533. */
  85534. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85535. /**
  85536. * Get an animation range by name
  85537. * @param name defines the name of the animation range to look for
  85538. * @returns null if not found else the requested animation range
  85539. */
  85540. getAnimationRange(name: string): Nullable<AnimationRange>;
  85541. /**
  85542. * Gets the list of all animation ranges defined on this node
  85543. * @returns an array
  85544. */
  85545. getAnimationRanges(): Nullable<AnimationRange>[];
  85546. /**
  85547. * Will start the animation sequence
  85548. * @param name defines the range frames for animation sequence
  85549. * @param loop defines if the animation should loop (false by default)
  85550. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85551. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85552. * @returns the object created for this animation. If range does not exist, it will return null
  85553. */
  85554. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85555. /**
  85556. * Serialize animation ranges into a JSON compatible object
  85557. * @returns serialization object
  85558. */
  85559. serializeAnimationRanges(): any;
  85560. /**
  85561. * Computes the world matrix of the node
  85562. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85563. * @returns the world matrix
  85564. */
  85565. computeWorldMatrix(force?: boolean): Matrix;
  85566. /**
  85567. * Releases resources associated with this node.
  85568. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85569. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85570. */
  85571. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85572. /**
  85573. * Parse animation range data from a serialization object and store them into a given node
  85574. * @param node defines where to store the animation ranges
  85575. * @param parsedNode defines the serialization object to read data from
  85576. * @param scene defines the hosting scene
  85577. */
  85578. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85579. /**
  85580. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85581. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85582. * @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
  85583. * @returns the new bounding vectors
  85584. */
  85585. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85586. min: Vector3;
  85587. max: Vector3;
  85588. };
  85589. }
  85590. }
  85591. declare module BABYLON {
  85592. /**
  85593. * @hidden
  85594. */
  85595. export class _IAnimationState {
  85596. key: number;
  85597. repeatCount: number;
  85598. workValue?: any;
  85599. loopMode?: number;
  85600. offsetValue?: any;
  85601. highLimitValue?: any;
  85602. }
  85603. /**
  85604. * Class used to store any kind of animation
  85605. */
  85606. export class Animation {
  85607. /**Name of the animation */
  85608. name: string;
  85609. /**Property to animate */
  85610. targetProperty: string;
  85611. /**The frames per second of the animation */
  85612. framePerSecond: number;
  85613. /**The data type of the animation */
  85614. dataType: number;
  85615. /**The loop mode of the animation */
  85616. loopMode?: number | undefined;
  85617. /**Specifies if blending should be enabled */
  85618. enableBlending?: boolean | undefined;
  85619. /**
  85620. * Use matrix interpolation instead of using direct key value when animating matrices
  85621. */
  85622. static AllowMatricesInterpolation: boolean;
  85623. /**
  85624. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85625. */
  85626. static AllowMatrixDecomposeForInterpolation: boolean;
  85627. /**
  85628. * Stores the key frames of the animation
  85629. */
  85630. private _keys;
  85631. /**
  85632. * Stores the easing function of the animation
  85633. */
  85634. private _easingFunction;
  85635. /**
  85636. * @hidden Internal use only
  85637. */
  85638. _runtimeAnimations: RuntimeAnimation[];
  85639. /**
  85640. * The set of event that will be linked to this animation
  85641. */
  85642. private _events;
  85643. /**
  85644. * Stores an array of target property paths
  85645. */
  85646. targetPropertyPath: string[];
  85647. /**
  85648. * Stores the blending speed of the animation
  85649. */
  85650. blendingSpeed: number;
  85651. /**
  85652. * Stores the animation ranges for the animation
  85653. */
  85654. private _ranges;
  85655. /**
  85656. * @hidden Internal use
  85657. */
  85658. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85659. /**
  85660. * Sets up an animation
  85661. * @param property The property to animate
  85662. * @param animationType The animation type to apply
  85663. * @param framePerSecond The frames per second of the animation
  85664. * @param easingFunction The easing function used in the animation
  85665. * @returns The created animation
  85666. */
  85667. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85668. /**
  85669. * Create and start an animation on a node
  85670. * @param name defines the name of the global animation that will be run on all nodes
  85671. * @param node defines the root node where the animation will take place
  85672. * @param targetProperty defines property to animate
  85673. * @param framePerSecond defines the number of frame per second yo use
  85674. * @param totalFrame defines the number of frames in total
  85675. * @param from defines the initial value
  85676. * @param to defines the final value
  85677. * @param loopMode defines which loop mode you want to use (off by default)
  85678. * @param easingFunction defines the easing function to use (linear by default)
  85679. * @param onAnimationEnd defines the callback to call when animation end
  85680. * @returns the animatable created for this animation
  85681. */
  85682. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85683. /**
  85684. * Create and start an animation on a node and its descendants
  85685. * @param name defines the name of the global animation that will be run on all nodes
  85686. * @param node defines the root node where the animation will take place
  85687. * @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
  85688. * @param targetProperty defines property to animate
  85689. * @param framePerSecond defines the number of frame per second to use
  85690. * @param totalFrame defines the number of frames in total
  85691. * @param from defines the initial value
  85692. * @param to defines the final value
  85693. * @param loopMode defines which loop mode you want to use (off by default)
  85694. * @param easingFunction defines the easing function to use (linear by default)
  85695. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85696. * @returns the list of animatables created for all nodes
  85697. * @example https://www.babylonjs-playground.com/#MH0VLI
  85698. */
  85699. 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[]>;
  85700. /**
  85701. * Creates a new animation, merges it with the existing animations and starts it
  85702. * @param name Name of the animation
  85703. * @param node Node which contains the scene that begins the animations
  85704. * @param targetProperty Specifies which property to animate
  85705. * @param framePerSecond The frames per second of the animation
  85706. * @param totalFrame The total number of frames
  85707. * @param from The frame at the beginning of the animation
  85708. * @param to The frame at the end of the animation
  85709. * @param loopMode Specifies the loop mode of the animation
  85710. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85711. * @param onAnimationEnd Callback to run once the animation is complete
  85712. * @returns Nullable animation
  85713. */
  85714. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85715. /**
  85716. * Transition property of an host to the target Value
  85717. * @param property The property to transition
  85718. * @param targetValue The target Value of the property
  85719. * @param host The object where the property to animate belongs
  85720. * @param scene Scene used to run the animation
  85721. * @param frameRate Framerate (in frame/s) to use
  85722. * @param transition The transition type we want to use
  85723. * @param duration The duration of the animation, in milliseconds
  85724. * @param onAnimationEnd Callback trigger at the end of the animation
  85725. * @returns Nullable animation
  85726. */
  85727. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85728. /**
  85729. * Return the array of runtime animations currently using this animation
  85730. */
  85731. readonly runtimeAnimations: RuntimeAnimation[];
  85732. /**
  85733. * Specifies if any of the runtime animations are currently running
  85734. */
  85735. readonly hasRunningRuntimeAnimations: boolean;
  85736. /**
  85737. * Initializes the animation
  85738. * @param name Name of the animation
  85739. * @param targetProperty Property to animate
  85740. * @param framePerSecond The frames per second of the animation
  85741. * @param dataType The data type of the animation
  85742. * @param loopMode The loop mode of the animation
  85743. * @param enableBlending Specifies if blending should be enabled
  85744. */
  85745. constructor(
  85746. /**Name of the animation */
  85747. name: string,
  85748. /**Property to animate */
  85749. targetProperty: string,
  85750. /**The frames per second of the animation */
  85751. framePerSecond: number,
  85752. /**The data type of the animation */
  85753. dataType: number,
  85754. /**The loop mode of the animation */
  85755. loopMode?: number | undefined,
  85756. /**Specifies if blending should be enabled */
  85757. enableBlending?: boolean | undefined);
  85758. /**
  85759. * Converts the animation to a string
  85760. * @param fullDetails support for multiple levels of logging within scene loading
  85761. * @returns String form of the animation
  85762. */
  85763. toString(fullDetails?: boolean): string;
  85764. /**
  85765. * Add an event to this animation
  85766. * @param event Event to add
  85767. */
  85768. addEvent(event: AnimationEvent): void;
  85769. /**
  85770. * Remove all events found at the given frame
  85771. * @param frame The frame to remove events from
  85772. */
  85773. removeEvents(frame: number): void;
  85774. /**
  85775. * Retrieves all the events from the animation
  85776. * @returns Events from the animation
  85777. */
  85778. getEvents(): AnimationEvent[];
  85779. /**
  85780. * Creates an animation range
  85781. * @param name Name of the animation range
  85782. * @param from Starting frame of the animation range
  85783. * @param to Ending frame of the animation
  85784. */
  85785. createRange(name: string, from: number, to: number): void;
  85786. /**
  85787. * Deletes an animation range by name
  85788. * @param name Name of the animation range to delete
  85789. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85790. */
  85791. deleteRange(name: string, deleteFrames?: boolean): void;
  85792. /**
  85793. * Gets the animation range by name, or null if not defined
  85794. * @param name Name of the animation range
  85795. * @returns Nullable animation range
  85796. */
  85797. getRange(name: string): Nullable<AnimationRange>;
  85798. /**
  85799. * Gets the key frames from the animation
  85800. * @returns The key frames of the animation
  85801. */
  85802. getKeys(): Array<IAnimationKey>;
  85803. /**
  85804. * Gets the highest frame rate of the animation
  85805. * @returns Highest frame rate of the animation
  85806. */
  85807. getHighestFrame(): number;
  85808. /**
  85809. * Gets the easing function of the animation
  85810. * @returns Easing function of the animation
  85811. */
  85812. getEasingFunction(): IEasingFunction;
  85813. /**
  85814. * Sets the easing function of the animation
  85815. * @param easingFunction A custom mathematical formula for animation
  85816. */
  85817. setEasingFunction(easingFunction: EasingFunction): void;
  85818. /**
  85819. * Interpolates a scalar linearly
  85820. * @param startValue Start value of the animation curve
  85821. * @param endValue End value of the animation curve
  85822. * @param gradient Scalar amount to interpolate
  85823. * @returns Interpolated scalar value
  85824. */
  85825. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85826. /**
  85827. * Interpolates a scalar cubically
  85828. * @param startValue Start value of the animation curve
  85829. * @param outTangent End tangent of the animation
  85830. * @param endValue End value of the animation curve
  85831. * @param inTangent Start tangent of the animation curve
  85832. * @param gradient Scalar amount to interpolate
  85833. * @returns Interpolated scalar value
  85834. */
  85835. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85836. /**
  85837. * Interpolates a quaternion using a spherical linear interpolation
  85838. * @param startValue Start value of the animation curve
  85839. * @param endValue End value of the animation curve
  85840. * @param gradient Scalar amount to interpolate
  85841. * @returns Interpolated quaternion value
  85842. */
  85843. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85844. /**
  85845. * Interpolates a quaternion cubically
  85846. * @param startValue Start value of the animation curve
  85847. * @param outTangent End tangent of the animation curve
  85848. * @param endValue End value of the animation curve
  85849. * @param inTangent Start tangent of the animation curve
  85850. * @param gradient Scalar amount to interpolate
  85851. * @returns Interpolated quaternion value
  85852. */
  85853. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85854. /**
  85855. * Interpolates a Vector3 linearl
  85856. * @param startValue Start value of the animation curve
  85857. * @param endValue End value of the animation curve
  85858. * @param gradient Scalar amount to interpolate
  85859. * @returns Interpolated scalar value
  85860. */
  85861. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85862. /**
  85863. * Interpolates a Vector3 cubically
  85864. * @param startValue Start value of the animation curve
  85865. * @param outTangent End tangent of the animation
  85866. * @param endValue End value of the animation curve
  85867. * @param inTangent Start tangent of the animation curve
  85868. * @param gradient Scalar amount to interpolate
  85869. * @returns InterpolatedVector3 value
  85870. */
  85871. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85872. /**
  85873. * Interpolates a Vector2 linearly
  85874. * @param startValue Start value of the animation curve
  85875. * @param endValue End value of the animation curve
  85876. * @param gradient Scalar amount to interpolate
  85877. * @returns Interpolated Vector2 value
  85878. */
  85879. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85880. /**
  85881. * Interpolates a Vector2 cubically
  85882. * @param startValue Start value of the animation curve
  85883. * @param outTangent End tangent of the animation
  85884. * @param endValue End value of the animation curve
  85885. * @param inTangent Start tangent of the animation curve
  85886. * @param gradient Scalar amount to interpolate
  85887. * @returns Interpolated Vector2 value
  85888. */
  85889. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85890. /**
  85891. * Interpolates a size linearly
  85892. * @param startValue Start value of the animation curve
  85893. * @param endValue End value of the animation curve
  85894. * @param gradient Scalar amount to interpolate
  85895. * @returns Interpolated Size value
  85896. */
  85897. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85898. /**
  85899. * Interpolates a Color3 linearly
  85900. * @param startValue Start value of the animation curve
  85901. * @param endValue End value of the animation curve
  85902. * @param gradient Scalar amount to interpolate
  85903. * @returns Interpolated Color3 value
  85904. */
  85905. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85906. /**
  85907. * @hidden Internal use only
  85908. */
  85909. _getKeyValue(value: any): any;
  85910. /**
  85911. * @hidden Internal use only
  85912. */
  85913. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85914. /**
  85915. * Defines the function to use to interpolate matrices
  85916. * @param startValue defines the start matrix
  85917. * @param endValue defines the end matrix
  85918. * @param gradient defines the gradient between both matrices
  85919. * @param result defines an optional target matrix where to store the interpolation
  85920. * @returns the interpolated matrix
  85921. */
  85922. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85923. /**
  85924. * Makes a copy of the animation
  85925. * @returns Cloned animation
  85926. */
  85927. clone(): Animation;
  85928. /**
  85929. * Sets the key frames of the animation
  85930. * @param values The animation key frames to set
  85931. */
  85932. setKeys(values: Array<IAnimationKey>): void;
  85933. /**
  85934. * Serializes the animation to an object
  85935. * @returns Serialized object
  85936. */
  85937. serialize(): any;
  85938. /**
  85939. * Float animation type
  85940. */
  85941. private static _ANIMATIONTYPE_FLOAT;
  85942. /**
  85943. * Vector3 animation type
  85944. */
  85945. private static _ANIMATIONTYPE_VECTOR3;
  85946. /**
  85947. * Quaternion animation type
  85948. */
  85949. private static _ANIMATIONTYPE_QUATERNION;
  85950. /**
  85951. * Matrix animation type
  85952. */
  85953. private static _ANIMATIONTYPE_MATRIX;
  85954. /**
  85955. * Color3 animation type
  85956. */
  85957. private static _ANIMATIONTYPE_COLOR3;
  85958. /**
  85959. * Vector2 animation type
  85960. */
  85961. private static _ANIMATIONTYPE_VECTOR2;
  85962. /**
  85963. * Size animation type
  85964. */
  85965. private static _ANIMATIONTYPE_SIZE;
  85966. /**
  85967. * Relative Loop Mode
  85968. */
  85969. private static _ANIMATIONLOOPMODE_RELATIVE;
  85970. /**
  85971. * Cycle Loop Mode
  85972. */
  85973. private static _ANIMATIONLOOPMODE_CYCLE;
  85974. /**
  85975. * Constant Loop Mode
  85976. */
  85977. private static _ANIMATIONLOOPMODE_CONSTANT;
  85978. /**
  85979. * Get the float animation type
  85980. */
  85981. static readonly ANIMATIONTYPE_FLOAT: number;
  85982. /**
  85983. * Get the Vector3 animation type
  85984. */
  85985. static readonly ANIMATIONTYPE_VECTOR3: number;
  85986. /**
  85987. * Get the Vector2 animation type
  85988. */
  85989. static readonly ANIMATIONTYPE_VECTOR2: number;
  85990. /**
  85991. * Get the Size animation type
  85992. */
  85993. static readonly ANIMATIONTYPE_SIZE: number;
  85994. /**
  85995. * Get the Quaternion animation type
  85996. */
  85997. static readonly ANIMATIONTYPE_QUATERNION: number;
  85998. /**
  85999. * Get the Matrix animation type
  86000. */
  86001. static readonly ANIMATIONTYPE_MATRIX: number;
  86002. /**
  86003. * Get the Color3 animation type
  86004. */
  86005. static readonly ANIMATIONTYPE_COLOR3: number;
  86006. /**
  86007. * Get the Relative Loop Mode
  86008. */
  86009. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  86010. /**
  86011. * Get the Cycle Loop Mode
  86012. */
  86013. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  86014. /**
  86015. * Get the Constant Loop Mode
  86016. */
  86017. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  86018. /** @hidden */
  86019. static _UniversalLerp(left: any, right: any, amount: number): any;
  86020. /**
  86021. * Parses an animation object and creates an animation
  86022. * @param parsedAnimation Parsed animation object
  86023. * @returns Animation object
  86024. */
  86025. static Parse(parsedAnimation: any): Animation;
  86026. /**
  86027. * Appends the serialized animations from the source animations
  86028. * @param source Source containing the animations
  86029. * @param destination Target to store the animations
  86030. */
  86031. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86032. }
  86033. }
  86034. declare module BABYLON {
  86035. /**
  86036. * Base class of all the textures in babylon.
  86037. * It groups all the common properties the materials, post process, lights... might need
  86038. * in order to make a correct use of the texture.
  86039. */
  86040. export class BaseTexture implements IAnimatable {
  86041. /**
  86042. * Default anisotropic filtering level for the application.
  86043. * It is set to 4 as a good tradeoff between perf and quality.
  86044. */
  86045. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  86046. /**
  86047. * Gets or sets the unique id of the texture
  86048. */
  86049. uniqueId: number;
  86050. /**
  86051. * Define the name of the texture.
  86052. */
  86053. name: string;
  86054. /**
  86055. * Gets or sets an object used to store user defined information.
  86056. */
  86057. metadata: any;
  86058. /**
  86059. * For internal use only. Please do not use.
  86060. */
  86061. reservedDataStore: any;
  86062. private _hasAlpha;
  86063. /**
  86064. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  86065. */
  86066. hasAlpha: boolean;
  86067. /**
  86068. * Defines if the alpha value should be determined via the rgb values.
  86069. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  86070. */
  86071. getAlphaFromRGB: boolean;
  86072. /**
  86073. * Intensity or strength of the texture.
  86074. * It is commonly used by materials to fine tune the intensity of the texture
  86075. */
  86076. level: number;
  86077. /**
  86078. * Define the UV chanel to use starting from 0 and defaulting to 0.
  86079. * This is part of the texture as textures usually maps to one uv set.
  86080. */
  86081. coordinatesIndex: number;
  86082. private _coordinatesMode;
  86083. /**
  86084. * How a texture is mapped.
  86085. *
  86086. * | Value | Type | Description |
  86087. * | ----- | ----------------------------------- | ----------- |
  86088. * | 0 | EXPLICIT_MODE | |
  86089. * | 1 | SPHERICAL_MODE | |
  86090. * | 2 | PLANAR_MODE | |
  86091. * | 3 | CUBIC_MODE | |
  86092. * | 4 | PROJECTION_MODE | |
  86093. * | 5 | SKYBOX_MODE | |
  86094. * | 6 | INVCUBIC_MODE | |
  86095. * | 7 | EQUIRECTANGULAR_MODE | |
  86096. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  86097. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  86098. */
  86099. coordinatesMode: number;
  86100. /**
  86101. * | Value | Type | Description |
  86102. * | ----- | ------------------ | ----------- |
  86103. * | 0 | CLAMP_ADDRESSMODE | |
  86104. * | 1 | WRAP_ADDRESSMODE | |
  86105. * | 2 | MIRROR_ADDRESSMODE | |
  86106. */
  86107. wrapU: number;
  86108. /**
  86109. * | Value | Type | Description |
  86110. * | ----- | ------------------ | ----------- |
  86111. * | 0 | CLAMP_ADDRESSMODE | |
  86112. * | 1 | WRAP_ADDRESSMODE | |
  86113. * | 2 | MIRROR_ADDRESSMODE | |
  86114. */
  86115. wrapV: number;
  86116. /**
  86117. * | Value | Type | Description |
  86118. * | ----- | ------------------ | ----------- |
  86119. * | 0 | CLAMP_ADDRESSMODE | |
  86120. * | 1 | WRAP_ADDRESSMODE | |
  86121. * | 2 | MIRROR_ADDRESSMODE | |
  86122. */
  86123. wrapR: number;
  86124. /**
  86125. * With compliant hardware and browser (supporting anisotropic filtering)
  86126. * this defines the level of anisotropic filtering in the texture.
  86127. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  86128. */
  86129. anisotropicFilteringLevel: number;
  86130. /**
  86131. * Define if the texture is a cube texture or if false a 2d texture.
  86132. */
  86133. isCube: boolean;
  86134. /**
  86135. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  86136. */
  86137. is3D: boolean;
  86138. /**
  86139. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  86140. * HDR texture are usually stored in linear space.
  86141. * This only impacts the PBR and Background materials
  86142. */
  86143. gammaSpace: boolean;
  86144. /**
  86145. * Gets whether or not the texture contains RGBD data.
  86146. */
  86147. readonly isRGBD: boolean;
  86148. /**
  86149. * Is Z inverted in the texture (useful in a cube texture).
  86150. */
  86151. invertZ: boolean;
  86152. /**
  86153. * Are mip maps generated for this texture or not.
  86154. */
  86155. readonly noMipmap: boolean;
  86156. /**
  86157. * @hidden
  86158. */
  86159. lodLevelInAlpha: boolean;
  86160. /**
  86161. * With prefiltered texture, defined the offset used during the prefiltering steps.
  86162. */
  86163. lodGenerationOffset: number;
  86164. /**
  86165. * With prefiltered texture, defined the scale used during the prefiltering steps.
  86166. */
  86167. lodGenerationScale: number;
  86168. /**
  86169. * Define if the texture is a render target.
  86170. */
  86171. isRenderTarget: boolean;
  86172. /**
  86173. * Define the unique id of the texture in the scene.
  86174. */
  86175. readonly uid: string;
  86176. /**
  86177. * Return a string representation of the texture.
  86178. * @returns the texture as a string
  86179. */
  86180. toString(): string;
  86181. /**
  86182. * Get the class name of the texture.
  86183. * @returns "BaseTexture"
  86184. */
  86185. getClassName(): string;
  86186. /**
  86187. * Define the list of animation attached to the texture.
  86188. */
  86189. animations: Animation[];
  86190. /**
  86191. * An event triggered when the texture is disposed.
  86192. */
  86193. onDisposeObservable: Observable<BaseTexture>;
  86194. private _onDisposeObserver;
  86195. /**
  86196. * Callback triggered when the texture has been disposed.
  86197. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86198. */
  86199. onDispose: () => void;
  86200. /**
  86201. * Define the current state of the loading sequence when in delayed load mode.
  86202. */
  86203. delayLoadState: number;
  86204. private _scene;
  86205. /** @hidden */
  86206. _texture: Nullable<InternalTexture>;
  86207. private _uid;
  86208. /**
  86209. * Define if the texture is preventinga material to render or not.
  86210. * If not and the texture is not ready, the engine will use a default black texture instead.
  86211. */
  86212. readonly isBlocking: boolean;
  86213. /**
  86214. * Instantiates a new BaseTexture.
  86215. * Base class of all the textures in babylon.
  86216. * It groups all the common properties the materials, post process, lights... might need
  86217. * in order to make a correct use of the texture.
  86218. * @param scene Define the scene the texture blongs to
  86219. */
  86220. constructor(scene: Nullable<Scene>);
  86221. /**
  86222. * Get the scene the texture belongs to.
  86223. * @returns the scene or null if undefined
  86224. */
  86225. getScene(): Nullable<Scene>;
  86226. /**
  86227. * Get the texture transform matrix used to offset tile the texture for istance.
  86228. * @returns the transformation matrix
  86229. */
  86230. getTextureMatrix(): Matrix;
  86231. /**
  86232. * Get the texture reflection matrix used to rotate/transform the reflection.
  86233. * @returns the reflection matrix
  86234. */
  86235. getReflectionTextureMatrix(): Matrix;
  86236. /**
  86237. * Get the underlying lower level texture from Babylon.
  86238. * @returns the insternal texture
  86239. */
  86240. getInternalTexture(): Nullable<InternalTexture>;
  86241. /**
  86242. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86243. * @returns true if ready or not blocking
  86244. */
  86245. isReadyOrNotBlocking(): boolean;
  86246. /**
  86247. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86248. * @returns true if fully ready
  86249. */
  86250. isReady(): boolean;
  86251. private _cachedSize;
  86252. /**
  86253. * Get the size of the texture.
  86254. * @returns the texture size.
  86255. */
  86256. getSize(): ISize;
  86257. /**
  86258. * Get the base size of the texture.
  86259. * It can be different from the size if the texture has been resized for POT for instance
  86260. * @returns the base size
  86261. */
  86262. getBaseSize(): ISize;
  86263. /**
  86264. * Update the sampling mode of the texture.
  86265. * Default is Trilinear mode.
  86266. *
  86267. * | Value | Type | Description |
  86268. * | ----- | ------------------ | ----------- |
  86269. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86270. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86271. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86272. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86273. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86274. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86275. * | 7 | NEAREST_LINEAR | |
  86276. * | 8 | NEAREST_NEAREST | |
  86277. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86278. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86279. * | 11 | LINEAR_LINEAR | |
  86280. * | 12 | LINEAR_NEAREST | |
  86281. *
  86282. * > _mag_: magnification filter (close to the viewer)
  86283. * > _min_: minification filter (far from the viewer)
  86284. * > _mip_: filter used between mip map levels
  86285. *@param samplingMode Define the new sampling mode of the texture
  86286. */
  86287. updateSamplingMode(samplingMode: number): void;
  86288. /**
  86289. * Scales the texture if is `canRescale()`
  86290. * @param ratio the resize factor we want to use to rescale
  86291. */
  86292. scale(ratio: number): void;
  86293. /**
  86294. * Get if the texture can rescale.
  86295. */
  86296. readonly canRescale: boolean;
  86297. /** @hidden */
  86298. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86299. /** @hidden */
  86300. _rebuild(): void;
  86301. /**
  86302. * Triggers the load sequence in delayed load mode.
  86303. */
  86304. delayLoad(): void;
  86305. /**
  86306. * Clones the texture.
  86307. * @returns the cloned texture
  86308. */
  86309. clone(): Nullable<BaseTexture>;
  86310. /**
  86311. * Get the texture underlying type (INT, FLOAT...)
  86312. */
  86313. readonly textureType: number;
  86314. /**
  86315. * Get the texture underlying format (RGB, RGBA...)
  86316. */
  86317. readonly textureFormat: number;
  86318. /**
  86319. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86320. * This will returns an RGBA array buffer containing either in values (0-255) or
  86321. * float values (0-1) depending of the underlying buffer type.
  86322. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86323. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86324. * @param buffer defines a user defined buffer to fill with data (can be null)
  86325. * @returns The Array buffer containing the pixels data.
  86326. */
  86327. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86328. /**
  86329. * Release and destroy the underlying lower level texture aka internalTexture.
  86330. */
  86331. releaseInternalTexture(): void;
  86332. /**
  86333. * Get the polynomial representation of the texture data.
  86334. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86335. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86336. */
  86337. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86338. /** @hidden */
  86339. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86340. /** @hidden */
  86341. readonly _lodTextureMid: Nullable<BaseTexture>;
  86342. /** @hidden */
  86343. readonly _lodTextureLow: Nullable<BaseTexture>;
  86344. /**
  86345. * Dispose the texture and release its associated resources.
  86346. */
  86347. dispose(): void;
  86348. /**
  86349. * Serialize the texture into a JSON representation that can be parsed later on.
  86350. * @returns the JSON representation of the texture
  86351. */
  86352. serialize(): any;
  86353. /**
  86354. * Helper function to be called back once a list of texture contains only ready textures.
  86355. * @param textures Define the list of textures to wait for
  86356. * @param callback Define the callback triggered once the entire list will be ready
  86357. */
  86358. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86359. }
  86360. }
  86361. declare module BABYLON {
  86362. /**
  86363. * Uniform buffer objects.
  86364. *
  86365. * Handles blocks of uniform on the GPU.
  86366. *
  86367. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86368. *
  86369. * For more information, please refer to :
  86370. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86371. */
  86372. export class UniformBuffer {
  86373. private _engine;
  86374. private _buffer;
  86375. private _data;
  86376. private _bufferData;
  86377. private _dynamic?;
  86378. private _uniformLocations;
  86379. private _uniformSizes;
  86380. private _uniformLocationPointer;
  86381. private _needSync;
  86382. private _noUBO;
  86383. private _currentEffect;
  86384. private static _MAX_UNIFORM_SIZE;
  86385. private static _tempBuffer;
  86386. /**
  86387. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86388. * This is dynamic to allow compat with webgl 1 and 2.
  86389. * You will need to pass the name of the uniform as well as the value.
  86390. */
  86391. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86392. /**
  86393. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86394. * This is dynamic to allow compat with webgl 1 and 2.
  86395. * You will need to pass the name of the uniform as well as the value.
  86396. */
  86397. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86398. /**
  86399. * Lambda to Update a single float in a uniform buffer.
  86400. * This is dynamic to allow compat with webgl 1 and 2.
  86401. * You will need to pass the name of the uniform as well as the value.
  86402. */
  86403. updateFloat: (name: string, x: number) => void;
  86404. /**
  86405. * Lambda to Update a vec2 of float in a uniform buffer.
  86406. * This is dynamic to allow compat with webgl 1 and 2.
  86407. * You will need to pass the name of the uniform as well as the value.
  86408. */
  86409. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86410. /**
  86411. * Lambda to Update a vec3 of float in a uniform buffer.
  86412. * This is dynamic to allow compat with webgl 1 and 2.
  86413. * You will need to pass the name of the uniform as well as the value.
  86414. */
  86415. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86416. /**
  86417. * Lambda to Update a vec4 of float in a uniform buffer.
  86418. * This is dynamic to allow compat with webgl 1 and 2.
  86419. * You will need to pass the name of the uniform as well as the value.
  86420. */
  86421. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86422. /**
  86423. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86424. * This is dynamic to allow compat with webgl 1 and 2.
  86425. * You will need to pass the name of the uniform as well as the value.
  86426. */
  86427. updateMatrix: (name: string, mat: Matrix) => void;
  86428. /**
  86429. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86430. * This is dynamic to allow compat with webgl 1 and 2.
  86431. * You will need to pass the name of the uniform as well as the value.
  86432. */
  86433. updateVector3: (name: string, vector: Vector3) => void;
  86434. /**
  86435. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86436. * This is dynamic to allow compat with webgl 1 and 2.
  86437. * You will need to pass the name of the uniform as well as the value.
  86438. */
  86439. updateVector4: (name: string, vector: Vector4) => void;
  86440. /**
  86441. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86442. * This is dynamic to allow compat with webgl 1 and 2.
  86443. * You will need to pass the name of the uniform as well as the value.
  86444. */
  86445. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86446. /**
  86447. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86448. * This is dynamic to allow compat with webgl 1 and 2.
  86449. * You will need to pass the name of the uniform as well as the value.
  86450. */
  86451. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86452. /**
  86453. * Instantiates a new Uniform buffer objects.
  86454. *
  86455. * Handles blocks of uniform on the GPU.
  86456. *
  86457. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86458. *
  86459. * For more information, please refer to :
  86460. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86461. * @param engine Define the engine the buffer is associated with
  86462. * @param data Define the data contained in the buffer
  86463. * @param dynamic Define if the buffer is updatable
  86464. */
  86465. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86466. /**
  86467. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86468. * or just falling back on setUniformXXX calls.
  86469. */
  86470. readonly useUbo: boolean;
  86471. /**
  86472. * Indicates if the WebGL underlying uniform buffer is in sync
  86473. * with the javascript cache data.
  86474. */
  86475. readonly isSync: boolean;
  86476. /**
  86477. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86478. * Also, a dynamic UniformBuffer will disable cache verification and always
  86479. * update the underlying WebGL uniform buffer to the GPU.
  86480. * @returns if Dynamic, otherwise false
  86481. */
  86482. isDynamic(): boolean;
  86483. /**
  86484. * The data cache on JS side.
  86485. * @returns the underlying data as a float array
  86486. */
  86487. getData(): Float32Array;
  86488. /**
  86489. * The underlying WebGL Uniform buffer.
  86490. * @returns the webgl buffer
  86491. */
  86492. getBuffer(): Nullable<DataBuffer>;
  86493. /**
  86494. * std140 layout specifies how to align data within an UBO structure.
  86495. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86496. * for specs.
  86497. */
  86498. private _fillAlignment;
  86499. /**
  86500. * Adds an uniform in the buffer.
  86501. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86502. * for the layout to be correct !
  86503. * @param name Name of the uniform, as used in the uniform block in the shader.
  86504. * @param size Data size, or data directly.
  86505. */
  86506. addUniform(name: string, size: number | number[]): void;
  86507. /**
  86508. * Adds a Matrix 4x4 to the uniform buffer.
  86509. * @param name Name of the uniform, as used in the uniform block in the shader.
  86510. * @param mat A 4x4 matrix.
  86511. */
  86512. addMatrix(name: string, mat: Matrix): void;
  86513. /**
  86514. * Adds a vec2 to the uniform buffer.
  86515. * @param name Name of the uniform, as used in the uniform block in the shader.
  86516. * @param x Define the x component value of the vec2
  86517. * @param y Define the y component value of the vec2
  86518. */
  86519. addFloat2(name: string, x: number, y: number): void;
  86520. /**
  86521. * Adds a vec3 to the uniform buffer.
  86522. * @param name Name of the uniform, as used in the uniform block in the shader.
  86523. * @param x Define the x component value of the vec3
  86524. * @param y Define the y component value of the vec3
  86525. * @param z Define the z component value of the vec3
  86526. */
  86527. addFloat3(name: string, x: number, y: number, z: number): void;
  86528. /**
  86529. * Adds a vec3 to the uniform buffer.
  86530. * @param name Name of the uniform, as used in the uniform block in the shader.
  86531. * @param color Define the vec3 from a Color
  86532. */
  86533. addColor3(name: string, color: Color3): void;
  86534. /**
  86535. * Adds a vec4 to the uniform buffer.
  86536. * @param name Name of the uniform, as used in the uniform block in the shader.
  86537. * @param color Define the rgb components from a Color
  86538. * @param alpha Define the a component of the vec4
  86539. */
  86540. addColor4(name: string, color: Color3, alpha: number): void;
  86541. /**
  86542. * Adds a vec3 to the uniform buffer.
  86543. * @param name Name of the uniform, as used in the uniform block in the shader.
  86544. * @param vector Define the vec3 components from a Vector
  86545. */
  86546. addVector3(name: string, vector: Vector3): void;
  86547. /**
  86548. * Adds a Matrix 3x3 to the uniform buffer.
  86549. * @param name Name of the uniform, as used in the uniform block in the shader.
  86550. */
  86551. addMatrix3x3(name: string): void;
  86552. /**
  86553. * Adds a Matrix 2x2 to the uniform buffer.
  86554. * @param name Name of the uniform, as used in the uniform block in the shader.
  86555. */
  86556. addMatrix2x2(name: string): void;
  86557. /**
  86558. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86559. */
  86560. create(): void;
  86561. /** @hidden */
  86562. _rebuild(): void;
  86563. /**
  86564. * Updates the WebGL Uniform Buffer on the GPU.
  86565. * If the `dynamic` flag is set to true, no cache comparison is done.
  86566. * Otherwise, the buffer will be updated only if the cache differs.
  86567. */
  86568. update(): void;
  86569. /**
  86570. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86571. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86572. * @param data Define the flattened data
  86573. * @param size Define the size of the data.
  86574. */
  86575. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86576. private _updateMatrix3x3ForUniform;
  86577. private _updateMatrix3x3ForEffect;
  86578. private _updateMatrix2x2ForEffect;
  86579. private _updateMatrix2x2ForUniform;
  86580. private _updateFloatForEffect;
  86581. private _updateFloatForUniform;
  86582. private _updateFloat2ForEffect;
  86583. private _updateFloat2ForUniform;
  86584. private _updateFloat3ForEffect;
  86585. private _updateFloat3ForUniform;
  86586. private _updateFloat4ForEffect;
  86587. private _updateFloat4ForUniform;
  86588. private _updateMatrixForEffect;
  86589. private _updateMatrixForUniform;
  86590. private _updateVector3ForEffect;
  86591. private _updateVector3ForUniform;
  86592. private _updateVector4ForEffect;
  86593. private _updateVector4ForUniform;
  86594. private _updateColor3ForEffect;
  86595. private _updateColor3ForUniform;
  86596. private _updateColor4ForEffect;
  86597. private _updateColor4ForUniform;
  86598. /**
  86599. * Sets a sampler uniform on the effect.
  86600. * @param name Define the name of the sampler.
  86601. * @param texture Define the texture to set in the sampler
  86602. */
  86603. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86604. /**
  86605. * Directly updates the value of the uniform in the cache AND on the GPU.
  86606. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86607. * @param data Define the flattened data
  86608. */
  86609. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86610. /**
  86611. * Binds this uniform buffer to an effect.
  86612. * @param effect Define the effect to bind the buffer to
  86613. * @param name Name of the uniform block in the shader.
  86614. */
  86615. bindToEffect(effect: Effect, name: string): void;
  86616. /**
  86617. * Disposes the uniform buffer.
  86618. */
  86619. dispose(): void;
  86620. }
  86621. }
  86622. declare module BABYLON {
  86623. /**
  86624. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86626. */
  86627. export class Analyser {
  86628. /**
  86629. * Gets or sets the smoothing
  86630. * @ignorenaming
  86631. */
  86632. SMOOTHING: number;
  86633. /**
  86634. * Gets or sets the FFT table size
  86635. * @ignorenaming
  86636. */
  86637. FFT_SIZE: number;
  86638. /**
  86639. * Gets or sets the bar graph amplitude
  86640. * @ignorenaming
  86641. */
  86642. BARGRAPHAMPLITUDE: number;
  86643. /**
  86644. * Gets or sets the position of the debug canvas
  86645. * @ignorenaming
  86646. */
  86647. DEBUGCANVASPOS: {
  86648. x: number;
  86649. y: number;
  86650. };
  86651. /**
  86652. * Gets or sets the debug canvas size
  86653. * @ignorenaming
  86654. */
  86655. DEBUGCANVASSIZE: {
  86656. width: number;
  86657. height: number;
  86658. };
  86659. private _byteFreqs;
  86660. private _byteTime;
  86661. private _floatFreqs;
  86662. private _webAudioAnalyser;
  86663. private _debugCanvas;
  86664. private _debugCanvasContext;
  86665. private _scene;
  86666. private _registerFunc;
  86667. private _audioEngine;
  86668. /**
  86669. * Creates a new analyser
  86670. * @param scene defines hosting scene
  86671. */
  86672. constructor(scene: Scene);
  86673. /**
  86674. * Get the number of data values you will have to play with for the visualization
  86675. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86676. * @returns a number
  86677. */
  86678. getFrequencyBinCount(): number;
  86679. /**
  86680. * Gets the current frequency data as a byte array
  86681. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86682. * @returns a Uint8Array
  86683. */
  86684. getByteFrequencyData(): Uint8Array;
  86685. /**
  86686. * Gets the current waveform as a byte array
  86687. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86688. * @returns a Uint8Array
  86689. */
  86690. getByteTimeDomainData(): Uint8Array;
  86691. /**
  86692. * Gets the current frequency data as a float array
  86693. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86694. * @returns a Float32Array
  86695. */
  86696. getFloatFrequencyData(): Float32Array;
  86697. /**
  86698. * Renders the debug canvas
  86699. */
  86700. drawDebugCanvas(): void;
  86701. /**
  86702. * Stops rendering the debug canvas and removes it
  86703. */
  86704. stopDebugCanvas(): void;
  86705. /**
  86706. * Connects two audio nodes
  86707. * @param inputAudioNode defines first node to connect
  86708. * @param outputAudioNode defines second node to connect
  86709. */
  86710. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86711. /**
  86712. * Releases all associated resources
  86713. */
  86714. dispose(): void;
  86715. }
  86716. }
  86717. declare module BABYLON {
  86718. /**
  86719. * This represents an audio engine and it is responsible
  86720. * to play, synchronize and analyse sounds throughout the application.
  86721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86722. */
  86723. export interface IAudioEngine extends IDisposable {
  86724. /**
  86725. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86726. */
  86727. readonly canUseWebAudio: boolean;
  86728. /**
  86729. * Gets the current AudioContext if available.
  86730. */
  86731. readonly audioContext: Nullable<AudioContext>;
  86732. /**
  86733. * The master gain node defines the global audio volume of your audio engine.
  86734. */
  86735. readonly masterGain: GainNode;
  86736. /**
  86737. * Gets whether or not mp3 are supported by your browser.
  86738. */
  86739. readonly isMP3supported: boolean;
  86740. /**
  86741. * Gets whether or not ogg are supported by your browser.
  86742. */
  86743. readonly isOGGsupported: boolean;
  86744. /**
  86745. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86746. * @ignoreNaming
  86747. */
  86748. WarnedWebAudioUnsupported: boolean;
  86749. /**
  86750. * Defines if the audio engine relies on a custom unlocked button.
  86751. * In this case, the embedded button will not be displayed.
  86752. */
  86753. useCustomUnlockedButton: boolean;
  86754. /**
  86755. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86756. */
  86757. readonly unlocked: boolean;
  86758. /**
  86759. * Event raised when audio has been unlocked on the browser.
  86760. */
  86761. onAudioUnlockedObservable: Observable<AudioEngine>;
  86762. /**
  86763. * Event raised when audio has been locked on the browser.
  86764. */
  86765. onAudioLockedObservable: Observable<AudioEngine>;
  86766. /**
  86767. * Flags the audio engine in Locked state.
  86768. * This happens due to new browser policies preventing audio to autoplay.
  86769. */
  86770. lock(): void;
  86771. /**
  86772. * Unlocks the audio engine once a user action has been done on the dom.
  86773. * This is helpful to resume play once browser policies have been satisfied.
  86774. */
  86775. unlock(): void;
  86776. }
  86777. /**
  86778. * This represents the default audio engine used in babylon.
  86779. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86781. */
  86782. export class AudioEngine implements IAudioEngine {
  86783. private _audioContext;
  86784. private _audioContextInitialized;
  86785. private _muteButton;
  86786. private _hostElement;
  86787. /**
  86788. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86789. */
  86790. canUseWebAudio: boolean;
  86791. /**
  86792. * The master gain node defines the global audio volume of your audio engine.
  86793. */
  86794. masterGain: GainNode;
  86795. /**
  86796. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86797. * @ignoreNaming
  86798. */
  86799. WarnedWebAudioUnsupported: boolean;
  86800. /**
  86801. * Gets whether or not mp3 are supported by your browser.
  86802. */
  86803. isMP3supported: boolean;
  86804. /**
  86805. * Gets whether or not ogg are supported by your browser.
  86806. */
  86807. isOGGsupported: boolean;
  86808. /**
  86809. * Gets whether audio has been unlocked on the device.
  86810. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86811. * a user interaction has happened.
  86812. */
  86813. unlocked: boolean;
  86814. /**
  86815. * Defines if the audio engine relies on a custom unlocked button.
  86816. * In this case, the embedded button will not be displayed.
  86817. */
  86818. useCustomUnlockedButton: boolean;
  86819. /**
  86820. * Event raised when audio has been unlocked on the browser.
  86821. */
  86822. onAudioUnlockedObservable: Observable<AudioEngine>;
  86823. /**
  86824. * Event raised when audio has been locked on the browser.
  86825. */
  86826. onAudioLockedObservable: Observable<AudioEngine>;
  86827. /**
  86828. * Gets the current AudioContext if available.
  86829. */
  86830. readonly audioContext: Nullable<AudioContext>;
  86831. private _connectedAnalyser;
  86832. /**
  86833. * Instantiates a new audio engine.
  86834. *
  86835. * There should be only one per page as some browsers restrict the number
  86836. * of audio contexts you can create.
  86837. * @param hostElement defines the host element where to display the mute icon if necessary
  86838. */
  86839. constructor(hostElement?: Nullable<HTMLElement>);
  86840. /**
  86841. * Flags the audio engine in Locked state.
  86842. * This happens due to new browser policies preventing audio to autoplay.
  86843. */
  86844. lock(): void;
  86845. /**
  86846. * Unlocks the audio engine once a user action has been done on the dom.
  86847. * This is helpful to resume play once browser policies have been satisfied.
  86848. */
  86849. unlock(): void;
  86850. private _resumeAudioContext;
  86851. private _initializeAudioContext;
  86852. private _tryToRun;
  86853. private _triggerRunningState;
  86854. private _triggerSuspendedState;
  86855. private _displayMuteButton;
  86856. private _moveButtonToTopLeft;
  86857. private _onResize;
  86858. private _hideMuteButton;
  86859. /**
  86860. * Destroy and release the resources associated with the audio ccontext.
  86861. */
  86862. dispose(): void;
  86863. /**
  86864. * Gets the global volume sets on the master gain.
  86865. * @returns the global volume if set or -1 otherwise
  86866. */
  86867. getGlobalVolume(): number;
  86868. /**
  86869. * Sets the global volume of your experience (sets on the master gain).
  86870. * @param newVolume Defines the new global volume of the application
  86871. */
  86872. setGlobalVolume(newVolume: number): void;
  86873. /**
  86874. * Connect the audio engine to an audio analyser allowing some amazing
  86875. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86877. * @param analyser The analyser to connect to the engine
  86878. */
  86879. connectToAnalyser(analyser: Analyser): void;
  86880. }
  86881. }
  86882. declare module BABYLON {
  86883. /**
  86884. * Interface used to present a loading screen while loading a scene
  86885. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86886. */
  86887. export interface ILoadingScreen {
  86888. /**
  86889. * Function called to display the loading screen
  86890. */
  86891. displayLoadingUI: () => void;
  86892. /**
  86893. * Function called to hide the loading screen
  86894. */
  86895. hideLoadingUI: () => void;
  86896. /**
  86897. * Gets or sets the color to use for the background
  86898. */
  86899. loadingUIBackgroundColor: string;
  86900. /**
  86901. * Gets or sets the text to display while loading
  86902. */
  86903. loadingUIText: string;
  86904. }
  86905. /**
  86906. * Class used for the default loading screen
  86907. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86908. */
  86909. export class DefaultLoadingScreen implements ILoadingScreen {
  86910. private _renderingCanvas;
  86911. private _loadingText;
  86912. private _loadingDivBackgroundColor;
  86913. private _loadingDiv;
  86914. private _loadingTextDiv;
  86915. /** Gets or sets the logo url to use for the default loading screen */
  86916. static DefaultLogoUrl: string;
  86917. /** Gets or sets the spinner url to use for the default loading screen */
  86918. static DefaultSpinnerUrl: string;
  86919. /**
  86920. * Creates a new default loading screen
  86921. * @param _renderingCanvas defines the canvas used to render the scene
  86922. * @param _loadingText defines the default text to display
  86923. * @param _loadingDivBackgroundColor defines the default background color
  86924. */
  86925. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86926. /**
  86927. * Function called to display the loading screen
  86928. */
  86929. displayLoadingUI(): void;
  86930. /**
  86931. * Function called to hide the loading screen
  86932. */
  86933. hideLoadingUI(): void;
  86934. /**
  86935. * Gets or sets the text to display while loading
  86936. */
  86937. loadingUIText: string;
  86938. /**
  86939. * Gets or sets the color to use for the background
  86940. */
  86941. loadingUIBackgroundColor: string;
  86942. private _resizeLoadingUI;
  86943. }
  86944. }
  86945. declare module BABYLON {
  86946. /** @hidden */
  86947. export class WebGLPipelineContext implements IPipelineContext {
  86948. engine: Engine;
  86949. program: Nullable<WebGLProgram>;
  86950. context?: WebGLRenderingContext;
  86951. vertexShader?: WebGLShader;
  86952. fragmentShader?: WebGLShader;
  86953. isParallelCompiled: boolean;
  86954. onCompiled?: () => void;
  86955. transformFeedback?: WebGLTransformFeedback | null;
  86956. readonly isAsync: boolean;
  86957. readonly isReady: boolean;
  86958. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86959. }
  86960. }
  86961. declare module BABYLON {
  86962. /** @hidden */
  86963. export class WebGLDataBuffer extends DataBuffer {
  86964. private _buffer;
  86965. constructor(resource: WebGLBuffer);
  86966. readonly underlyingResource: any;
  86967. }
  86968. }
  86969. declare module BABYLON {
  86970. /**
  86971. * Settings for finer control over video usage
  86972. */
  86973. export interface VideoTextureSettings {
  86974. /**
  86975. * Applies `autoplay` to video, if specified
  86976. */
  86977. autoPlay?: boolean;
  86978. /**
  86979. * Applies `loop` to video, if specified
  86980. */
  86981. loop?: boolean;
  86982. /**
  86983. * Automatically updates internal texture from video at every frame in the render loop
  86984. */
  86985. autoUpdateTexture: boolean;
  86986. /**
  86987. * Image src displayed during the video loading or until the user interacts with the video.
  86988. */
  86989. poster?: string;
  86990. }
  86991. /**
  86992. * If you want to display a video in your scene, this is the special texture for that.
  86993. * This special texture works similar to other textures, with the exception of a few parameters.
  86994. * @see https://doc.babylonjs.com/how_to/video_texture
  86995. */
  86996. export class VideoTexture extends Texture {
  86997. /**
  86998. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86999. */
  87000. readonly autoUpdateTexture: boolean;
  87001. /**
  87002. * The video instance used by the texture internally
  87003. */
  87004. readonly video: HTMLVideoElement;
  87005. private _onUserActionRequestedObservable;
  87006. /**
  87007. * Event triggerd when a dom action is required by the user to play the video.
  87008. * This happens due to recent changes in browser policies preventing video to auto start.
  87009. */
  87010. readonly onUserActionRequestedObservable: Observable<Texture>;
  87011. private _generateMipMaps;
  87012. private _engine;
  87013. private _stillImageCaptured;
  87014. private _displayingPosterTexture;
  87015. private _settings;
  87016. private _createInternalTextureOnEvent;
  87017. /**
  87018. * Creates a video texture.
  87019. * If you want to display a video in your scene, this is the special texture for that.
  87020. * This special texture works similar to other textures, with the exception of a few parameters.
  87021. * @see https://doc.babylonjs.com/how_to/video_texture
  87022. * @param name optional name, will detect from video source, if not defined
  87023. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  87024. * @param scene is obviously the current scene.
  87025. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  87026. * @param invertY is false by default but can be used to invert video on Y axis
  87027. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  87028. * @param settings allows finer control over video usage
  87029. */
  87030. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  87031. private _getName;
  87032. private _getVideo;
  87033. private _createInternalTexture;
  87034. private reset;
  87035. /**
  87036. * @hidden Internal method to initiate `update`.
  87037. */
  87038. _rebuild(): void;
  87039. /**
  87040. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  87041. */
  87042. update(): void;
  87043. /**
  87044. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  87045. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  87046. */
  87047. updateTexture(isVisible: boolean): void;
  87048. protected _updateInternalTexture: () => void;
  87049. /**
  87050. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  87051. * @param url New url.
  87052. */
  87053. updateURL(url: string): void;
  87054. /**
  87055. * Dispose the texture and release its associated resources.
  87056. */
  87057. dispose(): void;
  87058. /**
  87059. * Creates a video texture straight from a stream.
  87060. * @param scene Define the scene the texture should be created in
  87061. * @param stream Define the stream the texture should be created from
  87062. * @returns The created video texture as a promise
  87063. */
  87064. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  87065. /**
  87066. * Creates a video texture straight from your WebCam video feed.
  87067. * @param scene Define the scene the texture should be created in
  87068. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  87069. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  87070. * @returns The created video texture as a promise
  87071. */
  87072. static CreateFromWebCamAsync(scene: Scene, constraints: {
  87073. minWidth: number;
  87074. maxWidth: number;
  87075. minHeight: number;
  87076. maxHeight: number;
  87077. deviceId: string;
  87078. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  87079. /**
  87080. * Creates a video texture straight from your WebCam video feed.
  87081. * @param scene Define the scene the texture should be created in
  87082. * @param onReady Define a callback to triggered once the texture will be ready
  87083. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  87084. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  87085. */
  87086. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  87087. minWidth: number;
  87088. maxWidth: number;
  87089. minHeight: number;
  87090. maxHeight: number;
  87091. deviceId: string;
  87092. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  87093. }
  87094. }
  87095. declare module BABYLON {
  87096. /**
  87097. * Interface for attribute information associated with buffer instanciation
  87098. */
  87099. export class InstancingAttributeInfo {
  87100. /**
  87101. * Index/offset of the attribute in the vertex shader
  87102. */
  87103. index: number;
  87104. /**
  87105. * size of the attribute, 1, 2, 3 or 4
  87106. */
  87107. attributeSize: number;
  87108. /**
  87109. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  87110. * default is FLOAT
  87111. */
  87112. attribyteType: number;
  87113. /**
  87114. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  87115. */
  87116. normalized: boolean;
  87117. /**
  87118. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  87119. */
  87120. offset: number;
  87121. /**
  87122. * Name of the GLSL attribute, for debugging purpose only
  87123. */
  87124. attributeName: string;
  87125. }
  87126. /**
  87127. * Define options used to create a depth texture
  87128. */
  87129. export class DepthTextureCreationOptions {
  87130. /** Specifies whether or not a stencil should be allocated in the texture */
  87131. generateStencil?: boolean;
  87132. /** Specifies whether or not bilinear filtering is enable on the texture */
  87133. bilinearFiltering?: boolean;
  87134. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87135. comparisonFunction?: number;
  87136. /** Specifies if the created texture is a cube texture */
  87137. isCube?: boolean;
  87138. }
  87139. /**
  87140. * Class used to describe the capabilities of the engine relatively to the current browser
  87141. */
  87142. export class EngineCapabilities {
  87143. /** Maximum textures units per fragment shader */
  87144. maxTexturesImageUnits: number;
  87145. /** Maximum texture units per vertex shader */
  87146. maxVertexTextureImageUnits: number;
  87147. /** Maximum textures units in the entire pipeline */
  87148. maxCombinedTexturesImageUnits: number;
  87149. /** Maximum texture size */
  87150. maxTextureSize: number;
  87151. /** Maximum cube texture size */
  87152. maxCubemapTextureSize: number;
  87153. /** Maximum render texture size */
  87154. maxRenderTextureSize: number;
  87155. /** Maximum number of vertex attributes */
  87156. maxVertexAttribs: number;
  87157. /** Maximum number of varyings */
  87158. maxVaryingVectors: number;
  87159. /** Maximum number of uniforms per vertex shader */
  87160. maxVertexUniformVectors: number;
  87161. /** Maximum number of uniforms per fragment shader */
  87162. maxFragmentUniformVectors: number;
  87163. /** Defines if standard derivates (dx/dy) are supported */
  87164. standardDerivatives: boolean;
  87165. /** Defines if s3tc texture compression is supported */
  87166. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  87167. /** Defines if pvrtc texture compression is supported */
  87168. pvrtc: any;
  87169. /** Defines if etc1 texture compression is supported */
  87170. etc1: any;
  87171. /** Defines if etc2 texture compression is supported */
  87172. etc2: any;
  87173. /** Defines if astc texture compression is supported */
  87174. astc: any;
  87175. /** Defines if float textures are supported */
  87176. textureFloat: boolean;
  87177. /** Defines if vertex array objects are supported */
  87178. vertexArrayObject: boolean;
  87179. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87180. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87181. /** Gets the maximum level of anisotropy supported */
  87182. maxAnisotropy: number;
  87183. /** Defines if instancing is supported */
  87184. instancedArrays: boolean;
  87185. /** Defines if 32 bits indices are supported */
  87186. uintIndices: boolean;
  87187. /** Defines if high precision shaders are supported */
  87188. highPrecisionShaderSupported: boolean;
  87189. /** Defines if depth reading in the fragment shader is supported */
  87190. fragmentDepthSupported: boolean;
  87191. /** Defines if float texture linear filtering is supported*/
  87192. textureFloatLinearFiltering: boolean;
  87193. /** Defines if rendering to float textures is supported */
  87194. textureFloatRender: boolean;
  87195. /** Defines if half float textures are supported*/
  87196. textureHalfFloat: boolean;
  87197. /** Defines if half float texture linear filtering is supported*/
  87198. textureHalfFloatLinearFiltering: boolean;
  87199. /** Defines if rendering to half float textures is supported */
  87200. textureHalfFloatRender: boolean;
  87201. /** Defines if textureLOD shader command is supported */
  87202. textureLOD: boolean;
  87203. /** Defines if draw buffers extension is supported */
  87204. drawBuffersExtension: boolean;
  87205. /** Defines if depth textures are supported */
  87206. depthTextureExtension: boolean;
  87207. /** Defines if float color buffer are supported */
  87208. colorBufferFloat: boolean;
  87209. /** Gets disjoint timer query extension (null if not supported) */
  87210. timerQuery: EXT_disjoint_timer_query;
  87211. /** Defines if timestamp can be used with timer query */
  87212. canUseTimestampForTimerQuery: boolean;
  87213. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87214. multiview: any;
  87215. /** Function used to let the system compiles shaders in background */
  87216. parallelShaderCompile: {
  87217. COMPLETION_STATUS_KHR: number;
  87218. };
  87219. }
  87220. /** Interface defining initialization parameters for Engine class */
  87221. export interface EngineOptions extends WebGLContextAttributes {
  87222. /**
  87223. * Defines if the engine should no exceed a specified device ratio
  87224. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87225. */
  87226. limitDeviceRatio?: number;
  87227. /**
  87228. * Defines if webvr should be enabled automatically
  87229. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87230. */
  87231. autoEnableWebVR?: boolean;
  87232. /**
  87233. * Defines if webgl2 should be turned off even if supported
  87234. * @see http://doc.babylonjs.com/features/webgl2
  87235. */
  87236. disableWebGL2Support?: boolean;
  87237. /**
  87238. * Defines if webaudio should be initialized as well
  87239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87240. */
  87241. audioEngine?: boolean;
  87242. /**
  87243. * Defines if animations should run using a deterministic lock step
  87244. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87245. */
  87246. deterministicLockstep?: boolean;
  87247. /** Defines the maximum steps to use with deterministic lock step mode */
  87248. lockstepMaxSteps?: number;
  87249. /**
  87250. * Defines that engine should ignore context lost events
  87251. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87252. */
  87253. doNotHandleContextLost?: boolean;
  87254. /**
  87255. * Defines that engine should ignore modifying touch action attribute and style
  87256. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87257. */
  87258. doNotHandleTouchAction?: boolean;
  87259. /**
  87260. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87261. */
  87262. useHighPrecisionFloats?: boolean;
  87263. }
  87264. /**
  87265. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87266. */
  87267. export class Engine {
  87268. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87269. static ExceptionList: ({
  87270. key: string;
  87271. capture: string;
  87272. captureConstraint: number;
  87273. targets: string[];
  87274. } | {
  87275. key: string;
  87276. capture: null;
  87277. captureConstraint: null;
  87278. targets: string[];
  87279. })[];
  87280. /** Gets the list of created engines */
  87281. static readonly Instances: Engine[];
  87282. /**
  87283. * Gets the latest created engine
  87284. */
  87285. static readonly LastCreatedEngine: Nullable<Engine>;
  87286. /**
  87287. * Gets the latest created scene
  87288. */
  87289. static readonly LastCreatedScene: Nullable<Scene>;
  87290. /**
  87291. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87292. * @param flag defines which part of the materials must be marked as dirty
  87293. * @param predicate defines a predicate used to filter which materials should be affected
  87294. */
  87295. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87296. /**
  87297. * Hidden
  87298. */
  87299. static _TextureLoaders: IInternalTextureLoader[];
  87300. /** Defines that alpha blending is disabled */
  87301. static readonly ALPHA_DISABLE: number;
  87302. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87303. static readonly ALPHA_ADD: number;
  87304. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87305. static readonly ALPHA_COMBINE: number;
  87306. /** Defines that alpha blending to DEST - SRC * DEST */
  87307. static readonly ALPHA_SUBTRACT: number;
  87308. /** Defines that alpha blending to SRC * DEST */
  87309. static readonly ALPHA_MULTIPLY: number;
  87310. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87311. static readonly ALPHA_MAXIMIZED: number;
  87312. /** Defines that alpha blending to SRC + DEST */
  87313. static readonly ALPHA_ONEONE: number;
  87314. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87315. static readonly ALPHA_PREMULTIPLIED: number;
  87316. /**
  87317. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87318. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87319. */
  87320. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87321. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87322. static readonly ALPHA_INTERPOLATE: number;
  87323. /**
  87324. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87325. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87326. */
  87327. static readonly ALPHA_SCREENMODE: number;
  87328. /** Defines that the ressource is not delayed*/
  87329. static readonly DELAYLOADSTATE_NONE: number;
  87330. /** Defines that the ressource was successfully delay loaded */
  87331. static readonly DELAYLOADSTATE_LOADED: number;
  87332. /** Defines that the ressource is currently delay loading */
  87333. static readonly DELAYLOADSTATE_LOADING: number;
  87334. /** Defines that the ressource is delayed and has not started loading */
  87335. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87336. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87337. static readonly NEVER: number;
  87338. /** 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 */
  87339. static readonly ALWAYS: number;
  87340. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87341. static readonly LESS: number;
  87342. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87343. static readonly EQUAL: number;
  87344. /** 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 */
  87345. static readonly LEQUAL: number;
  87346. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87347. static readonly GREATER: number;
  87348. /** 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 */
  87349. static readonly GEQUAL: number;
  87350. /** 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 */
  87351. static readonly NOTEQUAL: number;
  87352. /** Passed to stencilOperation to specify that stencil value must be kept */
  87353. static readonly KEEP: number;
  87354. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87355. static readonly REPLACE: number;
  87356. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87357. static readonly INCR: number;
  87358. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87359. static readonly DECR: number;
  87360. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87361. static readonly INVERT: number;
  87362. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87363. static readonly INCR_WRAP: number;
  87364. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87365. static readonly DECR_WRAP: number;
  87366. /** Texture is not repeating outside of 0..1 UVs */
  87367. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87368. /** Texture is repeating outside of 0..1 UVs */
  87369. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87370. /** Texture is repeating and mirrored */
  87371. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87372. /** ALPHA */
  87373. static readonly TEXTUREFORMAT_ALPHA: number;
  87374. /** LUMINANCE */
  87375. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87376. /** LUMINANCE_ALPHA */
  87377. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87378. /** RGB */
  87379. static readonly TEXTUREFORMAT_RGB: number;
  87380. /** RGBA */
  87381. static readonly TEXTUREFORMAT_RGBA: number;
  87382. /** RED */
  87383. static readonly TEXTUREFORMAT_RED: number;
  87384. /** RED (2nd reference) */
  87385. static readonly TEXTUREFORMAT_R: number;
  87386. /** RG */
  87387. static readonly TEXTUREFORMAT_RG: number;
  87388. /** RED_INTEGER */
  87389. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87390. /** RED_INTEGER (2nd reference) */
  87391. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87392. /** RG_INTEGER */
  87393. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87394. /** RGB_INTEGER */
  87395. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87396. /** RGBA_INTEGER */
  87397. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87398. /** UNSIGNED_BYTE */
  87399. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87400. /** UNSIGNED_BYTE (2nd reference) */
  87401. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87402. /** FLOAT */
  87403. static readonly TEXTURETYPE_FLOAT: number;
  87404. /** HALF_FLOAT */
  87405. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87406. /** BYTE */
  87407. static readonly TEXTURETYPE_BYTE: number;
  87408. /** SHORT */
  87409. static readonly TEXTURETYPE_SHORT: number;
  87410. /** UNSIGNED_SHORT */
  87411. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87412. /** INT */
  87413. static readonly TEXTURETYPE_INT: number;
  87414. /** UNSIGNED_INT */
  87415. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87416. /** UNSIGNED_SHORT_4_4_4_4 */
  87417. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87418. /** UNSIGNED_SHORT_5_5_5_1 */
  87419. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87420. /** UNSIGNED_SHORT_5_6_5 */
  87421. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87422. /** UNSIGNED_INT_2_10_10_10_REV */
  87423. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87424. /** UNSIGNED_INT_24_8 */
  87425. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87426. /** UNSIGNED_INT_10F_11F_11F_REV */
  87427. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87428. /** UNSIGNED_INT_5_9_9_9_REV */
  87429. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87430. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87431. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87432. /** nearest is mag = nearest and min = nearest and mip = linear */
  87433. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87434. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87435. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87436. /** Trilinear is mag = linear and min = linear and mip = linear */
  87437. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87438. /** nearest is mag = nearest and min = nearest and mip = linear */
  87439. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87440. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87441. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87442. /** Trilinear is mag = linear and min = linear and mip = linear */
  87443. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87444. /** mag = nearest and min = nearest and mip = nearest */
  87445. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87446. /** mag = nearest and min = linear and mip = nearest */
  87447. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87448. /** mag = nearest and min = linear and mip = linear */
  87449. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87450. /** mag = nearest and min = linear and mip = none */
  87451. static readonly TEXTURE_NEAREST_LINEAR: number;
  87452. /** mag = nearest and min = nearest and mip = none */
  87453. static readonly TEXTURE_NEAREST_NEAREST: number;
  87454. /** mag = linear and min = nearest and mip = nearest */
  87455. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87456. /** mag = linear and min = nearest and mip = linear */
  87457. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87458. /** mag = linear and min = linear and mip = none */
  87459. static readonly TEXTURE_LINEAR_LINEAR: number;
  87460. /** mag = linear and min = nearest and mip = none */
  87461. static readonly TEXTURE_LINEAR_NEAREST: number;
  87462. /** Explicit coordinates mode */
  87463. static readonly TEXTURE_EXPLICIT_MODE: number;
  87464. /** Spherical coordinates mode */
  87465. static readonly TEXTURE_SPHERICAL_MODE: number;
  87466. /** Planar coordinates mode */
  87467. static readonly TEXTURE_PLANAR_MODE: number;
  87468. /** Cubic coordinates mode */
  87469. static readonly TEXTURE_CUBIC_MODE: number;
  87470. /** Projection coordinates mode */
  87471. static readonly TEXTURE_PROJECTION_MODE: number;
  87472. /** Skybox coordinates mode */
  87473. static readonly TEXTURE_SKYBOX_MODE: number;
  87474. /** Inverse Cubic coordinates mode */
  87475. static readonly TEXTURE_INVCUBIC_MODE: number;
  87476. /** Equirectangular coordinates mode */
  87477. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87478. /** Equirectangular Fixed coordinates mode */
  87479. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87480. /** Equirectangular Fixed Mirrored coordinates mode */
  87481. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87482. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87483. static readonly SCALEMODE_FLOOR: number;
  87484. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87485. static readonly SCALEMODE_NEAREST: number;
  87486. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87487. static readonly SCALEMODE_CEILING: number;
  87488. /**
  87489. * Returns the current npm package of the sdk
  87490. */
  87491. static readonly NpmPackage: string;
  87492. /**
  87493. * Returns the current version of the framework
  87494. */
  87495. static readonly Version: string;
  87496. /**
  87497. * Returns a string describing the current engine
  87498. */
  87499. readonly description: string;
  87500. /**
  87501. * Gets or sets the epsilon value used by collision engine
  87502. */
  87503. static CollisionsEpsilon: number;
  87504. /**
  87505. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87506. */
  87507. static ShadersRepository: string;
  87508. /**
  87509. * Method called to create the default loading screen.
  87510. * This can be overriden in your own app.
  87511. * @param canvas The rendering canvas element
  87512. * @returns The loading screen
  87513. */
  87514. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87515. /**
  87516. * Method called to create the default rescale post process on each engine.
  87517. */
  87518. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87519. /**
  87520. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87521. */
  87522. forcePOTTextures: boolean;
  87523. /**
  87524. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87525. */
  87526. isFullscreen: boolean;
  87527. /**
  87528. * Gets a boolean indicating if the pointer is currently locked
  87529. */
  87530. isPointerLock: boolean;
  87531. /**
  87532. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87533. */
  87534. cullBackFaces: boolean;
  87535. /**
  87536. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87537. */
  87538. renderEvenInBackground: boolean;
  87539. /**
  87540. * Gets or sets a boolean indicating that cache can be kept between frames
  87541. */
  87542. preventCacheWipeBetweenFrames: boolean;
  87543. /**
  87544. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87545. **/
  87546. enableOfflineSupport: boolean;
  87547. /**
  87548. * 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)
  87549. **/
  87550. disableManifestCheck: boolean;
  87551. /**
  87552. * Gets the list of created scenes
  87553. */
  87554. scenes: Scene[];
  87555. /**
  87556. * Event raised when a new scene is created
  87557. */
  87558. onNewSceneAddedObservable: Observable<Scene>;
  87559. /**
  87560. * Gets the list of created postprocesses
  87561. */
  87562. postProcesses: PostProcess[];
  87563. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87564. validateShaderPrograms: boolean;
  87565. /**
  87566. * Observable event triggered each time the rendering canvas is resized
  87567. */
  87568. onResizeObservable: Observable<Engine>;
  87569. /**
  87570. * Observable event triggered each time the canvas loses focus
  87571. */
  87572. onCanvasBlurObservable: Observable<Engine>;
  87573. /**
  87574. * Observable event triggered each time the canvas gains focus
  87575. */
  87576. onCanvasFocusObservable: Observable<Engine>;
  87577. /**
  87578. * Observable event triggered each time the canvas receives pointerout event
  87579. */
  87580. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87581. /**
  87582. * Observable event triggered before each texture is initialized
  87583. */
  87584. onBeforeTextureInitObservable: Observable<Texture>;
  87585. /**
  87586. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87587. */
  87588. disableUniformBuffers: boolean;
  87589. /** @hidden */
  87590. _uniformBuffers: UniformBuffer[];
  87591. /**
  87592. * Gets a boolean indicating that the engine supports uniform buffers
  87593. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87594. */
  87595. readonly supportsUniformBuffers: boolean;
  87596. /**
  87597. * Observable raised when the engine begins a new frame
  87598. */
  87599. onBeginFrameObservable: Observable<Engine>;
  87600. /**
  87601. * If set, will be used to request the next animation frame for the render loop
  87602. */
  87603. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87604. /**
  87605. * Observable raised when the engine ends the current frame
  87606. */
  87607. onEndFrameObservable: Observable<Engine>;
  87608. /**
  87609. * Observable raised when the engine is about to compile a shader
  87610. */
  87611. onBeforeShaderCompilationObservable: Observable<Engine>;
  87612. /**
  87613. * Observable raised when the engine has jsut compiled a shader
  87614. */
  87615. onAfterShaderCompilationObservable: Observable<Engine>;
  87616. /** @hidden */
  87617. _gl: WebGLRenderingContext;
  87618. private _renderingCanvas;
  87619. private _windowIsBackground;
  87620. private _webGLVersion;
  87621. protected _highPrecisionShadersAllowed: boolean;
  87622. /** @hidden */
  87623. readonly _shouldUseHighPrecisionShader: boolean;
  87624. /**
  87625. * Gets a boolean indicating that only power of 2 textures are supported
  87626. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87627. */
  87628. readonly needPOTTextures: boolean;
  87629. /** @hidden */
  87630. _badOS: boolean;
  87631. /** @hidden */
  87632. _badDesktopOS: boolean;
  87633. /**
  87634. * Gets the audio engine
  87635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87636. * @ignorenaming
  87637. */
  87638. static audioEngine: IAudioEngine;
  87639. /**
  87640. * Default AudioEngine factory responsible of creating the Audio Engine.
  87641. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87642. */
  87643. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87644. /**
  87645. * Default offline support factory responsible of creating a tool used to store data locally.
  87646. * By default, this will create a Database object if the workload has been embedded.
  87647. */
  87648. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87649. private _onFocus;
  87650. private _onBlur;
  87651. private _onCanvasPointerOut;
  87652. private _onCanvasBlur;
  87653. private _onCanvasFocus;
  87654. private _onFullscreenChange;
  87655. private _onPointerLockChange;
  87656. private _hardwareScalingLevel;
  87657. /** @hidden */
  87658. _caps: EngineCapabilities;
  87659. private _pointerLockRequested;
  87660. private _isStencilEnable;
  87661. private _colorWrite;
  87662. private _loadingScreen;
  87663. /** @hidden */
  87664. _drawCalls: PerfCounter;
  87665. private _glVersion;
  87666. private _glRenderer;
  87667. private _glVendor;
  87668. private _videoTextureSupported;
  87669. private _renderingQueueLaunched;
  87670. private _activeRenderLoops;
  87671. private _deterministicLockstep;
  87672. private _lockstepMaxSteps;
  87673. /**
  87674. * Observable signaled when a context lost event is raised
  87675. */
  87676. onContextLostObservable: Observable<Engine>;
  87677. /**
  87678. * Observable signaled when a context restored event is raised
  87679. */
  87680. onContextRestoredObservable: Observable<Engine>;
  87681. private _onContextLost;
  87682. private _onContextRestored;
  87683. private _contextWasLost;
  87684. /** @hidden */
  87685. _doNotHandleContextLost: boolean;
  87686. /**
  87687. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87688. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87689. */
  87690. doNotHandleContextLost: boolean;
  87691. private _performanceMonitor;
  87692. private _fps;
  87693. private _deltaTime;
  87694. /**
  87695. * Turn this value on if you want to pause FPS computation when in background
  87696. */
  87697. disablePerformanceMonitorInBackground: boolean;
  87698. /**
  87699. * Gets the performance monitor attached to this engine
  87700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87701. */
  87702. readonly performanceMonitor: PerformanceMonitor;
  87703. /**
  87704. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87705. */
  87706. disableVertexArrayObjects: boolean;
  87707. /** @hidden */
  87708. protected _depthCullingState: _DepthCullingState;
  87709. /** @hidden */
  87710. protected _stencilState: _StencilState;
  87711. /** @hidden */
  87712. protected _alphaState: _AlphaState;
  87713. /** @hidden */
  87714. protected _alphaMode: number;
  87715. /** @hidden */
  87716. _internalTexturesCache: InternalTexture[];
  87717. /** @hidden */
  87718. protected _activeChannel: number;
  87719. private _currentTextureChannel;
  87720. /** @hidden */
  87721. protected _boundTexturesCache: {
  87722. [key: string]: Nullable<InternalTexture>;
  87723. };
  87724. /** @hidden */
  87725. protected _currentEffect: Nullable<Effect>;
  87726. /** @hidden */
  87727. protected _currentProgram: Nullable<WebGLProgram>;
  87728. private _compiledEffects;
  87729. private _vertexAttribArraysEnabled;
  87730. /** @hidden */
  87731. protected _cachedViewport: Nullable<Viewport>;
  87732. private _cachedVertexArrayObject;
  87733. /** @hidden */
  87734. protected _cachedVertexBuffers: any;
  87735. /** @hidden */
  87736. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87737. /** @hidden */
  87738. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87739. /** @hidden */
  87740. _currentRenderTarget: Nullable<InternalTexture>;
  87741. private _uintIndicesCurrentlySet;
  87742. private _currentBoundBuffer;
  87743. /** @hidden */
  87744. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87745. private _currentBufferPointers;
  87746. private _currentInstanceLocations;
  87747. private _currentInstanceBuffers;
  87748. private _textureUnits;
  87749. /** @hidden */
  87750. _workingCanvas: Nullable<HTMLCanvasElement>;
  87751. /** @hidden */
  87752. _workingContext: Nullable<CanvasRenderingContext2D>;
  87753. private _rescalePostProcess;
  87754. private _dummyFramebuffer;
  87755. private _externalData;
  87756. /** @hidden */
  87757. _bindedRenderFunction: any;
  87758. private _vaoRecordInProgress;
  87759. private _mustWipeVertexAttributes;
  87760. private _emptyTexture;
  87761. private _emptyCubeTexture;
  87762. private _emptyTexture3D;
  87763. /** @hidden */
  87764. _frameHandler: number;
  87765. private _nextFreeTextureSlots;
  87766. private _maxSimultaneousTextures;
  87767. private _activeRequests;
  87768. private _texturesSupported;
  87769. /** @hidden */
  87770. _textureFormatInUse: Nullable<string>;
  87771. /**
  87772. * Gets the list of texture formats supported
  87773. */
  87774. readonly texturesSupported: Array<string>;
  87775. /**
  87776. * Gets the list of texture formats in use
  87777. */
  87778. readonly textureFormatInUse: Nullable<string>;
  87779. /**
  87780. * Gets the current viewport
  87781. */
  87782. readonly currentViewport: Nullable<Viewport>;
  87783. /**
  87784. * Gets the default empty texture
  87785. */
  87786. readonly emptyTexture: InternalTexture;
  87787. /**
  87788. * Gets the default empty 3D texture
  87789. */
  87790. readonly emptyTexture3D: InternalTexture;
  87791. /**
  87792. * Gets the default empty cube texture
  87793. */
  87794. readonly emptyCubeTexture: InternalTexture;
  87795. /**
  87796. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87797. */
  87798. readonly premultipliedAlpha: boolean;
  87799. /**
  87800. * Creates a new engine
  87801. * @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
  87802. * @param antialias defines enable antialiasing (default: false)
  87803. * @param options defines further options to be sent to the getContext() function
  87804. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87805. */
  87806. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87807. /**
  87808. * Initializes a webVR display and starts listening to display change events
  87809. * The onVRDisplayChangedObservable will be notified upon these changes
  87810. * @returns The onVRDisplayChangedObservable
  87811. */
  87812. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87813. /** @hidden */
  87814. _prepareVRComponent(): void;
  87815. /** @hidden */
  87816. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87817. /** @hidden */
  87818. _submitVRFrame(): void;
  87819. /**
  87820. * Call this function to leave webVR mode
  87821. * Will do nothing if webVR is not supported or if there is no webVR device
  87822. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87823. */
  87824. disableVR(): void;
  87825. /**
  87826. * Gets a boolean indicating that the system is in VR mode and is presenting
  87827. * @returns true if VR mode is engaged
  87828. */
  87829. isVRPresenting(): boolean;
  87830. /** @hidden */
  87831. _requestVRFrame(): void;
  87832. private _disableTouchAction;
  87833. private _rebuildInternalTextures;
  87834. private _rebuildEffects;
  87835. /**
  87836. * Gets a boolean indicating if all created effects are ready
  87837. * @returns true if all effects are ready
  87838. */
  87839. areAllEffectsReady(): boolean;
  87840. private _rebuildBuffers;
  87841. private _initGLContext;
  87842. /**
  87843. * Gets version of the current webGL context
  87844. */
  87845. readonly webGLVersion: number;
  87846. /**
  87847. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87848. */
  87849. readonly isStencilEnable: boolean;
  87850. /** @hidden */
  87851. _prepareWorkingCanvas(): void;
  87852. /**
  87853. * Reset the texture cache to empty state
  87854. */
  87855. resetTextureCache(): void;
  87856. /**
  87857. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87858. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87859. * @returns true if engine is in deterministic lock step mode
  87860. */
  87861. isDeterministicLockStep(): boolean;
  87862. /**
  87863. * Gets the max steps when engine is running in deterministic lock step
  87864. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87865. * @returns the max steps
  87866. */
  87867. getLockstepMaxSteps(): number;
  87868. /**
  87869. * Gets an object containing information about the current webGL context
  87870. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87871. */
  87872. getGlInfo(): {
  87873. vendor: string;
  87874. renderer: string;
  87875. version: string;
  87876. };
  87877. /**
  87878. * Gets current aspect ratio
  87879. * @param camera defines the camera to use to get the aspect ratio
  87880. * @param useScreen defines if screen size must be used (or the current render target if any)
  87881. * @returns a number defining the aspect ratio
  87882. */
  87883. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87884. /**
  87885. * Gets current screen aspect ratio
  87886. * @returns a number defining the aspect ratio
  87887. */
  87888. getScreenAspectRatio(): number;
  87889. /**
  87890. * Gets the current render width
  87891. * @param useScreen defines if screen size must be used (or the current render target if any)
  87892. * @returns a number defining the current render width
  87893. */
  87894. getRenderWidth(useScreen?: boolean): number;
  87895. /**
  87896. * Gets the current render height
  87897. * @param useScreen defines if screen size must be used (or the current render target if any)
  87898. * @returns a number defining the current render height
  87899. */
  87900. getRenderHeight(useScreen?: boolean): number;
  87901. /**
  87902. * Gets the HTML canvas attached with the current webGL context
  87903. * @returns a HTML canvas
  87904. */
  87905. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87906. /**
  87907. * Gets the client rect of the HTML canvas attached with the current webGL context
  87908. * @returns a client rectanglee
  87909. */
  87910. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87911. /**
  87912. * Defines the hardware scaling level.
  87913. * By default the hardware scaling level is computed from the window device ratio.
  87914. * 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.
  87915. * @param level defines the level to use
  87916. */
  87917. setHardwareScalingLevel(level: number): void;
  87918. /**
  87919. * Gets the current hardware scaling level.
  87920. * By default the hardware scaling level is computed from the window device ratio.
  87921. * 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.
  87922. * @returns a number indicating the current hardware scaling level
  87923. */
  87924. getHardwareScalingLevel(): number;
  87925. /**
  87926. * Gets the list of loaded textures
  87927. * @returns an array containing all loaded textures
  87928. */
  87929. getLoadedTexturesCache(): InternalTexture[];
  87930. /**
  87931. * Gets the object containing all engine capabilities
  87932. * @returns the EngineCapabilities object
  87933. */
  87934. getCaps(): EngineCapabilities;
  87935. /**
  87936. * Gets the current depth function
  87937. * @returns a number defining the depth function
  87938. */
  87939. getDepthFunction(): Nullable<number>;
  87940. /**
  87941. * Sets the current depth function
  87942. * @param depthFunc defines the function to use
  87943. */
  87944. setDepthFunction(depthFunc: number): void;
  87945. /**
  87946. * Sets the current depth function to GREATER
  87947. */
  87948. setDepthFunctionToGreater(): void;
  87949. /**
  87950. * Sets the current depth function to GEQUAL
  87951. */
  87952. setDepthFunctionToGreaterOrEqual(): void;
  87953. /**
  87954. * Sets the current depth function to LESS
  87955. */
  87956. setDepthFunctionToLess(): void;
  87957. private _cachedStencilBuffer;
  87958. private _cachedStencilFunction;
  87959. private _cachedStencilMask;
  87960. private _cachedStencilOperationPass;
  87961. private _cachedStencilOperationFail;
  87962. private _cachedStencilOperationDepthFail;
  87963. private _cachedStencilReference;
  87964. /**
  87965. * Caches the the state of the stencil buffer
  87966. */
  87967. cacheStencilState(): void;
  87968. /**
  87969. * Restores the state of the stencil buffer
  87970. */
  87971. restoreStencilState(): void;
  87972. /**
  87973. * Sets the current depth function to LEQUAL
  87974. */
  87975. setDepthFunctionToLessOrEqual(): void;
  87976. /**
  87977. * Gets a boolean indicating if stencil buffer is enabled
  87978. * @returns the current stencil buffer state
  87979. */
  87980. getStencilBuffer(): boolean;
  87981. /**
  87982. * Enable or disable the stencil buffer
  87983. * @param enable defines if the stencil buffer must be enabled or disabled
  87984. */
  87985. setStencilBuffer(enable: boolean): void;
  87986. /**
  87987. * Gets the current stencil mask
  87988. * @returns a number defining the new stencil mask to use
  87989. */
  87990. getStencilMask(): number;
  87991. /**
  87992. * Sets the current stencil mask
  87993. * @param mask defines the new stencil mask to use
  87994. */
  87995. setStencilMask(mask: number): void;
  87996. /**
  87997. * Gets the current stencil function
  87998. * @returns a number defining the stencil function to use
  87999. */
  88000. getStencilFunction(): number;
  88001. /**
  88002. * Gets the current stencil reference value
  88003. * @returns a number defining the stencil reference value to use
  88004. */
  88005. getStencilFunctionReference(): number;
  88006. /**
  88007. * Gets the current stencil mask
  88008. * @returns a number defining the stencil mask to use
  88009. */
  88010. getStencilFunctionMask(): number;
  88011. /**
  88012. * Sets the current stencil function
  88013. * @param stencilFunc defines the new stencil function to use
  88014. */
  88015. setStencilFunction(stencilFunc: number): void;
  88016. /**
  88017. * Sets the current stencil reference
  88018. * @param reference defines the new stencil reference to use
  88019. */
  88020. setStencilFunctionReference(reference: number): void;
  88021. /**
  88022. * Sets the current stencil mask
  88023. * @param mask defines the new stencil mask to use
  88024. */
  88025. setStencilFunctionMask(mask: number): void;
  88026. /**
  88027. * Gets the current stencil operation when stencil fails
  88028. * @returns a number defining stencil operation to use when stencil fails
  88029. */
  88030. getStencilOperationFail(): number;
  88031. /**
  88032. * Gets the current stencil operation when depth fails
  88033. * @returns a number defining stencil operation to use when depth fails
  88034. */
  88035. getStencilOperationDepthFail(): number;
  88036. /**
  88037. * Gets the current stencil operation when stencil passes
  88038. * @returns a number defining stencil operation to use when stencil passes
  88039. */
  88040. getStencilOperationPass(): number;
  88041. /**
  88042. * Sets the stencil operation to use when stencil fails
  88043. * @param operation defines the stencil operation to use when stencil fails
  88044. */
  88045. setStencilOperationFail(operation: number): void;
  88046. /**
  88047. * Sets the stencil operation to use when depth fails
  88048. * @param operation defines the stencil operation to use when depth fails
  88049. */
  88050. setStencilOperationDepthFail(operation: number): void;
  88051. /**
  88052. * Sets the stencil operation to use when stencil passes
  88053. * @param operation defines the stencil operation to use when stencil passes
  88054. */
  88055. setStencilOperationPass(operation: number): void;
  88056. /**
  88057. * Sets a boolean indicating if the dithering state is enabled or disabled
  88058. * @param value defines the dithering state
  88059. */
  88060. setDitheringState(value: boolean): void;
  88061. /**
  88062. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  88063. * @param value defines the rasterizer state
  88064. */
  88065. setRasterizerState(value: boolean): void;
  88066. /**
  88067. * stop executing a render loop function and remove it from the execution array
  88068. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  88069. */
  88070. stopRenderLoop(renderFunction?: () => void): void;
  88071. /** @hidden */
  88072. _renderLoop(): void;
  88073. /**
  88074. * Register and execute a render loop. The engine can have more than one render function
  88075. * @param renderFunction defines the function to continuously execute
  88076. */
  88077. runRenderLoop(renderFunction: () => void): void;
  88078. /**
  88079. * Toggle full screen mode
  88080. * @param requestPointerLock defines if a pointer lock should be requested from the user
  88081. */
  88082. switchFullscreen(requestPointerLock: boolean): void;
  88083. /**
  88084. * Enters full screen mode
  88085. * @param requestPointerLock defines if a pointer lock should be requested from the user
  88086. */
  88087. enterFullscreen(requestPointerLock: boolean): void;
  88088. /**
  88089. * Exits full screen mode
  88090. */
  88091. exitFullscreen(): void;
  88092. /**
  88093. * Clear the current render buffer or the current render target (if any is set up)
  88094. * @param color defines the color to use
  88095. * @param backBuffer defines if the back buffer must be cleared
  88096. * @param depth defines if the depth buffer must be cleared
  88097. * @param stencil defines if the stencil buffer must be cleared
  88098. */
  88099. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  88100. /**
  88101. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  88102. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  88103. * @param y defines the y-coordinate of the corner of the clear rectangle
  88104. * @param width defines the width of the clear rectangle
  88105. * @param height defines the height of the clear rectangle
  88106. * @param clearColor defines the clear color
  88107. */
  88108. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  88109. /**
  88110. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  88111. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  88112. * @param y defines the y-coordinate of the corner of the clear rectangle
  88113. * @param width defines the width of the clear rectangle
  88114. * @param height defines the height of the clear rectangle
  88115. */
  88116. enableScissor(x: number, y: number, width: number, height: number): void;
  88117. /**
  88118. * Disable previously set scissor test rectangle
  88119. */
  88120. disableScissor(): void;
  88121. private _viewportCached;
  88122. /** @hidden */
  88123. _viewport(x: number, y: number, width: number, height: number): void;
  88124. /**
  88125. * Set the WebGL's viewport
  88126. * @param viewport defines the viewport element to be used
  88127. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  88128. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  88129. */
  88130. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  88131. /**
  88132. * Directly set the WebGL Viewport
  88133. * @param x defines the x coordinate of the viewport (in screen space)
  88134. * @param y defines the y coordinate of the viewport (in screen space)
  88135. * @param width defines the width of the viewport (in screen space)
  88136. * @param height defines the height of the viewport (in screen space)
  88137. * @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
  88138. */
  88139. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  88140. /**
  88141. * Begin a new frame
  88142. */
  88143. beginFrame(): void;
  88144. /**
  88145. * Enf the current frame
  88146. */
  88147. endFrame(): void;
  88148. /**
  88149. * Resize the view according to the canvas' size
  88150. */
  88151. resize(): void;
  88152. /**
  88153. * Force a specific size of the canvas
  88154. * @param width defines the new canvas' width
  88155. * @param height defines the new canvas' height
  88156. */
  88157. setSize(width: number, height: number): void;
  88158. /**
  88159. * Binds the frame buffer to the specified texture.
  88160. * @param texture The texture to render to or null for the default canvas
  88161. * @param faceIndex The face of the texture to render to in case of cube texture
  88162. * @param requiredWidth The width of the target to render to
  88163. * @param requiredHeight The height of the target to render to
  88164. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  88165. * @param depthStencilTexture The depth stencil texture to use to render
  88166. * @param lodLevel defines le lod level to bind to the frame buffer
  88167. */
  88168. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  88169. /** @hidden */
  88170. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  88171. /**
  88172. * Unbind the current render target texture from the webGL context
  88173. * @param texture defines the render target texture to unbind
  88174. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  88175. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  88176. */
  88177. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  88178. /**
  88179. * Force the mipmap generation for the given render target texture
  88180. * @param texture defines the render target texture to use
  88181. */
  88182. generateMipMapsForCubemap(texture: InternalTexture): void;
  88183. /**
  88184. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88185. */
  88186. flushFramebuffer(): void;
  88187. /**
  88188. * Unbind the current render target and bind the default framebuffer
  88189. */
  88190. restoreDefaultFramebuffer(): void;
  88191. /**
  88192. * Create an uniform buffer
  88193. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88194. * @param elements defines the content of the uniform buffer
  88195. * @returns the webGL uniform buffer
  88196. */
  88197. createUniformBuffer(elements: FloatArray): DataBuffer;
  88198. /**
  88199. * Create a dynamic uniform buffer
  88200. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88201. * @param elements defines the content of the uniform buffer
  88202. * @returns the webGL uniform buffer
  88203. */
  88204. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88205. /**
  88206. * Update an existing uniform buffer
  88207. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88208. * @param uniformBuffer defines the target uniform buffer
  88209. * @param elements defines the content to update
  88210. * @param offset defines the offset in the uniform buffer where update should start
  88211. * @param count defines the size of the data to update
  88212. */
  88213. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88214. private _resetVertexBufferBinding;
  88215. /**
  88216. * Creates a vertex buffer
  88217. * @param data the data for the vertex buffer
  88218. * @returns the new WebGL static buffer
  88219. */
  88220. createVertexBuffer(data: DataArray): DataBuffer;
  88221. /**
  88222. * Creates a dynamic vertex buffer
  88223. * @param data the data for the dynamic vertex buffer
  88224. * @returns the new WebGL dynamic buffer
  88225. */
  88226. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88227. /**
  88228. * Update a dynamic index buffer
  88229. * @param indexBuffer defines the target index buffer
  88230. * @param indices defines the data to update
  88231. * @param offset defines the offset in the target index buffer where update should start
  88232. */
  88233. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88234. /**
  88235. * Updates a dynamic vertex buffer.
  88236. * @param vertexBuffer the vertex buffer to update
  88237. * @param data the data used to update the vertex buffer
  88238. * @param byteOffset the byte offset of the data
  88239. * @param byteLength the byte length of the data
  88240. */
  88241. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88242. private _resetIndexBufferBinding;
  88243. /**
  88244. * Creates a new index buffer
  88245. * @param indices defines the content of the index buffer
  88246. * @param updatable defines if the index buffer must be updatable
  88247. * @returns a new webGL buffer
  88248. */
  88249. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88250. /**
  88251. * Bind a webGL buffer to the webGL context
  88252. * @param buffer defines the buffer to bind
  88253. */
  88254. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88255. /**
  88256. * Bind an uniform buffer to the current webGL context
  88257. * @param buffer defines the buffer to bind
  88258. */
  88259. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88260. /**
  88261. * Bind a buffer to the current webGL context at a given location
  88262. * @param buffer defines the buffer to bind
  88263. * @param location defines the index where to bind the buffer
  88264. */
  88265. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88266. /**
  88267. * Bind a specific block at a given index in a specific shader program
  88268. * @param pipelineContext defines the pipeline context to use
  88269. * @param blockName defines the block name
  88270. * @param index defines the index where to bind the block
  88271. */
  88272. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88273. private bindIndexBuffer;
  88274. private bindBuffer;
  88275. /**
  88276. * update the bound buffer with the given data
  88277. * @param data defines the data to update
  88278. */
  88279. updateArrayBuffer(data: Float32Array): void;
  88280. private _vertexAttribPointer;
  88281. private _bindIndexBufferWithCache;
  88282. private _bindVertexBuffersAttributes;
  88283. /**
  88284. * Records a vertex array object
  88285. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88286. * @param vertexBuffers defines the list of vertex buffers to store
  88287. * @param indexBuffer defines the index buffer to store
  88288. * @param effect defines the effect to store
  88289. * @returns the new vertex array object
  88290. */
  88291. recordVertexArrayObject(vertexBuffers: {
  88292. [key: string]: VertexBuffer;
  88293. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88294. /**
  88295. * Bind a specific vertex array object
  88296. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88297. * @param vertexArrayObject defines the vertex array object to bind
  88298. * @param indexBuffer defines the index buffer to bind
  88299. */
  88300. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88301. /**
  88302. * Bind webGl buffers directly to the webGL context
  88303. * @param vertexBuffer defines the vertex buffer to bind
  88304. * @param indexBuffer defines the index buffer to bind
  88305. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88306. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88307. * @param effect defines the effect associated with the vertex buffer
  88308. */
  88309. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88310. private _unbindVertexArrayObject;
  88311. /**
  88312. * Bind a list of vertex buffers to the webGL context
  88313. * @param vertexBuffers defines the list of vertex buffers to bind
  88314. * @param indexBuffer defines the index buffer to bind
  88315. * @param effect defines the effect associated with the vertex buffers
  88316. */
  88317. bindBuffers(vertexBuffers: {
  88318. [key: string]: Nullable<VertexBuffer>;
  88319. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88320. /**
  88321. * Unbind all instance attributes
  88322. */
  88323. unbindInstanceAttributes(): void;
  88324. /**
  88325. * Release and free the memory of a vertex array object
  88326. * @param vao defines the vertex array object to delete
  88327. */
  88328. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88329. /** @hidden */
  88330. _releaseBuffer(buffer: DataBuffer): boolean;
  88331. /**
  88332. * Creates a webGL buffer to use with instanciation
  88333. * @param capacity defines the size of the buffer
  88334. * @returns the webGL buffer
  88335. */
  88336. createInstancesBuffer(capacity: number): DataBuffer;
  88337. /**
  88338. * Delete a webGL buffer used with instanciation
  88339. * @param buffer defines the webGL buffer to delete
  88340. */
  88341. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88342. /**
  88343. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88344. * @param instancesBuffer defines the webGL buffer to update and bind
  88345. * @param data defines the data to store in the buffer
  88346. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88347. */
  88348. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88349. /**
  88350. * Apply all cached states (depth, culling, stencil and alpha)
  88351. */
  88352. applyStates(): void;
  88353. /**
  88354. * Send a draw order
  88355. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88356. * @param indexStart defines the starting index
  88357. * @param indexCount defines the number of index to draw
  88358. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88359. */
  88360. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88361. /**
  88362. * Draw a list of points
  88363. * @param verticesStart defines the index of first vertex to draw
  88364. * @param verticesCount defines the count of vertices to draw
  88365. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88366. */
  88367. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88368. /**
  88369. * Draw a list of unindexed primitives
  88370. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88371. * @param verticesStart defines the index of first vertex to draw
  88372. * @param verticesCount defines the count of vertices to draw
  88373. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88374. */
  88375. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88376. /**
  88377. * Draw a list of indexed primitives
  88378. * @param fillMode defines the primitive to use
  88379. * @param indexStart defines the starting index
  88380. * @param indexCount defines the number of index to draw
  88381. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88382. */
  88383. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88384. /**
  88385. * Draw a list of unindexed primitives
  88386. * @param fillMode defines the primitive to use
  88387. * @param verticesStart defines the index of first vertex to draw
  88388. * @param verticesCount defines the count of vertices to draw
  88389. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88390. */
  88391. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88392. private _drawMode;
  88393. /** @hidden */
  88394. _releaseEffect(effect: Effect): void;
  88395. /** @hidden */
  88396. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88397. /**
  88398. * Create a new effect (used to store vertex/fragment shaders)
  88399. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88400. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88401. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88402. * @param samplers defines an array of string used to represent textures
  88403. * @param defines defines the string containing the defines to use to compile the shaders
  88404. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88405. * @param onCompiled defines a function to call when the effect creation is successful
  88406. * @param onError defines a function to call when the effect creation has failed
  88407. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88408. * @returns the new Effect
  88409. */
  88410. 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;
  88411. private _compileShader;
  88412. private _compileRawShader;
  88413. /**
  88414. * Directly creates a webGL program
  88415. * @param pipelineContext defines the pipeline context to attach to
  88416. * @param vertexCode defines the vertex shader code to use
  88417. * @param fragmentCode defines the fragment shader code to use
  88418. * @param context defines the webGL context to use (if not set, the current one will be used)
  88419. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88420. * @returns the new webGL program
  88421. */
  88422. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88423. /**
  88424. * Creates a webGL program
  88425. * @param pipelineContext defines the pipeline context to attach to
  88426. * @param vertexCode defines the vertex shader code to use
  88427. * @param fragmentCode defines the fragment shader code to use
  88428. * @param defines defines the string containing the defines to use to compile the shaders
  88429. * @param context defines the webGL context to use (if not set, the current one will be used)
  88430. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88431. * @returns the new webGL program
  88432. */
  88433. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88434. /**
  88435. * Creates a new pipeline context
  88436. * @returns the new pipeline
  88437. */
  88438. createPipelineContext(): WebGLPipelineContext;
  88439. private _createShaderProgram;
  88440. private _finalizePipelineContext;
  88441. /** @hidden */
  88442. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88443. /** @hidden */
  88444. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88445. /** @hidden */
  88446. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88447. /**
  88448. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88449. * @param pipelineContext defines the pipeline context to use
  88450. * @param uniformsNames defines the list of uniform names
  88451. * @returns an array of webGL uniform locations
  88452. */
  88453. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88454. /**
  88455. * Gets the lsit of active attributes for a given webGL program
  88456. * @param pipelineContext defines the pipeline context to use
  88457. * @param attributesNames defines the list of attribute names to get
  88458. * @returns an array of indices indicating the offset of each attribute
  88459. */
  88460. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88461. /**
  88462. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88463. * @param effect defines the effect to activate
  88464. */
  88465. enableEffect(effect: Nullable<Effect>): void;
  88466. /**
  88467. * Set the value of an uniform to an array of int32
  88468. * @param uniform defines the webGL uniform location where to store the value
  88469. * @param array defines the array of int32 to store
  88470. */
  88471. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88472. /**
  88473. * Set the value of an uniform to an array of int32 (stored as vec2)
  88474. * @param uniform defines the webGL uniform location where to store the value
  88475. * @param array defines the array of int32 to store
  88476. */
  88477. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88478. /**
  88479. * Set the value of an uniform to an array of int32 (stored as vec3)
  88480. * @param uniform defines the webGL uniform location where to store the value
  88481. * @param array defines the array of int32 to store
  88482. */
  88483. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88484. /**
  88485. * Set the value of an uniform to an array of int32 (stored as vec4)
  88486. * @param uniform defines the webGL uniform location where to store the value
  88487. * @param array defines the array of int32 to store
  88488. */
  88489. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88490. /**
  88491. * Set the value of an uniform to an array of float32
  88492. * @param uniform defines the webGL uniform location where to store the value
  88493. * @param array defines the array of float32 to store
  88494. */
  88495. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88496. /**
  88497. * Set the value of an uniform to an array of float32 (stored as vec2)
  88498. * @param uniform defines the webGL uniform location where to store the value
  88499. * @param array defines the array of float32 to store
  88500. */
  88501. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88502. /**
  88503. * Set the value of an uniform to an array of float32 (stored as vec3)
  88504. * @param uniform defines the webGL uniform location where to store the value
  88505. * @param array defines the array of float32 to store
  88506. */
  88507. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88508. /**
  88509. * Set the value of an uniform to an array of float32 (stored as vec4)
  88510. * @param uniform defines the webGL uniform location where to store the value
  88511. * @param array defines the array of float32 to store
  88512. */
  88513. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88514. /**
  88515. * Set the value of an uniform to an array of number
  88516. * @param uniform defines the webGL uniform location where to store the value
  88517. * @param array defines the array of number to store
  88518. */
  88519. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88520. /**
  88521. * Set the value of an uniform to an array of number (stored as vec2)
  88522. * @param uniform defines the webGL uniform location where to store the value
  88523. * @param array defines the array of number to store
  88524. */
  88525. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88526. /**
  88527. * Set the value of an uniform to an array of number (stored as vec3)
  88528. * @param uniform defines the webGL uniform location where to store the value
  88529. * @param array defines the array of number to store
  88530. */
  88531. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88532. /**
  88533. * Set the value of an uniform to an array of number (stored as vec4)
  88534. * @param uniform defines the webGL uniform location where to store the value
  88535. * @param array defines the array of number to store
  88536. */
  88537. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88538. /**
  88539. * Set the value of an uniform to an array of float32 (stored as matrices)
  88540. * @param uniform defines the webGL uniform location where to store the value
  88541. * @param matrices defines the array of float32 to store
  88542. */
  88543. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88544. /**
  88545. * Set the value of an uniform to a matrix
  88546. * @param uniform defines the webGL uniform location where to store the value
  88547. * @param matrix defines the matrix to store
  88548. */
  88549. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88550. /**
  88551. * Set the value of an uniform to a matrix (3x3)
  88552. * @param uniform defines the webGL uniform location where to store the value
  88553. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88554. */
  88555. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88556. /**
  88557. * Set the value of an uniform to a matrix (2x2)
  88558. * @param uniform defines the webGL uniform location where to store the value
  88559. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88560. */
  88561. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88562. /**
  88563. * Set the value of an uniform to a number (int)
  88564. * @param uniform defines the webGL uniform location where to store the value
  88565. * @param value defines the int number to store
  88566. */
  88567. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88568. /**
  88569. * Set the value of an uniform to a number (float)
  88570. * @param uniform defines the webGL uniform location where to store the value
  88571. * @param value defines the float number to store
  88572. */
  88573. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88574. /**
  88575. * Set the value of an uniform to a vec2
  88576. * @param uniform defines the webGL uniform location where to store the value
  88577. * @param x defines the 1st component of the value
  88578. * @param y defines the 2nd component of the value
  88579. */
  88580. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88581. /**
  88582. * Set the value of an uniform to a vec3
  88583. * @param uniform defines the webGL uniform location where to store the value
  88584. * @param x defines the 1st component of the value
  88585. * @param y defines the 2nd component of the value
  88586. * @param z defines the 3rd component of the value
  88587. */
  88588. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88589. /**
  88590. * Set the value of an uniform to a boolean
  88591. * @param uniform defines the webGL uniform location where to store the value
  88592. * @param bool defines the boolean to store
  88593. */
  88594. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88595. /**
  88596. * Set the value of an uniform to a vec4
  88597. * @param uniform defines the webGL uniform location where to store the value
  88598. * @param x defines the 1st component of the value
  88599. * @param y defines the 2nd component of the value
  88600. * @param z defines the 3rd component of the value
  88601. * @param w defines the 4th component of the value
  88602. */
  88603. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88604. /**
  88605. * Set the value of an uniform to a Color3
  88606. * @param uniform defines the webGL uniform location where to store the value
  88607. * @param color3 defines the color to store
  88608. */
  88609. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88610. /**
  88611. * Set the value of an uniform to a Color3 and an alpha value
  88612. * @param uniform defines the webGL uniform location where to store the value
  88613. * @param color3 defines the color to store
  88614. * @param alpha defines the alpha component to store
  88615. */
  88616. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88617. /**
  88618. * Sets a Color4 on a uniform variable
  88619. * @param uniform defines the uniform location
  88620. * @param color4 defines the value to be set
  88621. */
  88622. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88623. /**
  88624. * Set various states to the webGL context
  88625. * @param culling defines backface culling state
  88626. * @param zOffset defines the value to apply to zOffset (0 by default)
  88627. * @param force defines if states must be applied even if cache is up to date
  88628. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88629. */
  88630. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88631. /**
  88632. * Set the z offset to apply to current rendering
  88633. * @param value defines the offset to apply
  88634. */
  88635. setZOffset(value: number): void;
  88636. /**
  88637. * Gets the current value of the zOffset
  88638. * @returns the current zOffset state
  88639. */
  88640. getZOffset(): number;
  88641. /**
  88642. * Enable or disable depth buffering
  88643. * @param enable defines the state to set
  88644. */
  88645. setDepthBuffer(enable: boolean): void;
  88646. /**
  88647. * Gets a boolean indicating if depth writing is enabled
  88648. * @returns the current depth writing state
  88649. */
  88650. getDepthWrite(): boolean;
  88651. /**
  88652. * Enable or disable depth writing
  88653. * @param enable defines the state to set
  88654. */
  88655. setDepthWrite(enable: boolean): void;
  88656. /**
  88657. * Enable or disable color writing
  88658. * @param enable defines the state to set
  88659. */
  88660. setColorWrite(enable: boolean): void;
  88661. /**
  88662. * Gets a boolean indicating if color writing is enabled
  88663. * @returns the current color writing state
  88664. */
  88665. getColorWrite(): boolean;
  88666. /**
  88667. * Sets alpha constants used by some alpha blending modes
  88668. * @param r defines the red component
  88669. * @param g defines the green component
  88670. * @param b defines the blue component
  88671. * @param a defines the alpha component
  88672. */
  88673. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88674. /**
  88675. * Sets the current alpha mode
  88676. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88677. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88678. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88679. */
  88680. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88681. /**
  88682. * Gets the current alpha mode
  88683. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88684. * @returns the current alpha mode
  88685. */
  88686. getAlphaMode(): number;
  88687. /**
  88688. * Clears the list of texture accessible through engine.
  88689. * This can help preventing texture load conflict due to name collision.
  88690. */
  88691. clearInternalTexturesCache(): void;
  88692. /**
  88693. * Force the entire cache to be cleared
  88694. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88695. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88696. */
  88697. wipeCaches(bruteForce?: boolean): void;
  88698. /**
  88699. * Set the compressed texture format to use, based on the formats you have, and the formats
  88700. * supported by the hardware / browser.
  88701. *
  88702. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88703. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88704. * to API arguments needed to compressed textures. This puts the burden on the container
  88705. * generator to house the arcane code for determining these for current & future formats.
  88706. *
  88707. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88708. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88709. *
  88710. * Note: The result of this call is not taken into account when a texture is base64.
  88711. *
  88712. * @param formatsAvailable defines the list of those format families you have created
  88713. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88714. *
  88715. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88716. * @returns The extension selected.
  88717. */
  88718. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88719. /** @hidden */
  88720. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88721. min: number;
  88722. mag: number;
  88723. };
  88724. /** @hidden */
  88725. _createTexture(): WebGLTexture;
  88726. /**
  88727. * Usually called from Texture.ts.
  88728. * Passed information to create a WebGLTexture
  88729. * @param urlArg defines a value which contains one of the following:
  88730. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88731. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88732. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88733. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88734. * @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)
  88735. * @param scene needed for loading to the correct scene
  88736. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88737. * @param onLoad optional callback to be called upon successful completion
  88738. * @param onError optional callback to be called upon failure
  88739. * @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
  88740. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88741. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88742. * @param forcedExtension defines the extension to use to pick the right loader
  88743. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88744. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88745. */
  88746. 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;
  88747. private _rescaleTexture;
  88748. private _unpackFlipYCached;
  88749. /**
  88750. * In case you are sharing the context with other applications, it might
  88751. * be interested to not cache the unpack flip y state to ensure a consistent
  88752. * value would be set.
  88753. */
  88754. enableUnpackFlipYCached: boolean;
  88755. /** @hidden */
  88756. _unpackFlipY(value: boolean): void;
  88757. /** @hidden */
  88758. _getUnpackAlignement(): number;
  88759. /**
  88760. * Creates a dynamic texture
  88761. * @param width defines the width of the texture
  88762. * @param height defines the height of the texture
  88763. * @param generateMipMaps defines if the engine should generate the mip levels
  88764. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88765. * @returns the dynamic texture inside an InternalTexture
  88766. */
  88767. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88768. /**
  88769. * Update the sampling mode of a given texture
  88770. * @param samplingMode defines the required sampling mode
  88771. * @param texture defines the texture to update
  88772. */
  88773. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88774. /**
  88775. * Update the content of a dynamic texture
  88776. * @param texture defines the texture to update
  88777. * @param canvas defines the canvas containing the source
  88778. * @param invertY defines if data must be stored with Y axis inverted
  88779. * @param premulAlpha defines if alpha is stored as premultiplied
  88780. * @param format defines the format of the data
  88781. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88782. */
  88783. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88784. /**
  88785. * Update a video texture
  88786. * @param texture defines the texture to update
  88787. * @param video defines the video element to use
  88788. * @param invertY defines if data must be stored with Y axis inverted
  88789. */
  88790. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88791. /**
  88792. * Updates a depth texture Comparison Mode and Function.
  88793. * If the comparison Function is equal to 0, the mode will be set to none.
  88794. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88795. * @param texture The texture to set the comparison function for
  88796. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88797. */
  88798. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88799. /** @hidden */
  88800. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88801. width: number;
  88802. height: number;
  88803. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88804. /**
  88805. * Creates a depth stencil texture.
  88806. * This is only available in WebGL 2 or with the depth texture extension available.
  88807. * @param size The size of face edge in the texture.
  88808. * @param options The options defining the texture.
  88809. * @returns The texture
  88810. */
  88811. createDepthStencilTexture(size: number | {
  88812. width: number;
  88813. height: number;
  88814. }, options: DepthTextureCreationOptions): InternalTexture;
  88815. /**
  88816. * Creates a depth stencil texture.
  88817. * This is only available in WebGL 2 or with the depth texture extension available.
  88818. * @param size The size of face edge in the texture.
  88819. * @param options The options defining the texture.
  88820. * @returns The texture
  88821. */
  88822. private _createDepthStencilTexture;
  88823. /**
  88824. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88825. * @param renderTarget The render target to set the frame buffer for
  88826. */
  88827. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88828. /**
  88829. * Creates a new render target texture
  88830. * @param size defines the size of the texture
  88831. * @param options defines the options used to create the texture
  88832. * @returns a new render target texture stored in an InternalTexture
  88833. */
  88834. createRenderTargetTexture(size: number | {
  88835. width: number;
  88836. height: number;
  88837. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88838. /** @hidden */
  88839. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88840. /**
  88841. * Updates the sample count of a render target texture
  88842. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88843. * @param texture defines the texture to update
  88844. * @param samples defines the sample count to set
  88845. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88846. */
  88847. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88848. /** @hidden */
  88849. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88850. /** @hidden */
  88851. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88852. /** @hidden */
  88853. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88854. /** @hidden */
  88855. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88856. /**
  88857. * @hidden
  88858. */
  88859. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88860. private _prepareWebGLTextureContinuation;
  88861. private _prepareWebGLTexture;
  88862. /** @hidden */
  88863. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88864. /** @hidden */
  88865. _releaseFramebufferObjects(texture: InternalTexture): void;
  88866. /** @hidden */
  88867. _releaseTexture(texture: InternalTexture): void;
  88868. private setProgram;
  88869. private _boundUniforms;
  88870. /**
  88871. * Binds an effect to the webGL context
  88872. * @param effect defines the effect to bind
  88873. */
  88874. bindSamplers(effect: Effect): void;
  88875. private _activateCurrentTexture;
  88876. /** @hidden */
  88877. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88878. /** @hidden */
  88879. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88880. /**
  88881. * Sets a texture to the webGL context from a postprocess
  88882. * @param channel defines the channel to use
  88883. * @param postProcess defines the source postprocess
  88884. */
  88885. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88886. /**
  88887. * Binds the output of the passed in post process to the texture channel specified
  88888. * @param channel The channel the texture should be bound to
  88889. * @param postProcess The post process which's output should be bound
  88890. */
  88891. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88892. /**
  88893. * Unbind all textures from the webGL context
  88894. */
  88895. unbindAllTextures(): void;
  88896. /**
  88897. * Sets a texture to the according uniform.
  88898. * @param channel The texture channel
  88899. * @param uniform The uniform to set
  88900. * @param texture The texture to apply
  88901. */
  88902. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88903. /**
  88904. * Sets a depth stencil texture from a render target to the according uniform.
  88905. * @param channel The texture channel
  88906. * @param uniform The uniform to set
  88907. * @param texture The render target texture containing the depth stencil texture to apply
  88908. */
  88909. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88910. private _bindSamplerUniformToChannel;
  88911. private _getTextureWrapMode;
  88912. private _setTexture;
  88913. /**
  88914. * Sets an array of texture to the webGL context
  88915. * @param channel defines the channel where the texture array must be set
  88916. * @param uniform defines the associated uniform location
  88917. * @param textures defines the array of textures to bind
  88918. */
  88919. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88920. /** @hidden */
  88921. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88922. private _setTextureParameterFloat;
  88923. private _setTextureParameterInteger;
  88924. /**
  88925. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88926. * @param x defines the x coordinate of the rectangle where pixels must be read
  88927. * @param y defines the y coordinate of the rectangle where pixels must be read
  88928. * @param width defines the width of the rectangle where pixels must be read
  88929. * @param height defines the height of the rectangle where pixels must be read
  88930. * @returns a Uint8Array containing RGBA colors
  88931. */
  88932. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88933. /**
  88934. * Add an externaly attached data from its key.
  88935. * This method call will fail and return false, if such key already exists.
  88936. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88937. * @param key the unique key that identifies the data
  88938. * @param data the data object to associate to the key for this Engine instance
  88939. * @return true if no such key were already present and the data was added successfully, false otherwise
  88940. */
  88941. addExternalData<T>(key: string, data: T): boolean;
  88942. /**
  88943. * Get an externaly attached data from its key
  88944. * @param key the unique key that identifies the data
  88945. * @return the associated data, if present (can be null), or undefined if not present
  88946. */
  88947. getExternalData<T>(key: string): T;
  88948. /**
  88949. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88950. * @param key the unique key that identifies the data
  88951. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88952. * @return the associated data, can be null if the factory returned null.
  88953. */
  88954. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88955. /**
  88956. * Remove an externaly attached data from the Engine instance
  88957. * @param key the unique key that identifies the data
  88958. * @return true if the data was successfully removed, false if it doesn't exist
  88959. */
  88960. removeExternalData(key: string): boolean;
  88961. /**
  88962. * Unbind all vertex attributes from the webGL context
  88963. */
  88964. unbindAllAttributes(): void;
  88965. /**
  88966. * 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
  88967. */
  88968. releaseEffects(): void;
  88969. /**
  88970. * Dispose and release all associated resources
  88971. */
  88972. dispose(): void;
  88973. /**
  88974. * Display the loading screen
  88975. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88976. */
  88977. displayLoadingUI(): void;
  88978. /**
  88979. * Hide the loading screen
  88980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88981. */
  88982. hideLoadingUI(): void;
  88983. /**
  88984. * Gets the current loading screen object
  88985. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88986. */
  88987. /**
  88988. * Sets the current loading screen object
  88989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88990. */
  88991. loadingScreen: ILoadingScreen;
  88992. /**
  88993. * Sets the current loading screen text
  88994. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88995. */
  88996. loadingUIText: string;
  88997. /**
  88998. * Sets the current loading screen background color
  88999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89000. */
  89001. loadingUIBackgroundColor: string;
  89002. /**
  89003. * Attach a new callback raised when context lost event is fired
  89004. * @param callback defines the callback to call
  89005. */
  89006. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  89007. /**
  89008. * Attach a new callback raised when context restored event is fired
  89009. * @param callback defines the callback to call
  89010. */
  89011. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  89012. /**
  89013. * Gets the source code of the vertex shader associated with a specific webGL program
  89014. * @param program defines the program to use
  89015. * @returns a string containing the source code of the vertex shader associated with the program
  89016. */
  89017. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  89018. /**
  89019. * Gets the source code of the fragment shader associated with a specific webGL program
  89020. * @param program defines the program to use
  89021. * @returns a string containing the source code of the fragment shader associated with the program
  89022. */
  89023. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  89024. /**
  89025. * Get the current error code of the webGL context
  89026. * @returns the error code
  89027. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  89028. */
  89029. getError(): number;
  89030. /**
  89031. * Gets the current framerate
  89032. * @returns a number representing the framerate
  89033. */
  89034. getFps(): number;
  89035. /**
  89036. * Gets the time spent between current and previous frame
  89037. * @returns a number representing the delta time in ms
  89038. */
  89039. getDeltaTime(): number;
  89040. private _measureFps;
  89041. /** @hidden */
  89042. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  89043. private _canRenderToFloatFramebuffer;
  89044. private _canRenderToHalfFloatFramebuffer;
  89045. private _canRenderToFramebuffer;
  89046. /** @hidden */
  89047. _getWebGLTextureType(type: number): number;
  89048. /** @hidden */
  89049. _getInternalFormat(format: number): number;
  89050. /** @hidden */
  89051. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  89052. /** @hidden */
  89053. _getRGBAMultiSampleBufferFormat(type: number): number;
  89054. /** @hidden */
  89055. _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;
  89056. /** @hidden */
  89057. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89058. /**
  89059. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  89060. * @returns true if the engine can be created
  89061. * @ignorenaming
  89062. */
  89063. static isSupported(): boolean;
  89064. }
  89065. }
  89066. declare module BABYLON {
  89067. /**
  89068. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89069. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89070. */
  89071. export class EffectFallbacks {
  89072. private _defines;
  89073. private _currentRank;
  89074. private _maxRank;
  89075. private _mesh;
  89076. /**
  89077. * Removes the fallback from the bound mesh.
  89078. */
  89079. unBindMesh(): void;
  89080. /**
  89081. * Adds a fallback on the specified property.
  89082. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89083. * @param define The name of the define in the shader
  89084. */
  89085. addFallback(rank: number, define: string): void;
  89086. /**
  89087. * Sets the mesh to use CPU skinning when needing to fallback.
  89088. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89089. * @param mesh The mesh to use the fallbacks.
  89090. */
  89091. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89092. /**
  89093. * Checks to see if more fallbacks are still availible.
  89094. */
  89095. readonly isMoreFallbacks: boolean;
  89096. /**
  89097. * Removes the defines that shoould be removed when falling back.
  89098. * @param currentDefines defines the current define statements for the shader.
  89099. * @param effect defines the current effect we try to compile
  89100. * @returns The resulting defines with defines of the current rank removed.
  89101. */
  89102. reduce(currentDefines: string, effect: Effect): string;
  89103. }
  89104. /**
  89105. * Options to be used when creating an effect.
  89106. */
  89107. export class EffectCreationOptions {
  89108. /**
  89109. * Atrributes that will be used in the shader.
  89110. */
  89111. attributes: string[];
  89112. /**
  89113. * Uniform varible names that will be set in the shader.
  89114. */
  89115. uniformsNames: string[];
  89116. /**
  89117. * Uniform buffer varible names that will be set in the shader.
  89118. */
  89119. uniformBuffersNames: string[];
  89120. /**
  89121. * Sampler texture variable names that will be set in the shader.
  89122. */
  89123. samplers: string[];
  89124. /**
  89125. * Define statements that will be set in the shader.
  89126. */
  89127. defines: any;
  89128. /**
  89129. * Possible fallbacks for this effect to improve performance when needed.
  89130. */
  89131. fallbacks: Nullable<EffectFallbacks>;
  89132. /**
  89133. * Callback that will be called when the shader is compiled.
  89134. */
  89135. onCompiled: Nullable<(effect: Effect) => void>;
  89136. /**
  89137. * Callback that will be called if an error occurs during shader compilation.
  89138. */
  89139. onError: Nullable<(effect: Effect, errors: string) => void>;
  89140. /**
  89141. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89142. */
  89143. indexParameters: any;
  89144. /**
  89145. * Max number of lights that can be used in the shader.
  89146. */
  89147. maxSimultaneousLights: number;
  89148. /**
  89149. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  89150. */
  89151. transformFeedbackVaryings: Nullable<string[]>;
  89152. }
  89153. /**
  89154. * Effect containing vertex and fragment shader that can be executed on an object.
  89155. */
  89156. export class Effect implements IDisposable {
  89157. /**
  89158. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  89159. */
  89160. static ShadersRepository: string;
  89161. /**
  89162. * Name of the effect.
  89163. */
  89164. name: any;
  89165. /**
  89166. * String container all the define statements that should be set on the shader.
  89167. */
  89168. defines: string;
  89169. /**
  89170. * Callback that will be called when the shader is compiled.
  89171. */
  89172. onCompiled: Nullable<(effect: Effect) => void>;
  89173. /**
  89174. * Callback that will be called if an error occurs during shader compilation.
  89175. */
  89176. onError: Nullable<(effect: Effect, errors: string) => void>;
  89177. /**
  89178. * Callback that will be called when effect is bound.
  89179. */
  89180. onBind: Nullable<(effect: Effect) => void>;
  89181. /**
  89182. * Unique ID of the effect.
  89183. */
  89184. uniqueId: number;
  89185. /**
  89186. * Observable that will be called when the shader is compiled.
  89187. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89188. */
  89189. onCompileObservable: Observable<Effect>;
  89190. /**
  89191. * Observable that will be called if an error occurs during shader compilation.
  89192. */
  89193. onErrorObservable: Observable<Effect>;
  89194. /** @hidden */
  89195. _onBindObservable: Nullable<Observable<Effect>>;
  89196. /**
  89197. * Observable that will be called when effect is bound.
  89198. */
  89199. readonly onBindObservable: Observable<Effect>;
  89200. /** @hidden */
  89201. _bonesComputationForcedToCPU: boolean;
  89202. private static _uniqueIdSeed;
  89203. private _engine;
  89204. private _uniformBuffersNames;
  89205. private _uniformsNames;
  89206. private _samplerList;
  89207. private _samplers;
  89208. private _isReady;
  89209. private _compilationError;
  89210. private _attributesNames;
  89211. private _attributes;
  89212. private _uniforms;
  89213. /**
  89214. * Key for the effect.
  89215. * @hidden
  89216. */
  89217. _key: string;
  89218. private _indexParameters;
  89219. private _fallbacks;
  89220. private _vertexSourceCode;
  89221. private _fragmentSourceCode;
  89222. private _vertexSourceCodeOverride;
  89223. private _fragmentSourceCodeOverride;
  89224. private _transformFeedbackVaryings;
  89225. /**
  89226. * Compiled shader to webGL program.
  89227. * @hidden
  89228. */
  89229. _pipelineContext: Nullable<IPipelineContext>;
  89230. private _valueCache;
  89231. private static _baseCache;
  89232. /**
  89233. * Instantiates an effect.
  89234. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89235. * @param baseName Name of the effect.
  89236. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89237. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89238. * @param samplers List of sampler variables that will be passed to the shader.
  89239. * @param engine Engine to be used to render the effect
  89240. * @param defines Define statements to be added to the shader.
  89241. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89242. * @param onCompiled Callback that will be called when the shader is compiled.
  89243. * @param onError Callback that will be called if an error occurs during shader compilation.
  89244. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89245. */
  89246. 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);
  89247. /**
  89248. * Unique key for this effect
  89249. */
  89250. readonly key: string;
  89251. /**
  89252. * If the effect has been compiled and prepared.
  89253. * @returns if the effect is compiled and prepared.
  89254. */
  89255. isReady(): boolean;
  89256. /**
  89257. * The engine the effect was initialized with.
  89258. * @returns the engine.
  89259. */
  89260. getEngine(): Engine;
  89261. /**
  89262. * The pipeline context for this effect
  89263. * @returns the associated pipeline context
  89264. */
  89265. getPipelineContext(): Nullable<IPipelineContext>;
  89266. /**
  89267. * The set of names of attribute variables for the shader.
  89268. * @returns An array of attribute names.
  89269. */
  89270. getAttributesNames(): string[];
  89271. /**
  89272. * Returns the attribute at the given index.
  89273. * @param index The index of the attribute.
  89274. * @returns The location of the attribute.
  89275. */
  89276. getAttributeLocation(index: number): number;
  89277. /**
  89278. * Returns the attribute based on the name of the variable.
  89279. * @param name of the attribute to look up.
  89280. * @returns the attribute location.
  89281. */
  89282. getAttributeLocationByName(name: string): number;
  89283. /**
  89284. * The number of attributes.
  89285. * @returns the numnber of attributes.
  89286. */
  89287. getAttributesCount(): number;
  89288. /**
  89289. * Gets the index of a uniform variable.
  89290. * @param uniformName of the uniform to look up.
  89291. * @returns the index.
  89292. */
  89293. getUniformIndex(uniformName: string): number;
  89294. /**
  89295. * Returns the attribute based on the name of the variable.
  89296. * @param uniformName of the uniform to look up.
  89297. * @returns the location of the uniform.
  89298. */
  89299. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89300. /**
  89301. * Returns an array of sampler variable names
  89302. * @returns The array of sampler variable neames.
  89303. */
  89304. getSamplers(): string[];
  89305. /**
  89306. * The error from the last compilation.
  89307. * @returns the error string.
  89308. */
  89309. getCompilationError(): string;
  89310. /**
  89311. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89312. * @param func The callback to be used.
  89313. */
  89314. executeWhenCompiled(func: (effect: Effect) => void): void;
  89315. private _checkIsReady;
  89316. /** @hidden */
  89317. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89318. /** @hidden */
  89319. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89320. /** @hidden */
  89321. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89322. private _processShaderConversion;
  89323. private _processIncludes;
  89324. private _processPrecision;
  89325. /**
  89326. * Recompiles the webGL program
  89327. * @param vertexSourceCode The source code for the vertex shader.
  89328. * @param fragmentSourceCode The source code for the fragment shader.
  89329. * @param onCompiled Callback called when completed.
  89330. * @param onError Callback called on error.
  89331. * @hidden
  89332. */
  89333. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89334. /**
  89335. * Prepares the effect
  89336. * @hidden
  89337. */
  89338. _prepareEffect(): void;
  89339. /**
  89340. * Checks if the effect is supported. (Must be called after compilation)
  89341. */
  89342. readonly isSupported: boolean;
  89343. /**
  89344. * Binds a texture to the engine to be used as output of the shader.
  89345. * @param channel Name of the output variable.
  89346. * @param texture Texture to bind.
  89347. * @hidden
  89348. */
  89349. _bindTexture(channel: string, texture: InternalTexture): void;
  89350. /**
  89351. * Sets a texture on the engine to be used in the shader.
  89352. * @param channel Name of the sampler variable.
  89353. * @param texture Texture to set.
  89354. */
  89355. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89356. /**
  89357. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89358. * @param channel Name of the sampler variable.
  89359. * @param texture Texture to set.
  89360. */
  89361. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89362. /**
  89363. * Sets an array of textures on the engine to be used in the shader.
  89364. * @param channel Name of the variable.
  89365. * @param textures Textures to set.
  89366. */
  89367. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89368. /**
  89369. * 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)
  89370. * @param channel Name of the sampler variable.
  89371. * @param postProcess Post process to get the input texture from.
  89372. */
  89373. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89374. /**
  89375. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89376. * 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)
  89377. * @param channel Name of the sampler variable.
  89378. * @param postProcess Post process to get the output texture from.
  89379. */
  89380. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89381. /** @hidden */
  89382. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89383. /** @hidden */
  89384. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89385. /** @hidden */
  89386. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89387. /** @hidden */
  89388. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89389. /**
  89390. * Binds a buffer to a uniform.
  89391. * @param buffer Buffer to bind.
  89392. * @param name Name of the uniform variable to bind to.
  89393. */
  89394. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89395. /**
  89396. * Binds block to a uniform.
  89397. * @param blockName Name of the block to bind.
  89398. * @param index Index to bind.
  89399. */
  89400. bindUniformBlock(blockName: string, index: number): void;
  89401. /**
  89402. * Sets an interger value on a uniform variable.
  89403. * @param uniformName Name of the variable.
  89404. * @param value Value to be set.
  89405. * @returns this effect.
  89406. */
  89407. setInt(uniformName: string, value: number): Effect;
  89408. /**
  89409. * Sets an int array on a uniform variable.
  89410. * @param uniformName Name of the variable.
  89411. * @param array array to be set.
  89412. * @returns this effect.
  89413. */
  89414. setIntArray(uniformName: string, array: Int32Array): Effect;
  89415. /**
  89416. * 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)
  89417. * @param uniformName Name of the variable.
  89418. * @param array array to be set.
  89419. * @returns this effect.
  89420. */
  89421. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89422. /**
  89423. * 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)
  89424. * @param uniformName Name of the variable.
  89425. * @param array array to be set.
  89426. * @returns this effect.
  89427. */
  89428. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89429. /**
  89430. * 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)
  89431. * @param uniformName Name of the variable.
  89432. * @param array array to be set.
  89433. * @returns this effect.
  89434. */
  89435. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89436. /**
  89437. * Sets an float array on a uniform variable.
  89438. * @param uniformName Name of the variable.
  89439. * @param array array to be set.
  89440. * @returns this effect.
  89441. */
  89442. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89443. /**
  89444. * 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)
  89445. * @param uniformName Name of the variable.
  89446. * @param array array to be set.
  89447. * @returns this effect.
  89448. */
  89449. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89450. /**
  89451. * 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)
  89452. * @param uniformName Name of the variable.
  89453. * @param array array to be set.
  89454. * @returns this effect.
  89455. */
  89456. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89457. /**
  89458. * 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)
  89459. * @param uniformName Name of the variable.
  89460. * @param array array to be set.
  89461. * @returns this effect.
  89462. */
  89463. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89464. /**
  89465. * Sets an array on a uniform variable.
  89466. * @param uniformName Name of the variable.
  89467. * @param array array to be set.
  89468. * @returns this effect.
  89469. */
  89470. setArray(uniformName: string, array: number[]): Effect;
  89471. /**
  89472. * 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)
  89473. * @param uniformName Name of the variable.
  89474. * @param array array to be set.
  89475. * @returns this effect.
  89476. */
  89477. setArray2(uniformName: string, array: number[]): Effect;
  89478. /**
  89479. * 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)
  89480. * @param uniformName Name of the variable.
  89481. * @param array array to be set.
  89482. * @returns this effect.
  89483. */
  89484. setArray3(uniformName: string, array: number[]): Effect;
  89485. /**
  89486. * 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)
  89487. * @param uniformName Name of the variable.
  89488. * @param array array to be set.
  89489. * @returns this effect.
  89490. */
  89491. setArray4(uniformName: string, array: number[]): Effect;
  89492. /**
  89493. * Sets matrices on a uniform variable.
  89494. * @param uniformName Name of the variable.
  89495. * @param matrices matrices to be set.
  89496. * @returns this effect.
  89497. */
  89498. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89499. /**
  89500. * Sets matrix on a uniform variable.
  89501. * @param uniformName Name of the variable.
  89502. * @param matrix matrix to be set.
  89503. * @returns this effect.
  89504. */
  89505. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89506. /**
  89507. * 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)
  89508. * @param uniformName Name of the variable.
  89509. * @param matrix matrix to be set.
  89510. * @returns this effect.
  89511. */
  89512. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89513. /**
  89514. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89515. * @param uniformName Name of the variable.
  89516. * @param matrix matrix to be set.
  89517. * @returns this effect.
  89518. */
  89519. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89520. /**
  89521. * Sets a float on a uniform variable.
  89522. * @param uniformName Name of the variable.
  89523. * @param value value to be set.
  89524. * @returns this effect.
  89525. */
  89526. setFloat(uniformName: string, value: number): Effect;
  89527. /**
  89528. * Sets a boolean on a uniform variable.
  89529. * @param uniformName Name of the variable.
  89530. * @param bool value to be set.
  89531. * @returns this effect.
  89532. */
  89533. setBool(uniformName: string, bool: boolean): Effect;
  89534. /**
  89535. * Sets a Vector2 on a uniform variable.
  89536. * @param uniformName Name of the variable.
  89537. * @param vector2 vector2 to be set.
  89538. * @returns this effect.
  89539. */
  89540. setVector2(uniformName: string, vector2: Vector2): Effect;
  89541. /**
  89542. * Sets a float2 on a uniform variable.
  89543. * @param uniformName Name of the variable.
  89544. * @param x First float in float2.
  89545. * @param y Second float in float2.
  89546. * @returns this effect.
  89547. */
  89548. setFloat2(uniformName: string, x: number, y: number): Effect;
  89549. /**
  89550. * Sets a Vector3 on a uniform variable.
  89551. * @param uniformName Name of the variable.
  89552. * @param vector3 Value to be set.
  89553. * @returns this effect.
  89554. */
  89555. setVector3(uniformName: string, vector3: Vector3): Effect;
  89556. /**
  89557. * Sets a float3 on a uniform variable.
  89558. * @param uniformName Name of the variable.
  89559. * @param x First float in float3.
  89560. * @param y Second float in float3.
  89561. * @param z Third float in float3.
  89562. * @returns this effect.
  89563. */
  89564. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89565. /**
  89566. * Sets a Vector4 on a uniform variable.
  89567. * @param uniformName Name of the variable.
  89568. * @param vector4 Value to be set.
  89569. * @returns this effect.
  89570. */
  89571. setVector4(uniformName: string, vector4: Vector4): Effect;
  89572. /**
  89573. * Sets a float4 on a uniform variable.
  89574. * @param uniformName Name of the variable.
  89575. * @param x First float in float4.
  89576. * @param y Second float in float4.
  89577. * @param z Third float in float4.
  89578. * @param w Fourth float in float4.
  89579. * @returns this effect.
  89580. */
  89581. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89582. /**
  89583. * Sets a Color3 on a uniform variable.
  89584. * @param uniformName Name of the variable.
  89585. * @param color3 Value to be set.
  89586. * @returns this effect.
  89587. */
  89588. setColor3(uniformName: string, color3: Color3): Effect;
  89589. /**
  89590. * Sets a Color4 on a uniform variable.
  89591. * @param uniformName Name of the variable.
  89592. * @param color3 Value to be set.
  89593. * @param alpha Alpha value to be set.
  89594. * @returns this effect.
  89595. */
  89596. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89597. /**
  89598. * Sets a Color4 on a uniform variable
  89599. * @param uniformName defines the name of the variable
  89600. * @param color4 defines the value to be set
  89601. * @returns this effect.
  89602. */
  89603. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89604. /** Release all associated resources */
  89605. dispose(): void;
  89606. /**
  89607. * This function will add a new shader to the shader store
  89608. * @param name the name of the shader
  89609. * @param pixelShader optional pixel shader content
  89610. * @param vertexShader optional vertex shader content
  89611. */
  89612. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89613. /**
  89614. * Store of each shader (The can be looked up using effect.key)
  89615. */
  89616. static ShadersStore: {
  89617. [key: string]: string;
  89618. };
  89619. /**
  89620. * Store of each included file for a shader (The can be looked up using effect.key)
  89621. */
  89622. static IncludesShadersStore: {
  89623. [key: string]: string;
  89624. };
  89625. /**
  89626. * Resets the cache of effects.
  89627. */
  89628. static ResetCache(): void;
  89629. }
  89630. }
  89631. declare module BABYLON {
  89632. /**
  89633. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89634. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89635. * 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;
  89636. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89637. */
  89638. export class ColorCurves {
  89639. private _dirty;
  89640. private _tempColor;
  89641. private _globalCurve;
  89642. private _highlightsCurve;
  89643. private _midtonesCurve;
  89644. private _shadowsCurve;
  89645. private _positiveCurve;
  89646. private _negativeCurve;
  89647. private _globalHue;
  89648. private _globalDensity;
  89649. private _globalSaturation;
  89650. private _globalExposure;
  89651. /**
  89652. * Gets the global Hue value.
  89653. * 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).
  89654. */
  89655. /**
  89656. * Sets the global Hue value.
  89657. * 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).
  89658. */
  89659. globalHue: number;
  89660. /**
  89661. * Gets the global Density value.
  89662. * 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.
  89663. * Values less than zero provide a filter of opposite hue.
  89664. */
  89665. /**
  89666. * Sets the global Density value.
  89667. * 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.
  89668. * Values less than zero provide a filter of opposite hue.
  89669. */
  89670. globalDensity: number;
  89671. /**
  89672. * Gets the global Saturation value.
  89673. * 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.
  89674. */
  89675. /**
  89676. * Sets the global Saturation value.
  89677. * 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.
  89678. */
  89679. globalSaturation: number;
  89680. /**
  89681. * Gets the global Exposure value.
  89682. * 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.
  89683. */
  89684. /**
  89685. * Sets the global Exposure value.
  89686. * 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.
  89687. */
  89688. globalExposure: number;
  89689. private _highlightsHue;
  89690. private _highlightsDensity;
  89691. private _highlightsSaturation;
  89692. private _highlightsExposure;
  89693. /**
  89694. * Gets the highlights Hue value.
  89695. * 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).
  89696. */
  89697. /**
  89698. * Sets the highlights Hue value.
  89699. * 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).
  89700. */
  89701. highlightsHue: number;
  89702. /**
  89703. * Gets the highlights Density value.
  89704. * 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.
  89705. * Values less than zero provide a filter of opposite hue.
  89706. */
  89707. /**
  89708. * Sets the highlights Density value.
  89709. * 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.
  89710. * Values less than zero provide a filter of opposite hue.
  89711. */
  89712. highlightsDensity: number;
  89713. /**
  89714. * Gets the highlights Saturation value.
  89715. * 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.
  89716. */
  89717. /**
  89718. * Sets the highlights Saturation value.
  89719. * 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.
  89720. */
  89721. highlightsSaturation: number;
  89722. /**
  89723. * Gets the highlights Exposure value.
  89724. * 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.
  89725. */
  89726. /**
  89727. * Sets the highlights Exposure value.
  89728. * 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.
  89729. */
  89730. highlightsExposure: number;
  89731. private _midtonesHue;
  89732. private _midtonesDensity;
  89733. private _midtonesSaturation;
  89734. private _midtonesExposure;
  89735. /**
  89736. * Gets the midtones Hue value.
  89737. * 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).
  89738. */
  89739. /**
  89740. * Sets the midtones Hue value.
  89741. * 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).
  89742. */
  89743. midtonesHue: number;
  89744. /**
  89745. * Gets the midtones Density value.
  89746. * 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.
  89747. * Values less than zero provide a filter of opposite hue.
  89748. */
  89749. /**
  89750. * Sets the midtones Density value.
  89751. * 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.
  89752. * Values less than zero provide a filter of opposite hue.
  89753. */
  89754. midtonesDensity: number;
  89755. /**
  89756. * Gets the midtones Saturation value.
  89757. * 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.
  89758. */
  89759. /**
  89760. * Sets the midtones Saturation value.
  89761. * 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.
  89762. */
  89763. midtonesSaturation: number;
  89764. /**
  89765. * Gets the midtones Exposure value.
  89766. * 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.
  89767. */
  89768. /**
  89769. * Sets the midtones Exposure value.
  89770. * 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.
  89771. */
  89772. midtonesExposure: number;
  89773. private _shadowsHue;
  89774. private _shadowsDensity;
  89775. private _shadowsSaturation;
  89776. private _shadowsExposure;
  89777. /**
  89778. * Gets the shadows Hue value.
  89779. * 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).
  89780. */
  89781. /**
  89782. * Sets the shadows Hue value.
  89783. * 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).
  89784. */
  89785. shadowsHue: number;
  89786. /**
  89787. * Gets the shadows Density value.
  89788. * 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.
  89789. * Values less than zero provide a filter of opposite hue.
  89790. */
  89791. /**
  89792. * Sets the shadows Density value.
  89793. * 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.
  89794. * Values less than zero provide a filter of opposite hue.
  89795. */
  89796. shadowsDensity: number;
  89797. /**
  89798. * Gets the shadows Saturation value.
  89799. * 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.
  89800. */
  89801. /**
  89802. * Sets the shadows Saturation value.
  89803. * 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.
  89804. */
  89805. shadowsSaturation: number;
  89806. /**
  89807. * Gets the shadows Exposure value.
  89808. * 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.
  89809. */
  89810. /**
  89811. * Sets the shadows Exposure value.
  89812. * 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.
  89813. */
  89814. shadowsExposure: number;
  89815. /**
  89816. * Returns the class name
  89817. * @returns The class name
  89818. */
  89819. getClassName(): string;
  89820. /**
  89821. * Binds the color curves to the shader.
  89822. * @param colorCurves The color curve to bind
  89823. * @param effect The effect to bind to
  89824. * @param positiveUniform The positive uniform shader parameter
  89825. * @param neutralUniform The neutral uniform shader parameter
  89826. * @param negativeUniform The negative uniform shader parameter
  89827. */
  89828. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89829. /**
  89830. * Prepare the list of uniforms associated with the ColorCurves effects.
  89831. * @param uniformsList The list of uniforms used in the effect
  89832. */
  89833. static PrepareUniforms(uniformsList: string[]): void;
  89834. /**
  89835. * Returns color grading data based on a hue, density, saturation and exposure value.
  89836. * @param filterHue The hue of the color filter.
  89837. * @param filterDensity The density of the color filter.
  89838. * @param saturation The saturation.
  89839. * @param exposure The exposure.
  89840. * @param result The result data container.
  89841. */
  89842. private getColorGradingDataToRef;
  89843. /**
  89844. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89845. * @param value The input slider value in range [-100,100].
  89846. * @returns Adjusted value.
  89847. */
  89848. private static applyColorGradingSliderNonlinear;
  89849. /**
  89850. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89851. * @param hue The hue (H) input.
  89852. * @param saturation The saturation (S) input.
  89853. * @param brightness The brightness (B) input.
  89854. * @result An RGBA color represented as Vector4.
  89855. */
  89856. private static fromHSBToRef;
  89857. /**
  89858. * Returns a value clamped between min and max
  89859. * @param value The value to clamp
  89860. * @param min The minimum of value
  89861. * @param max The maximum of value
  89862. * @returns The clamped value.
  89863. */
  89864. private static clamp;
  89865. /**
  89866. * Clones the current color curve instance.
  89867. * @return The cloned curves
  89868. */
  89869. clone(): ColorCurves;
  89870. /**
  89871. * Serializes the current color curve instance to a json representation.
  89872. * @return a JSON representation
  89873. */
  89874. serialize(): any;
  89875. /**
  89876. * Parses the color curve from a json representation.
  89877. * @param source the JSON source to parse
  89878. * @return The parsed curves
  89879. */
  89880. static Parse(source: any): ColorCurves;
  89881. }
  89882. }
  89883. declare module BABYLON {
  89884. /**
  89885. * Interface to follow in your material defines to integrate easily the
  89886. * Image proccessing functions.
  89887. * @hidden
  89888. */
  89889. export interface IImageProcessingConfigurationDefines {
  89890. IMAGEPROCESSING: boolean;
  89891. VIGNETTE: boolean;
  89892. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89893. VIGNETTEBLENDMODEOPAQUE: boolean;
  89894. TONEMAPPING: boolean;
  89895. TONEMAPPING_ACES: boolean;
  89896. CONTRAST: boolean;
  89897. EXPOSURE: boolean;
  89898. COLORCURVES: boolean;
  89899. COLORGRADING: boolean;
  89900. COLORGRADING3D: boolean;
  89901. SAMPLER3DGREENDEPTH: boolean;
  89902. SAMPLER3DBGRMAP: boolean;
  89903. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89904. }
  89905. /**
  89906. * @hidden
  89907. */
  89908. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89909. IMAGEPROCESSING: boolean;
  89910. VIGNETTE: boolean;
  89911. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89912. VIGNETTEBLENDMODEOPAQUE: boolean;
  89913. TONEMAPPING: boolean;
  89914. TONEMAPPING_ACES: boolean;
  89915. CONTRAST: boolean;
  89916. COLORCURVES: boolean;
  89917. COLORGRADING: boolean;
  89918. COLORGRADING3D: boolean;
  89919. SAMPLER3DGREENDEPTH: boolean;
  89920. SAMPLER3DBGRMAP: boolean;
  89921. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89922. EXPOSURE: boolean;
  89923. constructor();
  89924. }
  89925. /**
  89926. * This groups together the common properties used for image processing either in direct forward pass
  89927. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89928. * or not.
  89929. */
  89930. export class ImageProcessingConfiguration {
  89931. /**
  89932. * Default tone mapping applied in BabylonJS.
  89933. */
  89934. static readonly TONEMAPPING_STANDARD: number;
  89935. /**
  89936. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89937. * to other engines rendering to increase portability.
  89938. */
  89939. static readonly TONEMAPPING_ACES: number;
  89940. /**
  89941. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89942. */
  89943. colorCurves: Nullable<ColorCurves>;
  89944. private _colorCurvesEnabled;
  89945. /**
  89946. * Gets wether the color curves effect is enabled.
  89947. */
  89948. /**
  89949. * Sets wether the color curves effect is enabled.
  89950. */
  89951. colorCurvesEnabled: boolean;
  89952. private _colorGradingTexture;
  89953. /**
  89954. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89955. */
  89956. /**
  89957. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89958. */
  89959. colorGradingTexture: Nullable<BaseTexture>;
  89960. private _colorGradingEnabled;
  89961. /**
  89962. * Gets wether the color grading effect is enabled.
  89963. */
  89964. /**
  89965. * Sets wether the color grading effect is enabled.
  89966. */
  89967. colorGradingEnabled: boolean;
  89968. private _colorGradingWithGreenDepth;
  89969. /**
  89970. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89971. */
  89972. /**
  89973. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89974. */
  89975. colorGradingWithGreenDepth: boolean;
  89976. private _colorGradingBGR;
  89977. /**
  89978. * Gets wether the color grading texture contains BGR values.
  89979. */
  89980. /**
  89981. * Sets wether the color grading texture contains BGR values.
  89982. */
  89983. colorGradingBGR: boolean;
  89984. /** @hidden */
  89985. _exposure: number;
  89986. /**
  89987. * Gets the Exposure used in the effect.
  89988. */
  89989. /**
  89990. * Sets the Exposure used in the effect.
  89991. */
  89992. exposure: number;
  89993. private _toneMappingEnabled;
  89994. /**
  89995. * Gets wether the tone mapping effect is enabled.
  89996. */
  89997. /**
  89998. * Sets wether the tone mapping effect is enabled.
  89999. */
  90000. toneMappingEnabled: boolean;
  90001. private _toneMappingType;
  90002. /**
  90003. * Gets the type of tone mapping effect.
  90004. */
  90005. /**
  90006. * Sets the type of tone mapping effect used in BabylonJS.
  90007. */
  90008. toneMappingType: number;
  90009. protected _contrast: number;
  90010. /**
  90011. * Gets the contrast used in the effect.
  90012. */
  90013. /**
  90014. * Sets the contrast used in the effect.
  90015. */
  90016. contrast: number;
  90017. /**
  90018. * Vignette stretch size.
  90019. */
  90020. vignetteStretch: number;
  90021. /**
  90022. * Vignette centre X Offset.
  90023. */
  90024. vignetteCentreX: number;
  90025. /**
  90026. * Vignette centre Y Offset.
  90027. */
  90028. vignetteCentreY: number;
  90029. /**
  90030. * Vignette weight or intensity of the vignette effect.
  90031. */
  90032. vignetteWeight: number;
  90033. /**
  90034. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  90035. * if vignetteEnabled is set to true.
  90036. */
  90037. vignetteColor: Color4;
  90038. /**
  90039. * Camera field of view used by the Vignette effect.
  90040. */
  90041. vignetteCameraFov: number;
  90042. private _vignetteBlendMode;
  90043. /**
  90044. * Gets the vignette blend mode allowing different kind of effect.
  90045. */
  90046. /**
  90047. * Sets the vignette blend mode allowing different kind of effect.
  90048. */
  90049. vignetteBlendMode: number;
  90050. private _vignetteEnabled;
  90051. /**
  90052. * Gets wether the vignette effect is enabled.
  90053. */
  90054. /**
  90055. * Sets wether the vignette effect is enabled.
  90056. */
  90057. vignetteEnabled: boolean;
  90058. private _applyByPostProcess;
  90059. /**
  90060. * Gets wether the image processing is applied through a post process or not.
  90061. */
  90062. /**
  90063. * Sets wether the image processing is applied through a post process or not.
  90064. */
  90065. applyByPostProcess: boolean;
  90066. private _isEnabled;
  90067. /**
  90068. * Gets wether the image processing is enabled or not.
  90069. */
  90070. /**
  90071. * Sets wether the image processing is enabled or not.
  90072. */
  90073. isEnabled: boolean;
  90074. /**
  90075. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  90076. */
  90077. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  90078. /**
  90079. * Method called each time the image processing information changes requires to recompile the effect.
  90080. */
  90081. protected _updateParameters(): void;
  90082. /**
  90083. * Gets the current class name.
  90084. * @return "ImageProcessingConfiguration"
  90085. */
  90086. getClassName(): string;
  90087. /**
  90088. * Prepare the list of uniforms associated with the Image Processing effects.
  90089. * @param uniforms The list of uniforms used in the effect
  90090. * @param defines the list of defines currently in use
  90091. */
  90092. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  90093. /**
  90094. * Prepare the list of samplers associated with the Image Processing effects.
  90095. * @param samplersList The list of uniforms used in the effect
  90096. * @param defines the list of defines currently in use
  90097. */
  90098. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  90099. /**
  90100. * Prepare the list of defines associated to the shader.
  90101. * @param defines the list of defines to complete
  90102. * @param forPostProcess Define if we are currently in post process mode or not
  90103. */
  90104. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  90105. /**
  90106. * Returns true if all the image processing information are ready.
  90107. * @returns True if ready, otherwise, false
  90108. */
  90109. isReady(): boolean;
  90110. /**
  90111. * Binds the image processing to the shader.
  90112. * @param effect The effect to bind to
  90113. * @param aspectRatio Define the current aspect ratio of the effect
  90114. */
  90115. bind(effect: Effect, aspectRatio?: number): void;
  90116. /**
  90117. * Clones the current image processing instance.
  90118. * @return The cloned image processing
  90119. */
  90120. clone(): ImageProcessingConfiguration;
  90121. /**
  90122. * Serializes the current image processing instance to a json representation.
  90123. * @return a JSON representation
  90124. */
  90125. serialize(): any;
  90126. /**
  90127. * Parses the image processing from a json representation.
  90128. * @param source the JSON source to parse
  90129. * @return The parsed image processing
  90130. */
  90131. static Parse(source: any): ImageProcessingConfiguration;
  90132. private static _VIGNETTEMODE_MULTIPLY;
  90133. private static _VIGNETTEMODE_OPAQUE;
  90134. /**
  90135. * Used to apply the vignette as a mix with the pixel color.
  90136. */
  90137. static readonly VIGNETTEMODE_MULTIPLY: number;
  90138. /**
  90139. * Used to apply the vignette as a replacement of the pixel color.
  90140. */
  90141. static readonly VIGNETTEMODE_OPAQUE: number;
  90142. }
  90143. }
  90144. declare module BABYLON {
  90145. /**
  90146. * This represents all the required information to add a fresnel effect on a material:
  90147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  90148. */
  90149. export class FresnelParameters {
  90150. private _isEnabled;
  90151. /**
  90152. * Define if the fresnel effect is enable or not.
  90153. */
  90154. isEnabled: boolean;
  90155. /**
  90156. * Define the color used on edges (grazing angle)
  90157. */
  90158. leftColor: Color3;
  90159. /**
  90160. * Define the color used on center
  90161. */
  90162. rightColor: Color3;
  90163. /**
  90164. * Define bias applied to computed fresnel term
  90165. */
  90166. bias: number;
  90167. /**
  90168. * Defined the power exponent applied to fresnel term
  90169. */
  90170. power: number;
  90171. /**
  90172. * Clones the current fresnel and its valuues
  90173. * @returns a clone fresnel configuration
  90174. */
  90175. clone(): FresnelParameters;
  90176. /**
  90177. * Serializes the current fresnel parameters to a JSON representation.
  90178. * @return the JSON serialization
  90179. */
  90180. serialize(): any;
  90181. /**
  90182. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90183. * @param parsedFresnelParameters Define the JSON representation
  90184. * @returns the parsed parameters
  90185. */
  90186. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90187. }
  90188. }
  90189. declare module BABYLON {
  90190. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90191. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90192. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90193. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90194. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90195. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90196. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90197. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90198. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90199. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90200. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90201. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90202. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90203. /**
  90204. * Decorator used to define property that can be serialized as reference to a camera
  90205. * @param sourceName defines the name of the property to decorate
  90206. */
  90207. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90208. /**
  90209. * Class used to help serialization objects
  90210. */
  90211. export class SerializationHelper {
  90212. /** hidden */
  90213. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90214. /** hidden */
  90215. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90216. /** hidden */
  90217. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90218. /** hidden */
  90219. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90220. /**
  90221. * Appends the serialized animations from the source animations
  90222. * @param source Source containing the animations
  90223. * @param destination Target to store the animations
  90224. */
  90225. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90226. /**
  90227. * Static function used to serialized a specific entity
  90228. * @param entity defines the entity to serialize
  90229. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90230. * @returns a JSON compatible object representing the serialization of the entity
  90231. */
  90232. static Serialize<T>(entity: T, serializationObject?: any): any;
  90233. /**
  90234. * Creates a new entity from a serialization data object
  90235. * @param creationFunction defines a function used to instanciated the new entity
  90236. * @param source defines the source serialization data
  90237. * @param scene defines the hosting scene
  90238. * @param rootUrl defines the root url for resources
  90239. * @returns a new entity
  90240. */
  90241. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90242. /**
  90243. * Clones an object
  90244. * @param creationFunction defines the function used to instanciate the new object
  90245. * @param source defines the source object
  90246. * @returns the cloned object
  90247. */
  90248. static Clone<T>(creationFunction: () => T, source: T): T;
  90249. /**
  90250. * Instanciates a new object based on a source one (some data will be shared between both object)
  90251. * @param creationFunction defines the function used to instanciate the new object
  90252. * @param source defines the source object
  90253. * @returns the new object
  90254. */
  90255. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90256. }
  90257. }
  90258. declare module BABYLON {
  90259. /**
  90260. * This is the base class of all the camera used in the application.
  90261. * @see http://doc.babylonjs.com/features/cameras
  90262. */
  90263. export class Camera extends Node {
  90264. /** @hidden */
  90265. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90266. /**
  90267. * This is the default projection mode used by the cameras.
  90268. * It helps recreating a feeling of perspective and better appreciate depth.
  90269. * This is the best way to simulate real life cameras.
  90270. */
  90271. static readonly PERSPECTIVE_CAMERA: number;
  90272. /**
  90273. * This helps creating camera with an orthographic mode.
  90274. * 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.
  90275. */
  90276. static readonly ORTHOGRAPHIC_CAMERA: number;
  90277. /**
  90278. * This is the default FOV mode for perspective cameras.
  90279. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90280. */
  90281. static readonly FOVMODE_VERTICAL_FIXED: number;
  90282. /**
  90283. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90284. */
  90285. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90286. /**
  90287. * This specifies ther is no need for a camera rig.
  90288. * Basically only one eye is rendered corresponding to the camera.
  90289. */
  90290. static readonly RIG_MODE_NONE: number;
  90291. /**
  90292. * Simulates a camera Rig with one blue eye and one red eye.
  90293. * This can be use with 3d blue and red glasses.
  90294. */
  90295. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90296. /**
  90297. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90298. */
  90299. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90300. /**
  90301. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90302. */
  90303. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90304. /**
  90305. * Defines that both eyes of the camera will be rendered over under each other.
  90306. */
  90307. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90308. /**
  90309. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90310. */
  90311. static readonly RIG_MODE_VR: number;
  90312. /**
  90313. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90314. */
  90315. static readonly RIG_MODE_WEBVR: number;
  90316. /**
  90317. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90318. */
  90319. static readonly RIG_MODE_CUSTOM: number;
  90320. /**
  90321. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90322. */
  90323. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90324. /**
  90325. * Define the input manager associated with the camera.
  90326. */
  90327. inputs: CameraInputsManager<Camera>;
  90328. /** @hidden */
  90329. _position: Vector3;
  90330. /**
  90331. * Define the current local position of the camera in the scene
  90332. */
  90333. position: Vector3;
  90334. /**
  90335. * The vector the camera should consider as up.
  90336. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90337. */
  90338. upVector: Vector3;
  90339. /**
  90340. * Define the current limit on the left side for an orthographic camera
  90341. * In scene unit
  90342. */
  90343. orthoLeft: Nullable<number>;
  90344. /**
  90345. * Define the current limit on the right side for an orthographic camera
  90346. * In scene unit
  90347. */
  90348. orthoRight: Nullable<number>;
  90349. /**
  90350. * Define the current limit on the bottom side for an orthographic camera
  90351. * In scene unit
  90352. */
  90353. orthoBottom: Nullable<number>;
  90354. /**
  90355. * Define the current limit on the top side for an orthographic camera
  90356. * In scene unit
  90357. */
  90358. orthoTop: Nullable<number>;
  90359. /**
  90360. * Field Of View is set in Radians. (default is 0.8)
  90361. */
  90362. fov: number;
  90363. /**
  90364. * Define the minimum distance the camera can see from.
  90365. * This is important to note that the depth buffer are not infinite and the closer it starts
  90366. * the more your scene might encounter depth fighting issue.
  90367. */
  90368. minZ: number;
  90369. /**
  90370. * Define the maximum distance the camera can see to.
  90371. * This is important to note that the depth buffer are not infinite and the further it end
  90372. * the more your scene might encounter depth fighting issue.
  90373. */
  90374. maxZ: number;
  90375. /**
  90376. * Define the default inertia of the camera.
  90377. * This helps giving a smooth feeling to the camera movement.
  90378. */
  90379. inertia: number;
  90380. /**
  90381. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90382. */
  90383. mode: number;
  90384. /**
  90385. * Define wether the camera is intermediate.
  90386. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90387. */
  90388. isIntermediate: boolean;
  90389. /**
  90390. * Define the viewport of the camera.
  90391. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90392. */
  90393. viewport: Viewport;
  90394. /**
  90395. * Restricts the camera to viewing objects with the same layerMask.
  90396. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90397. */
  90398. layerMask: number;
  90399. /**
  90400. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90401. */
  90402. fovMode: number;
  90403. /**
  90404. * Rig mode of the camera.
  90405. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90406. * This is normally controlled byt the camera themselves as internal use.
  90407. */
  90408. cameraRigMode: number;
  90409. /**
  90410. * Defines the distance between both "eyes" in case of a RIG
  90411. */
  90412. interaxialDistance: number;
  90413. /**
  90414. * Defines if stereoscopic rendering is done side by side or over under.
  90415. */
  90416. isStereoscopicSideBySide: boolean;
  90417. /**
  90418. * 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
  90419. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90420. * else in the scene.
  90421. */
  90422. customRenderTargets: RenderTargetTexture[];
  90423. /**
  90424. * When set, the camera will render to this render target instead of the default canvas
  90425. */
  90426. outputRenderTarget: Nullable<RenderTargetTexture>;
  90427. /**
  90428. * Observable triggered when the camera view matrix has changed.
  90429. */
  90430. onViewMatrixChangedObservable: Observable<Camera>;
  90431. /**
  90432. * Observable triggered when the camera Projection matrix has changed.
  90433. */
  90434. onProjectionMatrixChangedObservable: Observable<Camera>;
  90435. /**
  90436. * Observable triggered when the inputs have been processed.
  90437. */
  90438. onAfterCheckInputsObservable: Observable<Camera>;
  90439. /**
  90440. * Observable triggered when reset has been called and applied to the camera.
  90441. */
  90442. onRestoreStateObservable: Observable<Camera>;
  90443. /** @hidden */
  90444. _cameraRigParams: any;
  90445. /** @hidden */
  90446. _rigCameras: Camera[];
  90447. /** @hidden */
  90448. _rigPostProcess: Nullable<PostProcess>;
  90449. protected _webvrViewMatrix: Matrix;
  90450. /** @hidden */
  90451. _skipRendering: boolean;
  90452. /** @hidden */
  90453. _projectionMatrix: Matrix;
  90454. /** @hidden */
  90455. _postProcesses: Nullable<PostProcess>[];
  90456. /** @hidden */
  90457. _activeMeshes: SmartArray<AbstractMesh>;
  90458. protected _globalPosition: Vector3;
  90459. /** hidden */
  90460. _computedViewMatrix: Matrix;
  90461. private _doNotComputeProjectionMatrix;
  90462. private _transformMatrix;
  90463. private _frustumPlanes;
  90464. private _refreshFrustumPlanes;
  90465. private _storedFov;
  90466. private _stateStored;
  90467. /**
  90468. * Instantiates a new camera object.
  90469. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90470. * @see http://doc.babylonjs.com/features/cameras
  90471. * @param name Defines the name of the camera in the scene
  90472. * @param position Defines the position of the camera
  90473. * @param scene Defines the scene the camera belongs too
  90474. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90475. */
  90476. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90477. /**
  90478. * Store current camera state (fov, position, etc..)
  90479. * @returns the camera
  90480. */
  90481. storeState(): Camera;
  90482. /**
  90483. * Restores the camera state values if it has been stored. You must call storeState() first
  90484. */
  90485. protected _restoreStateValues(): boolean;
  90486. /**
  90487. * Restored camera state. You must call storeState() first.
  90488. * @returns true if restored and false otherwise
  90489. */
  90490. restoreState(): boolean;
  90491. /**
  90492. * Gets the class name of the camera.
  90493. * @returns the class name
  90494. */
  90495. getClassName(): string;
  90496. /** @hidden */
  90497. readonly _isCamera: boolean;
  90498. /**
  90499. * Gets a string representation of the camera useful for debug purpose.
  90500. * @param fullDetails Defines that a more verboe level of logging is required
  90501. * @returns the string representation
  90502. */
  90503. toString(fullDetails?: boolean): string;
  90504. /**
  90505. * Gets the current world space position of the camera.
  90506. */
  90507. readonly globalPosition: Vector3;
  90508. /**
  90509. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90510. * @returns the active meshe list
  90511. */
  90512. getActiveMeshes(): SmartArray<AbstractMesh>;
  90513. /**
  90514. * Check wether a mesh is part of the current active mesh list of the camera
  90515. * @param mesh Defines the mesh to check
  90516. * @returns true if active, false otherwise
  90517. */
  90518. isActiveMesh(mesh: Mesh): boolean;
  90519. /**
  90520. * Is this camera ready to be used/rendered
  90521. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90522. * @return true if the camera is ready
  90523. */
  90524. isReady(completeCheck?: boolean): boolean;
  90525. /** @hidden */
  90526. _initCache(): void;
  90527. /** @hidden */
  90528. _updateCache(ignoreParentClass?: boolean): void;
  90529. /** @hidden */
  90530. _isSynchronized(): boolean;
  90531. /** @hidden */
  90532. _isSynchronizedViewMatrix(): boolean;
  90533. /** @hidden */
  90534. _isSynchronizedProjectionMatrix(): boolean;
  90535. /**
  90536. * Attach the input controls to a specific dom element to get the input from.
  90537. * @param element Defines the element the controls should be listened from
  90538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90539. */
  90540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90541. /**
  90542. * Detach the current controls from the specified dom element.
  90543. * @param element Defines the element to stop listening the inputs from
  90544. */
  90545. detachControl(element: HTMLElement): void;
  90546. /**
  90547. * Update the camera state according to the different inputs gathered during the frame.
  90548. */
  90549. update(): void;
  90550. /** @hidden */
  90551. _checkInputs(): void;
  90552. /** @hidden */
  90553. readonly rigCameras: Camera[];
  90554. /**
  90555. * Gets the post process used by the rig cameras
  90556. */
  90557. readonly rigPostProcess: Nullable<PostProcess>;
  90558. /**
  90559. * Internal, gets the first post proces.
  90560. * @returns the first post process to be run on this camera.
  90561. */
  90562. _getFirstPostProcess(): Nullable<PostProcess>;
  90563. private _cascadePostProcessesToRigCams;
  90564. /**
  90565. * Attach a post process to the camera.
  90566. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90567. * @param postProcess The post process to attach to the camera
  90568. * @param insertAt The position of the post process in case several of them are in use in the scene
  90569. * @returns the position the post process has been inserted at
  90570. */
  90571. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90572. /**
  90573. * Detach a post process to the camera.
  90574. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90575. * @param postProcess The post process to detach from the camera
  90576. */
  90577. detachPostProcess(postProcess: PostProcess): void;
  90578. /**
  90579. * Gets the current world matrix of the camera
  90580. */
  90581. getWorldMatrix(): Matrix;
  90582. /** @hidden */
  90583. _getViewMatrix(): Matrix;
  90584. /**
  90585. * Gets the current view matrix of the camera.
  90586. * @param force forces the camera to recompute the matrix without looking at the cached state
  90587. * @returns the view matrix
  90588. */
  90589. getViewMatrix(force?: boolean): Matrix;
  90590. /**
  90591. * Freeze the projection matrix.
  90592. * It will prevent the cache check of the camera projection compute and can speed up perf
  90593. * if no parameter of the camera are meant to change
  90594. * @param projection Defines manually a projection if necessary
  90595. */
  90596. freezeProjectionMatrix(projection?: Matrix): void;
  90597. /**
  90598. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90599. */
  90600. unfreezeProjectionMatrix(): void;
  90601. /**
  90602. * Gets the current projection matrix of the camera.
  90603. * @param force forces the camera to recompute the matrix without looking at the cached state
  90604. * @returns the projection matrix
  90605. */
  90606. getProjectionMatrix(force?: boolean): Matrix;
  90607. /**
  90608. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90609. * @returns a Matrix
  90610. */
  90611. getTransformationMatrix(): Matrix;
  90612. private _updateFrustumPlanes;
  90613. /**
  90614. * Checks if a cullable object (mesh...) is in the camera frustum
  90615. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90616. * @param target The object to check
  90617. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90618. * @returns true if the object is in frustum otherwise false
  90619. */
  90620. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90621. /**
  90622. * Checks if a cullable object (mesh...) is in the camera frustum
  90623. * Unlike isInFrustum this cheks the full bounding box
  90624. * @param target The object to check
  90625. * @returns true if the object is in frustum otherwise false
  90626. */
  90627. isCompletelyInFrustum(target: ICullable): boolean;
  90628. /**
  90629. * Gets a ray in the forward direction from the camera.
  90630. * @param length Defines the length of the ray to create
  90631. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90632. * @param origin Defines the start point of the ray which defaults to the camera position
  90633. * @returns the forward ray
  90634. */
  90635. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90636. /**
  90637. * Releases resources associated with this node.
  90638. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90639. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90640. */
  90641. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90642. /** @hidden */
  90643. _isLeftCamera: boolean;
  90644. /**
  90645. * Gets the left camera of a rig setup in case of Rigged Camera
  90646. */
  90647. readonly isLeftCamera: boolean;
  90648. /** @hidden */
  90649. _isRightCamera: boolean;
  90650. /**
  90651. * Gets the right camera of a rig setup in case of Rigged Camera
  90652. */
  90653. readonly isRightCamera: boolean;
  90654. /**
  90655. * Gets the left camera of a rig setup in case of Rigged Camera
  90656. */
  90657. readonly leftCamera: Nullable<FreeCamera>;
  90658. /**
  90659. * Gets the right camera of a rig setup in case of Rigged Camera
  90660. */
  90661. readonly rightCamera: Nullable<FreeCamera>;
  90662. /**
  90663. * Gets the left camera target of a rig setup in case of Rigged Camera
  90664. * @returns the target position
  90665. */
  90666. getLeftTarget(): Nullable<Vector3>;
  90667. /**
  90668. * Gets the right camera target of a rig setup in case of Rigged Camera
  90669. * @returns the target position
  90670. */
  90671. getRightTarget(): Nullable<Vector3>;
  90672. /**
  90673. * @hidden
  90674. */
  90675. setCameraRigMode(mode: number, rigParams: any): void;
  90676. /** @hidden */
  90677. static _setStereoscopicRigMode(camera: Camera): void;
  90678. /** @hidden */
  90679. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90680. /** @hidden */
  90681. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90682. /** @hidden */
  90683. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90684. /** @hidden */
  90685. _getVRProjectionMatrix(): Matrix;
  90686. protected _updateCameraRotationMatrix(): void;
  90687. protected _updateWebVRCameraRotationMatrix(): void;
  90688. /**
  90689. * This function MUST be overwritten by the different WebVR cameras available.
  90690. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90691. * @hidden
  90692. */
  90693. _getWebVRProjectionMatrix(): Matrix;
  90694. /**
  90695. * This function MUST be overwritten by the different WebVR cameras available.
  90696. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90697. * @hidden
  90698. */
  90699. _getWebVRViewMatrix(): Matrix;
  90700. /** @hidden */
  90701. setCameraRigParameter(name: string, value: any): void;
  90702. /**
  90703. * needs to be overridden by children so sub has required properties to be copied
  90704. * @hidden
  90705. */
  90706. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90707. /**
  90708. * May need to be overridden by children
  90709. * @hidden
  90710. */
  90711. _updateRigCameras(): void;
  90712. /** @hidden */
  90713. _setupInputs(): void;
  90714. /**
  90715. * Serialiaze the camera setup to a json represention
  90716. * @returns the JSON representation
  90717. */
  90718. serialize(): any;
  90719. /**
  90720. * Clones the current camera.
  90721. * @param name The cloned camera name
  90722. * @returns the cloned camera
  90723. */
  90724. clone(name: string): Camera;
  90725. /**
  90726. * Gets the direction of the camera relative to a given local axis.
  90727. * @param localAxis Defines the reference axis to provide a relative direction.
  90728. * @return the direction
  90729. */
  90730. getDirection(localAxis: Vector3): Vector3;
  90731. /**
  90732. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90733. * @param localAxis Defines the reference axis to provide a relative direction.
  90734. * @param result Defines the vector to store the result in
  90735. */
  90736. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90737. /**
  90738. * Gets a camera constructor for a given camera type
  90739. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90740. * @param name The name of the camera the result will be able to instantiate
  90741. * @param scene The scene the result will construct the camera in
  90742. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90743. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90744. * @returns a factory method to construc the camera
  90745. */
  90746. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90747. /**
  90748. * Compute the world matrix of the camera.
  90749. * @returns the camera workd matrix
  90750. */
  90751. computeWorldMatrix(): Matrix;
  90752. /**
  90753. * Parse a JSON and creates the camera from the parsed information
  90754. * @param parsedCamera The JSON to parse
  90755. * @param scene The scene to instantiate the camera in
  90756. * @returns the newly constructed camera
  90757. */
  90758. static Parse(parsedCamera: any, scene: Scene): Camera;
  90759. }
  90760. }
  90761. declare module BABYLON {
  90762. /**
  90763. * Interface for any object that can request an animation frame
  90764. */
  90765. export interface ICustomAnimationFrameRequester {
  90766. /**
  90767. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90768. */
  90769. renderFunction?: Function;
  90770. /**
  90771. * Called to request the next frame to render to
  90772. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90773. */
  90774. requestAnimationFrame: Function;
  90775. /**
  90776. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90777. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90778. */
  90779. requestID?: number;
  90780. }
  90781. /**
  90782. * Interface containing an array of animations
  90783. */
  90784. export interface IAnimatable {
  90785. /**
  90786. * Array of animations
  90787. */
  90788. animations: Nullable<Array<Animation>>;
  90789. }
  90790. /** Interface used by value gradients (color, factor, ...) */
  90791. export interface IValueGradient {
  90792. /**
  90793. * Gets or sets the gradient value (between 0 and 1)
  90794. */
  90795. gradient: number;
  90796. }
  90797. /** Class used to store color4 gradient */
  90798. export class ColorGradient implements IValueGradient {
  90799. /**
  90800. * Gets or sets the gradient value (between 0 and 1)
  90801. */
  90802. gradient: number;
  90803. /**
  90804. * Gets or sets first associated color
  90805. */
  90806. color1: Color4;
  90807. /**
  90808. * Gets or sets second associated color
  90809. */
  90810. color2?: Color4;
  90811. /**
  90812. * Will get a color picked randomly between color1 and color2.
  90813. * If color2 is undefined then color1 will be used
  90814. * @param result defines the target Color4 to store the result in
  90815. */
  90816. getColorToRef(result: Color4): void;
  90817. }
  90818. /** Class used to store color 3 gradient */
  90819. export class Color3Gradient implements IValueGradient {
  90820. /**
  90821. * Gets or sets the gradient value (between 0 and 1)
  90822. */
  90823. gradient: number;
  90824. /**
  90825. * Gets or sets the associated color
  90826. */
  90827. color: Color3;
  90828. }
  90829. /** Class used to store factor gradient */
  90830. export class FactorGradient implements IValueGradient {
  90831. /**
  90832. * Gets or sets the gradient value (between 0 and 1)
  90833. */
  90834. gradient: number;
  90835. /**
  90836. * Gets or sets first associated factor
  90837. */
  90838. factor1: number;
  90839. /**
  90840. * Gets or sets second associated factor
  90841. */
  90842. factor2?: number;
  90843. /**
  90844. * Will get a number picked randomly between factor1 and factor2.
  90845. * If factor2 is undefined then factor1 will be used
  90846. * @returns the picked number
  90847. */
  90848. getFactor(): number;
  90849. }
  90850. /**
  90851. * @ignore
  90852. * Application error to support additional information when loading a file
  90853. */
  90854. export class LoadFileError extends Error {
  90855. /** defines the optional web request */
  90856. request?: WebRequest | undefined;
  90857. private static _setPrototypeOf;
  90858. /**
  90859. * Creates a new LoadFileError
  90860. * @param message defines the message of the error
  90861. * @param request defines the optional web request
  90862. */
  90863. constructor(message: string,
  90864. /** defines the optional web request */
  90865. request?: WebRequest | undefined);
  90866. }
  90867. /**
  90868. * Class used to define a retry strategy when error happens while loading assets
  90869. */
  90870. export class RetryStrategy {
  90871. /**
  90872. * Function used to defines an exponential back off strategy
  90873. * @param maxRetries defines the maximum number of retries (3 by default)
  90874. * @param baseInterval defines the interval between retries
  90875. * @returns the strategy function to use
  90876. */
  90877. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90878. }
  90879. /**
  90880. * File request interface
  90881. */
  90882. export interface IFileRequest {
  90883. /**
  90884. * Raised when the request is complete (success or error).
  90885. */
  90886. onCompleteObservable: Observable<IFileRequest>;
  90887. /**
  90888. * Aborts the request for a file.
  90889. */
  90890. abort: () => void;
  90891. }
  90892. /**
  90893. * Class containing a set of static utilities functions
  90894. */
  90895. export class Tools {
  90896. /**
  90897. * Gets or sets the base URL to use to load assets
  90898. */
  90899. static BaseUrl: string;
  90900. /**
  90901. * Enable/Disable Custom HTTP Request Headers globally.
  90902. * default = false
  90903. * @see CustomRequestHeaders
  90904. */
  90905. static UseCustomRequestHeaders: boolean;
  90906. /**
  90907. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90908. * i.e. when loading files, where the server/service expects an Authorization header
  90909. */
  90910. static CustomRequestHeaders: {
  90911. [key: string]: string;
  90912. };
  90913. /**
  90914. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90915. */
  90916. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90917. /**
  90918. * Default behaviour for cors in the application.
  90919. * It can be a string if the expected behavior is identical in the entire app.
  90920. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90921. */
  90922. static CorsBehavior: string | ((url: string | string[]) => string);
  90923. /**
  90924. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90925. * @ignorenaming
  90926. */
  90927. static UseFallbackTexture: boolean;
  90928. /**
  90929. * Use this object to register external classes like custom textures or material
  90930. * to allow the laoders to instantiate them
  90931. */
  90932. static RegisteredExternalClasses: {
  90933. [key: string]: Object;
  90934. };
  90935. /**
  90936. * Texture content used if a texture cannot loaded
  90937. * @ignorenaming
  90938. */
  90939. static fallbackTexture: string;
  90940. /**
  90941. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90942. * @param u defines the coordinate on X axis
  90943. * @param v defines the coordinate on Y axis
  90944. * @param width defines the width of the source data
  90945. * @param height defines the height of the source data
  90946. * @param pixels defines the source byte array
  90947. * @param color defines the output color
  90948. */
  90949. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90950. /**
  90951. * Interpolates between a and b via alpha
  90952. * @param a The lower value (returned when alpha = 0)
  90953. * @param b The upper value (returned when alpha = 1)
  90954. * @param alpha The interpolation-factor
  90955. * @return The mixed value
  90956. */
  90957. static Mix(a: number, b: number, alpha: number): number;
  90958. /**
  90959. * Tries to instantiate a new object from a given class name
  90960. * @param className defines the class name to instantiate
  90961. * @returns the new object or null if the system was not able to do the instantiation
  90962. */
  90963. static Instantiate(className: string): any;
  90964. /**
  90965. * Provides a slice function that will work even on IE
  90966. * @param data defines the array to slice
  90967. * @param start defines the start of the data (optional)
  90968. * @param end defines the end of the data (optional)
  90969. * @returns the new sliced array
  90970. */
  90971. static Slice<T>(data: T, start?: number, end?: number): T;
  90972. /**
  90973. * Polyfill for setImmediate
  90974. * @param action defines the action to execute after the current execution block
  90975. */
  90976. static SetImmediate(action: () => void): void;
  90977. /**
  90978. * Function indicating if a number is an exponent of 2
  90979. * @param value defines the value to test
  90980. * @returns true if the value is an exponent of 2
  90981. */
  90982. static IsExponentOfTwo(value: number): boolean;
  90983. private static _tmpFloatArray;
  90984. /**
  90985. * Returns the nearest 32-bit single precision float representation of a Number
  90986. * @param value A Number. If the parameter is of a different type, it will get converted
  90987. * to a number or to NaN if it cannot be converted
  90988. * @returns number
  90989. */
  90990. static FloatRound(value: number): number;
  90991. /**
  90992. * Find the next highest power of two.
  90993. * @param x Number to start search from.
  90994. * @return Next highest power of two.
  90995. */
  90996. static CeilingPOT(x: number): number;
  90997. /**
  90998. * Find the next lowest power of two.
  90999. * @param x Number to start search from.
  91000. * @return Next lowest power of two.
  91001. */
  91002. static FloorPOT(x: number): number;
  91003. /**
  91004. * Find the nearest power of two.
  91005. * @param x Number to start search from.
  91006. * @return Next nearest power of two.
  91007. */
  91008. static NearestPOT(x: number): number;
  91009. /**
  91010. * Get the closest exponent of two
  91011. * @param value defines the value to approximate
  91012. * @param max defines the maximum value to return
  91013. * @param mode defines how to define the closest value
  91014. * @returns closest exponent of two of the given value
  91015. */
  91016. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  91017. /**
  91018. * Extracts the filename from a path
  91019. * @param path defines the path to use
  91020. * @returns the filename
  91021. */
  91022. static GetFilename(path: string): string;
  91023. /**
  91024. * Extracts the "folder" part of a path (everything before the filename).
  91025. * @param uri The URI to extract the info from
  91026. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  91027. * @returns The "folder" part of the path
  91028. */
  91029. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  91030. /**
  91031. * Extracts text content from a DOM element hierarchy
  91032. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  91033. */
  91034. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  91035. /**
  91036. * Convert an angle in radians to degrees
  91037. * @param angle defines the angle to convert
  91038. * @returns the angle in degrees
  91039. */
  91040. static ToDegrees(angle: number): number;
  91041. /**
  91042. * Convert an angle in degrees to radians
  91043. * @param angle defines the angle to convert
  91044. * @returns the angle in radians
  91045. */
  91046. static ToRadians(angle: number): number;
  91047. /**
  91048. * Encode a buffer to a base64 string
  91049. * @param buffer defines the buffer to encode
  91050. * @returns the encoded string
  91051. */
  91052. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  91053. /**
  91054. * Extracts minimum and maximum values from a list of indexed positions
  91055. * @param positions defines the positions to use
  91056. * @param indices defines the indices to the positions
  91057. * @param indexStart defines the start index
  91058. * @param indexCount defines the end index
  91059. * @param bias defines bias value to add to the result
  91060. * @return minimum and maximum values
  91061. */
  91062. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  91063. minimum: Vector3;
  91064. maximum: Vector3;
  91065. };
  91066. /**
  91067. * Extracts minimum and maximum values from a list of positions
  91068. * @param positions defines the positions to use
  91069. * @param start defines the start index in the positions array
  91070. * @param count defines the number of positions to handle
  91071. * @param bias defines bias value to add to the result
  91072. * @param stride defines the stride size to use (distance between two positions in the positions array)
  91073. * @return minimum and maximum values
  91074. */
  91075. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  91076. minimum: Vector3;
  91077. maximum: Vector3;
  91078. };
  91079. /**
  91080. * Returns an array if obj is not an array
  91081. * @param obj defines the object to evaluate as an array
  91082. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  91083. * @returns either obj directly if obj is an array or a new array containing obj
  91084. */
  91085. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  91086. /**
  91087. * Gets the pointer prefix to use
  91088. * @returns "pointer" if touch is enabled. Else returns "mouse"
  91089. */
  91090. static GetPointerPrefix(): string;
  91091. /**
  91092. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  91093. * @param func - the function to be called
  91094. * @param requester - the object that will request the next frame. Falls back to window.
  91095. * @returns frame number
  91096. */
  91097. static QueueNewFrame(func: () => void, requester?: any): number;
  91098. /**
  91099. * Ask the browser to promote the current element to fullscreen rendering mode
  91100. * @param element defines the DOM element to promote
  91101. */
  91102. static RequestFullscreen(element: HTMLElement): void;
  91103. /**
  91104. * Asks the browser to exit fullscreen mode
  91105. */
  91106. static ExitFullscreen(): void;
  91107. /**
  91108. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  91109. * @param url define the url we are trying
  91110. * @param element define the dom element where to configure the cors policy
  91111. */
  91112. static SetCorsBehavior(url: string | string[], element: {
  91113. crossOrigin: string | null;
  91114. }): void;
  91115. /**
  91116. * Removes unwanted characters from an url
  91117. * @param url defines the url to clean
  91118. * @returns the cleaned url
  91119. */
  91120. static CleanUrl(url: string): string;
  91121. /**
  91122. * Gets or sets a function used to pre-process url before using them to load assets
  91123. */
  91124. static PreprocessUrl: (url: string) => string;
  91125. /**
  91126. * Loads an image as an HTMLImageElement.
  91127. * @param input url string, ArrayBuffer, or Blob to load
  91128. * @param onLoad callback called when the image successfully loads
  91129. * @param onError callback called when the image fails to load
  91130. * @param offlineProvider offline provider for caching
  91131. * @returns the HTMLImageElement of the loaded image
  91132. */
  91133. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  91134. /**
  91135. * Loads a file
  91136. * @param url url string, ArrayBuffer, or Blob to load
  91137. * @param onSuccess callback called when the file successfully loads
  91138. * @param onProgress callback called while file is loading (if the server supports this mode)
  91139. * @param offlineProvider defines the offline provider for caching
  91140. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  91141. * @param onError callback called when the file fails to load
  91142. * @returns a file request object
  91143. */
  91144. 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;
  91145. /**
  91146. * Load a script (identified by an url). When the url returns, the
  91147. * content of this file is added into a new script element, attached to the DOM (body element)
  91148. * @param scriptUrl defines the url of the script to laod
  91149. * @param onSuccess defines the callback called when the script is loaded
  91150. * @param onError defines the callback to call if an error occurs
  91151. * @param scriptId defines the id of the script element
  91152. */
  91153. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  91154. /**
  91155. * Load an asynchronous script (identified by an url). When the url returns, the
  91156. * content of this file is added into a new script element, attached to the DOM (body element)
  91157. * @param scriptUrl defines the url of the script to laod
  91158. * @param scriptId defines the id of the script element
  91159. * @returns a promise request object
  91160. */
  91161. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  91162. /**
  91163. * Loads a file from a blob
  91164. * @param fileToLoad defines the blob to use
  91165. * @param callback defines the callback to call when data is loaded
  91166. * @param progressCallback defines the callback to call during loading process
  91167. * @returns a file request object
  91168. */
  91169. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  91170. /**
  91171. * Loads a file
  91172. * @param fileToLoad defines the file to load
  91173. * @param callback defines the callback to call when data is loaded
  91174. * @param progressCallBack defines the callback to call during loading process
  91175. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  91176. * @returns a file request object
  91177. */
  91178. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  91179. /**
  91180. * Creates a data url from a given string content
  91181. * @param content defines the content to convert
  91182. * @returns the new data url link
  91183. */
  91184. static FileAsURL(content: string): string;
  91185. /**
  91186. * Format the given number to a specific decimal format
  91187. * @param value defines the number to format
  91188. * @param decimals defines the number of decimals to use
  91189. * @returns the formatted string
  91190. */
  91191. static Format(value: number, decimals?: number): string;
  91192. /**
  91193. * Checks if a given vector is inside a specific range
  91194. * @param v defines the vector to test
  91195. * @param min defines the minimum range
  91196. * @param max defines the maximum range
  91197. */
  91198. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91199. /**
  91200. * Tries to copy an object by duplicating every property
  91201. * @param source defines the source object
  91202. * @param destination defines the target object
  91203. * @param doNotCopyList defines a list of properties to avoid
  91204. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91205. */
  91206. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91207. /**
  91208. * Gets a boolean indicating if the given object has no own property
  91209. * @param obj defines the object to test
  91210. * @returns true if object has no own property
  91211. */
  91212. static IsEmpty(obj: any): boolean;
  91213. /**
  91214. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91215. * @param str Source string
  91216. * @param suffix Suffix to search for in the source string
  91217. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91218. */
  91219. static EndsWith(str: string, suffix: string): boolean;
  91220. /**
  91221. * Function used to register events at window level
  91222. * @param events defines the events to register
  91223. */
  91224. static RegisterTopRootEvents(events: {
  91225. name: string;
  91226. handler: Nullable<(e: FocusEvent) => any>;
  91227. }[]): void;
  91228. /**
  91229. * Function used to unregister events from window level
  91230. * @param events defines the events to unregister
  91231. */
  91232. static UnregisterTopRootEvents(events: {
  91233. name: string;
  91234. handler: Nullable<(e: FocusEvent) => any>;
  91235. }[]): void;
  91236. /**
  91237. * @ignore
  91238. */
  91239. static _ScreenshotCanvas: HTMLCanvasElement;
  91240. /**
  91241. * Dumps the current bound framebuffer
  91242. * @param width defines the rendering width
  91243. * @param height defines the rendering height
  91244. * @param engine defines the hosting engine
  91245. * @param successCallback defines the callback triggered once the data are available
  91246. * @param mimeType defines the mime type of the result
  91247. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91248. */
  91249. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91250. /**
  91251. * Converts the canvas data to blob.
  91252. * This acts as a polyfill for browsers not supporting the to blob function.
  91253. * @param canvas Defines the canvas to extract the data from
  91254. * @param successCallback Defines the callback triggered once the data are available
  91255. * @param mimeType Defines the mime type of the result
  91256. */
  91257. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91258. /**
  91259. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91260. * @param successCallback defines the callback triggered once the data are available
  91261. * @param mimeType defines the mime type of the result
  91262. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91263. */
  91264. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91265. /**
  91266. * Downloads a blob in the browser
  91267. * @param blob defines the blob to download
  91268. * @param fileName defines the name of the downloaded file
  91269. */
  91270. static Download(blob: Blob, fileName: string): void;
  91271. /**
  91272. * Captures a screenshot of the current rendering
  91273. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91274. * @param engine defines the rendering engine
  91275. * @param camera defines the source camera
  91276. * @param size This parameter can be set to a single number or to an object with the
  91277. * following (optional) properties: precision, width, height. If a single number is passed,
  91278. * it will be used for both width and height. If an object is passed, the screenshot size
  91279. * will be derived from the parameters. The precision property is a multiplier allowing
  91280. * rendering at a higher or lower resolution
  91281. * @param successCallback defines the callback receives a single parameter which contains the
  91282. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91283. * src parameter of an <img> to display it
  91284. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91285. * Check your browser for supported MIME types
  91286. */
  91287. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91288. /**
  91289. * Generates an image screenshot from the specified camera.
  91290. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91291. * @param engine The engine to use for rendering
  91292. * @param camera The camera to use for rendering
  91293. * @param size This parameter can be set to a single number or to an object with the
  91294. * following (optional) properties: precision, width, height. If a single number is passed,
  91295. * it will be used for both width and height. If an object is passed, the screenshot size
  91296. * will be derived from the parameters. The precision property is a multiplier allowing
  91297. * rendering at a higher or lower resolution
  91298. * @param successCallback The callback receives a single parameter which contains the
  91299. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91300. * src parameter of an <img> to display it
  91301. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91302. * Check your browser for supported MIME types
  91303. * @param samples Texture samples (default: 1)
  91304. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91305. * @param fileName A name for for the downloaded file.
  91306. */
  91307. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91308. /**
  91309. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91310. * Be aware Math.random() could cause collisions, but:
  91311. * "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"
  91312. * @returns a pseudo random id
  91313. */
  91314. static RandomId(): string;
  91315. /**
  91316. * Test if the given uri is a base64 string
  91317. * @param uri The uri to test
  91318. * @return True if the uri is a base64 string or false otherwise
  91319. */
  91320. static IsBase64(uri: string): boolean;
  91321. /**
  91322. * Decode the given base64 uri.
  91323. * @param uri The uri to decode
  91324. * @return The decoded base64 data.
  91325. */
  91326. static DecodeBase64(uri: string): ArrayBuffer;
  91327. /**
  91328. * Gets the absolute url.
  91329. * @param url the input url
  91330. * @return the absolute url
  91331. */
  91332. static GetAbsoluteUrl(url: string): string;
  91333. /**
  91334. * No log
  91335. */
  91336. static readonly NoneLogLevel: number;
  91337. /**
  91338. * Only message logs
  91339. */
  91340. static readonly MessageLogLevel: number;
  91341. /**
  91342. * Only warning logs
  91343. */
  91344. static readonly WarningLogLevel: number;
  91345. /**
  91346. * Only error logs
  91347. */
  91348. static readonly ErrorLogLevel: number;
  91349. /**
  91350. * All logs
  91351. */
  91352. static readonly AllLogLevel: number;
  91353. /**
  91354. * Gets a value indicating the number of loading errors
  91355. * @ignorenaming
  91356. */
  91357. static readonly errorsCount: number;
  91358. /**
  91359. * Callback called when a new log is added
  91360. */
  91361. static OnNewCacheEntry: (entry: string) => void;
  91362. /**
  91363. * Log a message to the console
  91364. * @param message defines the message to log
  91365. */
  91366. static Log(message: string): void;
  91367. /**
  91368. * Write a warning message to the console
  91369. * @param message defines the message to log
  91370. */
  91371. static Warn(message: string): void;
  91372. /**
  91373. * Write an error message to the console
  91374. * @param message defines the message to log
  91375. */
  91376. static Error(message: string): void;
  91377. /**
  91378. * Gets current log cache (list of logs)
  91379. */
  91380. static readonly LogCache: string;
  91381. /**
  91382. * Clears the log cache
  91383. */
  91384. static ClearLogCache(): void;
  91385. /**
  91386. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91387. */
  91388. static LogLevels: number;
  91389. /**
  91390. * Checks if the loaded document was accessed via `file:`-Protocol.
  91391. * @returns boolean
  91392. */
  91393. static IsFileURL(): boolean;
  91394. /**
  91395. * Checks if the window object exists
  91396. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91397. */
  91398. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91399. /**
  91400. * No performance log
  91401. */
  91402. static readonly PerformanceNoneLogLevel: number;
  91403. /**
  91404. * Use user marks to log performance
  91405. */
  91406. static readonly PerformanceUserMarkLogLevel: number;
  91407. /**
  91408. * Log performance to the console
  91409. */
  91410. static readonly PerformanceConsoleLogLevel: number;
  91411. private static _performance;
  91412. /**
  91413. * Sets the current performance log level
  91414. */
  91415. static PerformanceLogLevel: number;
  91416. private static _StartPerformanceCounterDisabled;
  91417. private static _EndPerformanceCounterDisabled;
  91418. private static _StartUserMark;
  91419. private static _EndUserMark;
  91420. private static _StartPerformanceConsole;
  91421. private static _EndPerformanceConsole;
  91422. /**
  91423. * Starts a performance counter
  91424. */
  91425. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91426. /**
  91427. * Ends a specific performance coutner
  91428. */
  91429. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91430. /**
  91431. * Gets either window.performance.now() if supported or Date.now() else
  91432. */
  91433. static readonly Now: number;
  91434. /**
  91435. * This method will return the name of the class used to create the instance of the given object.
  91436. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91437. * @param object the object to get the class name from
  91438. * @param isType defines if the object is actually a type
  91439. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91440. */
  91441. static GetClassName(object: any, isType?: boolean): string;
  91442. /**
  91443. * Gets the first element of an array satisfying a given predicate
  91444. * @param array defines the array to browse
  91445. * @param predicate defines the predicate to use
  91446. * @returns null if not found or the element
  91447. */
  91448. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91449. /**
  91450. * This method will return the name of the full name of the class, including its owning module (if any).
  91451. * 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).
  91452. * @param object the object to get the class name from
  91453. * @param isType defines if the object is actually a type
  91454. * @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.
  91455. * @ignorenaming
  91456. */
  91457. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91458. /**
  91459. * Returns a promise that resolves after the given amount of time.
  91460. * @param delay Number of milliseconds to delay
  91461. * @returns Promise that resolves after the given amount of time
  91462. */
  91463. static DelayAsync(delay: number): Promise<void>;
  91464. /**
  91465. * Gets the current gradient from an array of IValueGradient
  91466. * @param ratio defines the current ratio to get
  91467. * @param gradients defines the array of IValueGradient
  91468. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91469. */
  91470. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91471. }
  91472. /**
  91473. * This class is used to track a performance counter which is number based.
  91474. * The user has access to many properties which give statistics of different nature.
  91475. *
  91476. * The implementer can track two kinds of Performance Counter: time and count.
  91477. * 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.
  91478. * 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.
  91479. */
  91480. export class PerfCounter {
  91481. /**
  91482. * Gets or sets a global boolean to turn on and off all the counters
  91483. */
  91484. static Enabled: boolean;
  91485. /**
  91486. * Returns the smallest value ever
  91487. */
  91488. readonly min: number;
  91489. /**
  91490. * Returns the biggest value ever
  91491. */
  91492. readonly max: number;
  91493. /**
  91494. * Returns the average value since the performance counter is running
  91495. */
  91496. readonly average: number;
  91497. /**
  91498. * Returns the average value of the last second the counter was monitored
  91499. */
  91500. readonly lastSecAverage: number;
  91501. /**
  91502. * Returns the current value
  91503. */
  91504. readonly current: number;
  91505. /**
  91506. * Gets the accumulated total
  91507. */
  91508. readonly total: number;
  91509. /**
  91510. * Gets the total value count
  91511. */
  91512. readonly count: number;
  91513. /**
  91514. * Creates a new counter
  91515. */
  91516. constructor();
  91517. /**
  91518. * Call this method to start monitoring a new frame.
  91519. * 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.
  91520. */
  91521. fetchNewFrame(): void;
  91522. /**
  91523. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91524. * @param newCount the count value to add to the monitored count
  91525. * @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.
  91526. */
  91527. addCount(newCount: number, fetchResult: boolean): void;
  91528. /**
  91529. * Start monitoring this performance counter
  91530. */
  91531. beginMonitoring(): void;
  91532. /**
  91533. * Compute the time lapsed since the previous beginMonitoring() call.
  91534. * @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
  91535. */
  91536. endMonitoring(newFrame?: boolean): void;
  91537. private _fetchResult;
  91538. private _startMonitoringTime;
  91539. private _min;
  91540. private _max;
  91541. private _average;
  91542. private _current;
  91543. private _totalValueCount;
  91544. private _totalAccumulated;
  91545. private _lastSecAverage;
  91546. private _lastSecAccumulated;
  91547. private _lastSecTime;
  91548. private _lastSecValueCount;
  91549. }
  91550. /**
  91551. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91552. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91553. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91554. * @param name The name of the class, case should be preserved
  91555. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91556. */
  91557. export function className(name: string, module?: string): (target: Object) => void;
  91558. /**
  91559. * An implementation of a loop for asynchronous functions.
  91560. */
  91561. export class AsyncLoop {
  91562. /**
  91563. * Defines the number of iterations for the loop
  91564. */
  91565. iterations: number;
  91566. /**
  91567. * Defines the current index of the loop.
  91568. */
  91569. index: number;
  91570. private _done;
  91571. private _fn;
  91572. private _successCallback;
  91573. /**
  91574. * Constructor.
  91575. * @param iterations the number of iterations.
  91576. * @param func the function to run each iteration
  91577. * @param successCallback the callback that will be called upon succesful execution
  91578. * @param offset starting offset.
  91579. */
  91580. constructor(
  91581. /**
  91582. * Defines the number of iterations for the loop
  91583. */
  91584. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91585. /**
  91586. * Execute the next iteration. Must be called after the last iteration was finished.
  91587. */
  91588. executeNext(): void;
  91589. /**
  91590. * Break the loop and run the success callback.
  91591. */
  91592. breakLoop(): void;
  91593. /**
  91594. * Create and run an async loop.
  91595. * @param iterations the number of iterations.
  91596. * @param fn the function to run each iteration
  91597. * @param successCallback the callback that will be called upon succesful execution
  91598. * @param offset starting offset.
  91599. * @returns the created async loop object
  91600. */
  91601. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91602. /**
  91603. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91604. * @param iterations total number of iterations
  91605. * @param syncedIterations number of synchronous iterations in each async iteration.
  91606. * @param fn the function to call each iteration.
  91607. * @param callback a success call back that will be called when iterating stops.
  91608. * @param breakFunction a break condition (optional)
  91609. * @param timeout timeout settings for the setTimeout function. default - 0.
  91610. * @returns the created async loop object
  91611. */
  91612. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91613. }
  91614. }
  91615. declare module BABYLON {
  91616. /** @hidden */
  91617. export interface ICollisionCoordinator {
  91618. createCollider(): Collider;
  91619. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91620. init(scene: Scene): void;
  91621. }
  91622. /** @hidden */
  91623. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91624. private _scene;
  91625. private _scaledPosition;
  91626. private _scaledVelocity;
  91627. private _finalPosition;
  91628. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91629. createCollider(): Collider;
  91630. init(scene: Scene): void;
  91631. private _collideWithWorld;
  91632. }
  91633. }
  91634. declare module BABYLON {
  91635. /**
  91636. * Class used to manage all inputs for the scene.
  91637. */
  91638. export class InputManager {
  91639. /** The distance in pixel that you have to move to prevent some events */
  91640. static DragMovementThreshold: number;
  91641. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91642. static LongPressDelay: number;
  91643. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91644. static DoubleClickDelay: number;
  91645. /** If you need to check double click without raising a single click at first click, enable this flag */
  91646. static ExclusiveDoubleClickMode: boolean;
  91647. private _wheelEventName;
  91648. private _onPointerMove;
  91649. private _onPointerDown;
  91650. private _onPointerUp;
  91651. private _initClickEvent;
  91652. private _initActionManager;
  91653. private _delayedSimpleClick;
  91654. private _delayedSimpleClickTimeout;
  91655. private _previousDelayedSimpleClickTimeout;
  91656. private _meshPickProceed;
  91657. private _previousButtonPressed;
  91658. private _currentPickResult;
  91659. private _previousPickResult;
  91660. private _totalPointersPressed;
  91661. private _doubleClickOccured;
  91662. private _pointerOverMesh;
  91663. private _pickedDownMesh;
  91664. private _pickedUpMesh;
  91665. private _pointerX;
  91666. private _pointerY;
  91667. private _unTranslatedPointerX;
  91668. private _unTranslatedPointerY;
  91669. private _startingPointerPosition;
  91670. private _previousStartingPointerPosition;
  91671. private _startingPointerTime;
  91672. private _previousStartingPointerTime;
  91673. private _pointerCaptures;
  91674. private _onKeyDown;
  91675. private _onKeyUp;
  91676. private _onCanvasFocusObserver;
  91677. private _onCanvasBlurObserver;
  91678. private _scene;
  91679. /**
  91680. * Creates a new InputManager
  91681. * @param scene defines the hosting scene
  91682. */
  91683. constructor(scene: Scene);
  91684. /**
  91685. * Gets the mesh that is currently under the pointer
  91686. */
  91687. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91688. /**
  91689. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91690. */
  91691. readonly unTranslatedPointer: Vector2;
  91692. /**
  91693. * Gets or sets the current on-screen X position of the pointer
  91694. */
  91695. pointerX: number;
  91696. /**
  91697. * Gets or sets the current on-screen Y position of the pointer
  91698. */
  91699. pointerY: number;
  91700. private _updatePointerPosition;
  91701. private _processPointerMove;
  91702. private _setRayOnPointerInfo;
  91703. private _checkPrePointerObservable;
  91704. /**
  91705. * Use this method to simulate a pointer move on a mesh
  91706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91709. */
  91710. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91711. /**
  91712. * Use this method to simulate a pointer down on a mesh
  91713. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91714. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91715. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91716. */
  91717. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91718. private _processPointerDown;
  91719. /** @hidden */
  91720. _isPointerSwiping(): boolean;
  91721. /**
  91722. * Use this method to simulate a pointer up on a mesh
  91723. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91724. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91725. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91726. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91727. */
  91728. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91729. private _processPointerUp;
  91730. /**
  91731. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91732. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91733. * @returns true if the pointer was captured
  91734. */
  91735. isPointerCaptured(pointerId?: number): boolean;
  91736. /**
  91737. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91738. * @param attachUp defines if you want to attach events to pointerup
  91739. * @param attachDown defines if you want to attach events to pointerdown
  91740. * @param attachMove defines if you want to attach events to pointermove
  91741. */
  91742. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91743. /**
  91744. * Detaches all event handlers
  91745. */
  91746. detachControl(): void;
  91747. /**
  91748. * Force the value of meshUnderPointer
  91749. * @param mesh defines the mesh to use
  91750. */
  91751. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91752. /**
  91753. * Gets the mesh under the pointer
  91754. * @returns a Mesh or null if no mesh is under the pointer
  91755. */
  91756. getPointerOverMesh(): Nullable<AbstractMesh>;
  91757. }
  91758. }
  91759. declare module BABYLON {
  91760. /**
  91761. * This class defines the direct association between an animation and a target
  91762. */
  91763. export class TargetedAnimation {
  91764. /**
  91765. * Animation to perform
  91766. */
  91767. animation: Animation;
  91768. /**
  91769. * Target to animate
  91770. */
  91771. target: any;
  91772. }
  91773. /**
  91774. * Use this class to create coordinated animations on multiple targets
  91775. */
  91776. export class AnimationGroup implements IDisposable {
  91777. /** The name of the animation group */
  91778. name: string;
  91779. private _scene;
  91780. private _targetedAnimations;
  91781. private _animatables;
  91782. private _from;
  91783. private _to;
  91784. private _isStarted;
  91785. private _isPaused;
  91786. private _speedRatio;
  91787. private _loopAnimation;
  91788. /**
  91789. * Gets or sets the unique id of the node
  91790. */
  91791. uniqueId: number;
  91792. /**
  91793. * This observable will notify when one animation have ended
  91794. */
  91795. onAnimationEndObservable: Observable<TargetedAnimation>;
  91796. /**
  91797. * Observer raised when one animation loops
  91798. */
  91799. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91800. /**
  91801. * This observable will notify when all animations have ended.
  91802. */
  91803. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91804. /**
  91805. * This observable will notify when all animations have paused.
  91806. */
  91807. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91808. /**
  91809. * This observable will notify when all animations are playing.
  91810. */
  91811. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91812. /**
  91813. * Gets the first frame
  91814. */
  91815. readonly from: number;
  91816. /**
  91817. * Gets the last frame
  91818. */
  91819. readonly to: number;
  91820. /**
  91821. * Define if the animations are started
  91822. */
  91823. readonly isStarted: boolean;
  91824. /**
  91825. * Gets a value indicating that the current group is playing
  91826. */
  91827. readonly isPlaying: boolean;
  91828. /**
  91829. * Gets or sets the speed ratio to use for all animations
  91830. */
  91831. /**
  91832. * Gets or sets the speed ratio to use for all animations
  91833. */
  91834. speedRatio: number;
  91835. /**
  91836. * Gets or sets if all animations should loop or not
  91837. */
  91838. loopAnimation: boolean;
  91839. /**
  91840. * Gets the targeted animations for this animation group
  91841. */
  91842. readonly targetedAnimations: Array<TargetedAnimation>;
  91843. /**
  91844. * returning the list of animatables controlled by this animation group.
  91845. */
  91846. readonly animatables: Array<Animatable>;
  91847. /**
  91848. * Instantiates a new Animation Group.
  91849. * This helps managing several animations at once.
  91850. * @see http://doc.babylonjs.com/how_to/group
  91851. * @param name Defines the name of the group
  91852. * @param scene Defines the scene the group belongs to
  91853. */
  91854. constructor(
  91855. /** The name of the animation group */
  91856. name: string, scene?: Nullable<Scene>);
  91857. /**
  91858. * Add an animation (with its target) in the group
  91859. * @param animation defines the animation we want to add
  91860. * @param target defines the target of the animation
  91861. * @returns the TargetedAnimation object
  91862. */
  91863. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91864. /**
  91865. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91866. * It can add constant keys at begin or end
  91867. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91868. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91869. * @returns the animation group
  91870. */
  91871. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91872. /**
  91873. * Start all animations on given targets
  91874. * @param loop defines if animations must loop
  91875. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91876. * @param from defines the from key (optional)
  91877. * @param to defines the to key (optional)
  91878. * @returns the current animation group
  91879. */
  91880. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91881. /**
  91882. * Pause all animations
  91883. * @returns the animation group
  91884. */
  91885. pause(): AnimationGroup;
  91886. /**
  91887. * Play all animations to initial state
  91888. * This function will start() the animations if they were not started or will restart() them if they were paused
  91889. * @param loop defines if animations must loop
  91890. * @returns the animation group
  91891. */
  91892. play(loop?: boolean): AnimationGroup;
  91893. /**
  91894. * Reset all animations to initial state
  91895. * @returns the animation group
  91896. */
  91897. reset(): AnimationGroup;
  91898. /**
  91899. * Restart animations from key 0
  91900. * @returns the animation group
  91901. */
  91902. restart(): AnimationGroup;
  91903. /**
  91904. * Stop all animations
  91905. * @returns the animation group
  91906. */
  91907. stop(): AnimationGroup;
  91908. /**
  91909. * Set animation weight for all animatables
  91910. * @param weight defines the weight to use
  91911. * @return the animationGroup
  91912. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91913. */
  91914. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91915. /**
  91916. * Synchronize and normalize all animatables with a source animatable
  91917. * @param root defines the root animatable to synchronize with
  91918. * @return the animationGroup
  91919. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91920. */
  91921. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91922. /**
  91923. * Goes to a specific frame in this animation group
  91924. * @param frame the frame number to go to
  91925. * @return the animationGroup
  91926. */
  91927. goToFrame(frame: number): AnimationGroup;
  91928. /**
  91929. * Dispose all associated resources
  91930. */
  91931. dispose(): void;
  91932. private _checkAnimationGroupEnded;
  91933. /**
  91934. * Clone the current animation group and returns a copy
  91935. * @param newName defines the name of the new group
  91936. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91937. * @returns the new aniamtion group
  91938. */
  91939. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91940. /**
  91941. * Returns a new AnimationGroup object parsed from the source provided.
  91942. * @param parsedAnimationGroup defines the source
  91943. * @param scene defines the scene that will receive the animationGroup
  91944. * @returns a new AnimationGroup
  91945. */
  91946. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91947. /**
  91948. * Returns the string "AnimationGroup"
  91949. * @returns "AnimationGroup"
  91950. */
  91951. getClassName(): string;
  91952. /**
  91953. * Creates a detailled string about the object
  91954. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91955. * @returns a string representing the object
  91956. */
  91957. toString(fullDetails?: boolean): string;
  91958. }
  91959. }
  91960. declare module BABYLON {
  91961. /**
  91962. * Define an interface for all classes that will hold resources
  91963. */
  91964. export interface IDisposable {
  91965. /**
  91966. * Releases all held resources
  91967. */
  91968. dispose(): void;
  91969. }
  91970. /** Interface defining initialization parameters for Scene class */
  91971. export interface SceneOptions {
  91972. /**
  91973. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91974. * It will improve performance when the number of geometries becomes important.
  91975. */
  91976. useGeometryUniqueIdsMap?: boolean;
  91977. /**
  91978. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91979. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91980. */
  91981. useMaterialMeshMap?: boolean;
  91982. /**
  91983. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91984. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91985. */
  91986. useClonedMeshhMap?: boolean;
  91987. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  91988. virtual?: boolean;
  91989. }
  91990. /**
  91991. * Represents a scene to be rendered by the engine.
  91992. * @see http://doc.babylonjs.com/features/scene
  91993. */
  91994. export class Scene extends AbstractScene implements IAnimatable {
  91995. private static _uniqueIdCounter;
  91996. /** The fog is deactivated */
  91997. static readonly FOGMODE_NONE: number;
  91998. /** The fog density is following an exponential function */
  91999. static readonly FOGMODE_EXP: number;
  92000. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  92001. static readonly FOGMODE_EXP2: number;
  92002. /** The fog density is following a linear function. */
  92003. static readonly FOGMODE_LINEAR: number;
  92004. /**
  92005. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  92006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92007. */
  92008. static MinDeltaTime: number;
  92009. /**
  92010. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  92011. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92012. */
  92013. static MaxDeltaTime: number;
  92014. /**
  92015. * Factory used to create the default material.
  92016. * @param name The name of the material to create
  92017. * @param scene The scene to create the material for
  92018. * @returns The default material
  92019. */
  92020. static DefaultMaterialFactory(scene: Scene): Material;
  92021. /**
  92022. * Factory used to create the a collision coordinator.
  92023. * @returns The collision coordinator
  92024. */
  92025. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  92026. /** @hidden */
  92027. _inputManager: InputManager;
  92028. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  92029. cameraToUseForPointers: Nullable<Camera>;
  92030. /** @hidden */
  92031. readonly _isScene: boolean;
  92032. /**
  92033. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  92034. */
  92035. autoClear: boolean;
  92036. /**
  92037. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  92038. */
  92039. autoClearDepthAndStencil: boolean;
  92040. /**
  92041. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  92042. */
  92043. clearColor: Color4;
  92044. /**
  92045. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  92046. */
  92047. ambientColor: Color3;
  92048. /**
  92049. * This is use to store the default BRDF lookup for PBR materials in your scene.
  92050. * It should only be one of the following (if not the default embedded one):
  92051. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  92052. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  92053. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  92054. * The material properties need to be setup according to the type of texture in use.
  92055. */
  92056. environmentBRDFTexture: BaseTexture;
  92057. /** @hidden */
  92058. protected _environmentTexture: Nullable<BaseTexture>;
  92059. /**
  92060. * Texture used in all pbr material as the reflection texture.
  92061. * As in the majority of the scene they are the same (exception for multi room and so on),
  92062. * this is easier to reference from here than from all the materials.
  92063. */
  92064. /**
  92065. * Texture used in all pbr material as the reflection texture.
  92066. * As in the majority of the scene they are the same (exception for multi room and so on),
  92067. * this is easier to set here than in all the materials.
  92068. */
  92069. environmentTexture: Nullable<BaseTexture>;
  92070. /** @hidden */
  92071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  92072. /**
  92073. * Default image processing configuration used either in the rendering
  92074. * Forward main pass or through the imageProcessingPostProcess if present.
  92075. * As in the majority of the scene they are the same (exception for multi camera),
  92076. * this is easier to reference from here than from all the materials and post process.
  92077. *
  92078. * No setter as we it is a shared configuration, you can set the values instead.
  92079. */
  92080. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  92081. private _forceWireframe;
  92082. /**
  92083. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  92084. */
  92085. forceWireframe: boolean;
  92086. private _forcePointsCloud;
  92087. /**
  92088. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  92089. */
  92090. forcePointsCloud: boolean;
  92091. /**
  92092. * Gets or sets the active clipplane 1
  92093. */
  92094. clipPlane: Nullable<Plane>;
  92095. /**
  92096. * Gets or sets the active clipplane 2
  92097. */
  92098. clipPlane2: Nullable<Plane>;
  92099. /**
  92100. * Gets or sets the active clipplane 3
  92101. */
  92102. clipPlane3: Nullable<Plane>;
  92103. /**
  92104. * Gets or sets the active clipplane 4
  92105. */
  92106. clipPlane4: Nullable<Plane>;
  92107. /**
  92108. * Gets or sets a boolean indicating if animations are enabled
  92109. */
  92110. animationsEnabled: boolean;
  92111. private _animationPropertiesOverride;
  92112. /**
  92113. * Gets or sets the animation properties override
  92114. */
  92115. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92116. /**
  92117. * Gets or sets a boolean indicating if a constant deltatime has to be used
  92118. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  92119. */
  92120. useConstantAnimationDeltaTime: boolean;
  92121. /**
  92122. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  92123. * Please note that it requires to run a ray cast through the scene on every frame
  92124. */
  92125. constantlyUpdateMeshUnderPointer: boolean;
  92126. /**
  92127. * Defines the HTML cursor to use when hovering over interactive elements
  92128. */
  92129. hoverCursor: string;
  92130. /**
  92131. * Defines the HTML default cursor to use (empty by default)
  92132. */
  92133. defaultCursor: string;
  92134. /**
  92135. * This is used to call preventDefault() on pointer down
  92136. * in order to block unwanted artifacts like system double clicks
  92137. */
  92138. preventDefaultOnPointerDown: boolean;
  92139. /**
  92140. * This is used to call preventDefault() on pointer up
  92141. * in order to block unwanted artifacts like system double clicks
  92142. */
  92143. preventDefaultOnPointerUp: boolean;
  92144. /**
  92145. * Gets or sets user defined metadata
  92146. */
  92147. metadata: any;
  92148. /**
  92149. * For internal use only. Please do not use.
  92150. */
  92151. reservedDataStore: any;
  92152. /**
  92153. * Gets the name of the plugin used to load this scene (null by default)
  92154. */
  92155. loadingPluginName: string;
  92156. /**
  92157. * Use this array to add regular expressions used to disable offline support for specific urls
  92158. */
  92159. disableOfflineSupportExceptionRules: RegExp[];
  92160. /**
  92161. * An event triggered when the scene is disposed.
  92162. */
  92163. onDisposeObservable: Observable<Scene>;
  92164. private _onDisposeObserver;
  92165. /** Sets a function to be executed when this scene is disposed. */
  92166. onDispose: () => void;
  92167. /**
  92168. * An event triggered before rendering the scene (right after animations and physics)
  92169. */
  92170. onBeforeRenderObservable: Observable<Scene>;
  92171. private _onBeforeRenderObserver;
  92172. /** Sets a function to be executed before rendering this scene */
  92173. beforeRender: Nullable<() => void>;
  92174. /**
  92175. * An event triggered after rendering the scene
  92176. */
  92177. onAfterRenderObservable: Observable<Scene>;
  92178. private _onAfterRenderObserver;
  92179. /** Sets a function to be executed after rendering this scene */
  92180. afterRender: Nullable<() => void>;
  92181. /**
  92182. * An event triggered before animating the scene
  92183. */
  92184. onBeforeAnimationsObservable: Observable<Scene>;
  92185. /**
  92186. * An event triggered after animations processing
  92187. */
  92188. onAfterAnimationsObservable: Observable<Scene>;
  92189. /**
  92190. * An event triggered before draw calls are ready to be sent
  92191. */
  92192. onBeforeDrawPhaseObservable: Observable<Scene>;
  92193. /**
  92194. * An event triggered after draw calls have been sent
  92195. */
  92196. onAfterDrawPhaseObservable: Observable<Scene>;
  92197. /**
  92198. * An event triggered when the scene is ready
  92199. */
  92200. onReadyObservable: Observable<Scene>;
  92201. /**
  92202. * An event triggered before rendering a camera
  92203. */
  92204. onBeforeCameraRenderObservable: Observable<Camera>;
  92205. private _onBeforeCameraRenderObserver;
  92206. /** Sets a function to be executed before rendering a camera*/
  92207. beforeCameraRender: () => void;
  92208. /**
  92209. * An event triggered after rendering a camera
  92210. */
  92211. onAfterCameraRenderObservable: Observable<Camera>;
  92212. private _onAfterCameraRenderObserver;
  92213. /** Sets a function to be executed after rendering a camera*/
  92214. afterCameraRender: () => void;
  92215. /**
  92216. * An event triggered when active meshes evaluation is about to start
  92217. */
  92218. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92219. /**
  92220. * An event triggered when active meshes evaluation is done
  92221. */
  92222. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92223. /**
  92224. * An event triggered when particles rendering is about to start
  92225. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92226. */
  92227. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92228. /**
  92229. * An event triggered when particles rendering is done
  92230. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92231. */
  92232. onAfterParticlesRenderingObservable: Observable<Scene>;
  92233. /**
  92234. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92235. */
  92236. onDataLoadedObservable: Observable<Scene>;
  92237. /**
  92238. * An event triggered when a camera is created
  92239. */
  92240. onNewCameraAddedObservable: Observable<Camera>;
  92241. /**
  92242. * An event triggered when a camera is removed
  92243. */
  92244. onCameraRemovedObservable: Observable<Camera>;
  92245. /**
  92246. * An event triggered when a light is created
  92247. */
  92248. onNewLightAddedObservable: Observable<Light>;
  92249. /**
  92250. * An event triggered when a light is removed
  92251. */
  92252. onLightRemovedObservable: Observable<Light>;
  92253. /**
  92254. * An event triggered when a geometry is created
  92255. */
  92256. onNewGeometryAddedObservable: Observable<Geometry>;
  92257. /**
  92258. * An event triggered when a geometry is removed
  92259. */
  92260. onGeometryRemovedObservable: Observable<Geometry>;
  92261. /**
  92262. * An event triggered when a transform node is created
  92263. */
  92264. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92265. /**
  92266. * An event triggered when a transform node is removed
  92267. */
  92268. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92269. /**
  92270. * An event triggered when a mesh is created
  92271. */
  92272. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92273. /**
  92274. * An event triggered when a mesh is removed
  92275. */
  92276. onMeshRemovedObservable: Observable<AbstractMesh>;
  92277. /**
  92278. * An event triggered when a skeleton is created
  92279. */
  92280. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92281. /**
  92282. * An event triggered when a skeleton is removed
  92283. */
  92284. onSkeletonRemovedObservable: Observable<Skeleton>;
  92285. /**
  92286. * An event triggered when a material is created
  92287. */
  92288. onNewMaterialAddedObservable: Observable<Material>;
  92289. /**
  92290. * An event triggered when a material is removed
  92291. */
  92292. onMaterialRemovedObservable: Observable<Material>;
  92293. /**
  92294. * An event triggered when a texture is created
  92295. */
  92296. onNewTextureAddedObservable: Observable<BaseTexture>;
  92297. /**
  92298. * An event triggered when a texture is removed
  92299. */
  92300. onTextureRemovedObservable: Observable<BaseTexture>;
  92301. /**
  92302. * An event triggered when render targets are about to be rendered
  92303. * Can happen multiple times per frame.
  92304. */
  92305. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92306. /**
  92307. * An event triggered when render targets were rendered.
  92308. * Can happen multiple times per frame.
  92309. */
  92310. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92311. /**
  92312. * An event triggered before calculating deterministic simulation step
  92313. */
  92314. onBeforeStepObservable: Observable<Scene>;
  92315. /**
  92316. * An event triggered after calculating deterministic simulation step
  92317. */
  92318. onAfterStepObservable: Observable<Scene>;
  92319. /**
  92320. * An event triggered when the activeCamera property is updated
  92321. */
  92322. onActiveCameraChanged: Observable<Scene>;
  92323. /**
  92324. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92325. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92326. * 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)
  92327. */
  92328. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92329. /**
  92330. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92331. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92332. * 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)
  92333. */
  92334. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92335. /**
  92336. * This Observable will when a mesh has been imported into the scene.
  92337. */
  92338. onMeshImportedObservable: Observable<AbstractMesh>;
  92339. /**
  92340. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92341. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92342. */
  92343. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92344. /** @hidden */
  92345. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92346. /**
  92347. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92348. */
  92349. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92350. /**
  92351. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92352. */
  92353. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92354. /**
  92355. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92356. */
  92357. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92358. /** Callback called when a pointer move is detected */
  92359. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92360. /** Callback called when a pointer down is detected */
  92361. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92362. /** Callback called when a pointer up is detected */
  92363. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92364. /** Callback called when a pointer pick is detected */
  92365. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92366. /**
  92367. * 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).
  92368. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92369. */
  92370. onPrePointerObservable: Observable<PointerInfoPre>;
  92371. /**
  92372. * Observable event triggered each time an input event is received from the rendering canvas
  92373. */
  92374. onPointerObservable: Observable<PointerInfo>;
  92375. /**
  92376. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92377. */
  92378. readonly unTranslatedPointer: Vector2;
  92379. /**
  92380. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92381. */
  92382. static DragMovementThreshold: number;
  92383. /**
  92384. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92385. */
  92386. static LongPressDelay: number;
  92387. /**
  92388. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92389. */
  92390. static DoubleClickDelay: number;
  92391. /** If you need to check double click without raising a single click at first click, enable this flag */
  92392. static ExclusiveDoubleClickMode: boolean;
  92393. /** @hidden */
  92394. _mirroredCameraPosition: Nullable<Vector3>;
  92395. /**
  92396. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92397. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92398. */
  92399. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92400. /**
  92401. * Observable event triggered each time an keyboard event is received from the hosting window
  92402. */
  92403. onKeyboardObservable: Observable<KeyboardInfo>;
  92404. private _useRightHandedSystem;
  92405. /**
  92406. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92407. */
  92408. useRightHandedSystem: boolean;
  92409. private _timeAccumulator;
  92410. private _currentStepId;
  92411. private _currentInternalStep;
  92412. /**
  92413. * Sets the step Id used by deterministic lock step
  92414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92415. * @param newStepId defines the step Id
  92416. */
  92417. setStepId(newStepId: number): void;
  92418. /**
  92419. * Gets the step Id used by deterministic lock step
  92420. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92421. * @returns the step Id
  92422. */
  92423. getStepId(): number;
  92424. /**
  92425. * Gets the internal step used by deterministic lock step
  92426. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92427. * @returns the internal step
  92428. */
  92429. getInternalStep(): number;
  92430. private _fogEnabled;
  92431. /**
  92432. * Gets or sets a boolean indicating if fog is enabled on this scene
  92433. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92434. * (Default is true)
  92435. */
  92436. fogEnabled: boolean;
  92437. private _fogMode;
  92438. /**
  92439. * Gets or sets the fog mode to use
  92440. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92441. * | mode | value |
  92442. * | --- | --- |
  92443. * | FOGMODE_NONE | 0 |
  92444. * | FOGMODE_EXP | 1 |
  92445. * | FOGMODE_EXP2 | 2 |
  92446. * | FOGMODE_LINEAR | 3 |
  92447. */
  92448. fogMode: number;
  92449. /**
  92450. * Gets or sets the fog color to use
  92451. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92452. * (Default is Color3(0.2, 0.2, 0.3))
  92453. */
  92454. fogColor: Color3;
  92455. /**
  92456. * Gets or sets the fog density to use
  92457. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92458. * (Default is 0.1)
  92459. */
  92460. fogDensity: number;
  92461. /**
  92462. * Gets or sets the fog start distance to use
  92463. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92464. * (Default is 0)
  92465. */
  92466. fogStart: number;
  92467. /**
  92468. * Gets or sets the fog end distance to use
  92469. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92470. * (Default is 1000)
  92471. */
  92472. fogEnd: number;
  92473. private _shadowsEnabled;
  92474. /**
  92475. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92476. */
  92477. shadowsEnabled: boolean;
  92478. private _lightsEnabled;
  92479. /**
  92480. * Gets or sets a boolean indicating if lights are enabled on this scene
  92481. */
  92482. lightsEnabled: boolean;
  92483. /** All of the active cameras added to this scene. */
  92484. activeCameras: Camera[];
  92485. /** @hidden */
  92486. _activeCamera: Nullable<Camera>;
  92487. /** Gets or sets the current active camera */
  92488. activeCamera: Nullable<Camera>;
  92489. private _defaultMaterial;
  92490. /** The default material used on meshes when no material is affected */
  92491. /** The default material used on meshes when no material is affected */
  92492. defaultMaterial: Material;
  92493. private _texturesEnabled;
  92494. /**
  92495. * Gets or sets a boolean indicating if textures are enabled on this scene
  92496. */
  92497. texturesEnabled: boolean;
  92498. /**
  92499. * Gets or sets a boolean indicating if particles are enabled on this scene
  92500. */
  92501. particlesEnabled: boolean;
  92502. /**
  92503. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92504. */
  92505. spritesEnabled: boolean;
  92506. private _skeletonsEnabled;
  92507. /**
  92508. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92509. */
  92510. skeletonsEnabled: boolean;
  92511. /**
  92512. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92513. */
  92514. lensFlaresEnabled: boolean;
  92515. /**
  92516. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92517. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92518. */
  92519. collisionsEnabled: boolean;
  92520. private _collisionCoordinator;
  92521. /** @hidden */
  92522. readonly collisionCoordinator: ICollisionCoordinator;
  92523. /**
  92524. * Defines the gravity applied to this scene (used only for collisions)
  92525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92526. */
  92527. gravity: Vector3;
  92528. /**
  92529. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92530. */
  92531. postProcessesEnabled: boolean;
  92532. /**
  92533. * The list of postprocesses added to the scene
  92534. */
  92535. postProcesses: PostProcess[];
  92536. /**
  92537. * Gets the current postprocess manager
  92538. */
  92539. postProcessManager: PostProcessManager;
  92540. /**
  92541. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92542. */
  92543. renderTargetsEnabled: boolean;
  92544. /**
  92545. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92546. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92547. */
  92548. dumpNextRenderTargets: boolean;
  92549. /**
  92550. * The list of user defined render targets added to the scene
  92551. */
  92552. customRenderTargets: RenderTargetTexture[];
  92553. /**
  92554. * Defines if texture loading must be delayed
  92555. * If true, textures will only be loaded when they need to be rendered
  92556. */
  92557. useDelayedTextureLoading: boolean;
  92558. /**
  92559. * Gets the list of meshes imported to the scene through SceneLoader
  92560. */
  92561. importedMeshesFiles: String[];
  92562. /**
  92563. * Gets or sets a boolean indicating if probes are enabled on this scene
  92564. */
  92565. probesEnabled: boolean;
  92566. /**
  92567. * Gets or sets the current offline provider to use to store scene data
  92568. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92569. */
  92570. offlineProvider: IOfflineProvider;
  92571. /**
  92572. * Gets or sets the action manager associated with the scene
  92573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92574. */
  92575. actionManager: AbstractActionManager;
  92576. private _meshesForIntersections;
  92577. /**
  92578. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92579. */
  92580. proceduralTexturesEnabled: boolean;
  92581. private _engine;
  92582. private _totalVertices;
  92583. /** @hidden */
  92584. _activeIndices: PerfCounter;
  92585. /** @hidden */
  92586. _activeParticles: PerfCounter;
  92587. /** @hidden */
  92588. _activeBones: PerfCounter;
  92589. private _animationRatio;
  92590. /** @hidden */
  92591. _animationTimeLast: number;
  92592. /** @hidden */
  92593. _animationTime: number;
  92594. /**
  92595. * Gets or sets a general scale for animation speed
  92596. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92597. */
  92598. animationTimeScale: number;
  92599. /** @hidden */
  92600. _cachedMaterial: Nullable<Material>;
  92601. /** @hidden */
  92602. _cachedEffect: Nullable<Effect>;
  92603. /** @hidden */
  92604. _cachedVisibility: Nullable<number>;
  92605. private _renderId;
  92606. private _frameId;
  92607. private _executeWhenReadyTimeoutId;
  92608. private _intermediateRendering;
  92609. private _viewUpdateFlag;
  92610. private _projectionUpdateFlag;
  92611. /** @hidden */
  92612. _toBeDisposed: Nullable<IDisposable>[];
  92613. private _activeRequests;
  92614. /** @hidden */
  92615. _pendingData: any[];
  92616. private _isDisposed;
  92617. /**
  92618. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92619. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92620. */
  92621. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92622. private _activeMeshes;
  92623. private _processedMaterials;
  92624. private _renderTargets;
  92625. /** @hidden */
  92626. _activeParticleSystems: SmartArray<IParticleSystem>;
  92627. private _activeSkeletons;
  92628. private _softwareSkinnedMeshes;
  92629. private _renderingManager;
  92630. /** @hidden */
  92631. _activeAnimatables: Animatable[];
  92632. private _transformMatrix;
  92633. private _sceneUbo;
  92634. /** @hidden */
  92635. _viewMatrix: Matrix;
  92636. private _projectionMatrix;
  92637. /** @hidden */
  92638. _forcedViewPosition: Nullable<Vector3>;
  92639. /** @hidden */
  92640. _frustumPlanes: Plane[];
  92641. /**
  92642. * Gets the list of frustum planes (built from the active camera)
  92643. */
  92644. readonly frustumPlanes: Plane[];
  92645. /**
  92646. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92647. * This is useful if there are more lights that the maximum simulteanous authorized
  92648. */
  92649. requireLightSorting: boolean;
  92650. /** @hidden */
  92651. readonly useMaterialMeshMap: boolean;
  92652. /** @hidden */
  92653. readonly useClonedMeshhMap: boolean;
  92654. private _externalData;
  92655. private _uid;
  92656. /**
  92657. * @hidden
  92658. * Backing store of defined scene components.
  92659. */
  92660. _components: ISceneComponent[];
  92661. /**
  92662. * @hidden
  92663. * Backing store of defined scene components.
  92664. */
  92665. _serializableComponents: ISceneSerializableComponent[];
  92666. /**
  92667. * List of components to register on the next registration step.
  92668. */
  92669. private _transientComponents;
  92670. /**
  92671. * Registers the transient components if needed.
  92672. */
  92673. private _registerTransientComponents;
  92674. /**
  92675. * @hidden
  92676. * Add a component to the scene.
  92677. * Note that the ccomponent could be registered on th next frame if this is called after
  92678. * the register component stage.
  92679. * @param component Defines the component to add to the scene
  92680. */
  92681. _addComponent(component: ISceneComponent): void;
  92682. /**
  92683. * @hidden
  92684. * Gets a component from the scene.
  92685. * @param name defines the name of the component to retrieve
  92686. * @returns the component or null if not present
  92687. */
  92688. _getComponent(name: string): Nullable<ISceneComponent>;
  92689. /**
  92690. * @hidden
  92691. * Defines the actions happening before camera updates.
  92692. */
  92693. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92694. /**
  92695. * @hidden
  92696. * Defines the actions happening before clear the canvas.
  92697. */
  92698. _beforeClearStage: Stage<SimpleStageAction>;
  92699. /**
  92700. * @hidden
  92701. * Defines the actions when collecting render targets for the frame.
  92702. */
  92703. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92704. /**
  92705. * @hidden
  92706. * Defines the actions happening for one camera in the frame.
  92707. */
  92708. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92709. /**
  92710. * @hidden
  92711. * Defines the actions happening during the per mesh ready checks.
  92712. */
  92713. _isReadyForMeshStage: Stage<MeshStageAction>;
  92714. /**
  92715. * @hidden
  92716. * Defines the actions happening before evaluate active mesh checks.
  92717. */
  92718. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92719. /**
  92720. * @hidden
  92721. * Defines the actions happening during the evaluate sub mesh checks.
  92722. */
  92723. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92724. /**
  92725. * @hidden
  92726. * Defines the actions happening during the active mesh stage.
  92727. */
  92728. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92729. /**
  92730. * @hidden
  92731. * Defines the actions happening during the per camera render target step.
  92732. */
  92733. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92734. /**
  92735. * @hidden
  92736. * Defines the actions happening just before the active camera is drawing.
  92737. */
  92738. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92739. /**
  92740. * @hidden
  92741. * Defines the actions happening just before a render target is drawing.
  92742. */
  92743. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92744. /**
  92745. * @hidden
  92746. * Defines the actions happening just before a rendering group is drawing.
  92747. */
  92748. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92749. /**
  92750. * @hidden
  92751. * Defines the actions happening just before a mesh is drawing.
  92752. */
  92753. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92754. /**
  92755. * @hidden
  92756. * Defines the actions happening just after a mesh has been drawn.
  92757. */
  92758. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92759. /**
  92760. * @hidden
  92761. * Defines the actions happening just after a rendering group has been drawn.
  92762. */
  92763. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92764. /**
  92765. * @hidden
  92766. * Defines the actions happening just after the active camera has been drawn.
  92767. */
  92768. _afterCameraDrawStage: Stage<CameraStageAction>;
  92769. /**
  92770. * @hidden
  92771. * Defines the actions happening just after a render target has been drawn.
  92772. */
  92773. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92774. /**
  92775. * @hidden
  92776. * Defines the actions happening just after rendering all cameras and computing intersections.
  92777. */
  92778. _afterRenderStage: Stage<SimpleStageAction>;
  92779. /**
  92780. * @hidden
  92781. * Defines the actions happening when a pointer move event happens.
  92782. */
  92783. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92784. /**
  92785. * @hidden
  92786. * Defines the actions happening when a pointer down event happens.
  92787. */
  92788. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92789. /**
  92790. * @hidden
  92791. * Defines the actions happening when a pointer up event happens.
  92792. */
  92793. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92794. /**
  92795. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92796. */
  92797. private geometriesByUniqueId;
  92798. /**
  92799. * Creates a new Scene
  92800. * @param engine defines the engine to use to render this scene
  92801. * @param options defines the scene options
  92802. */
  92803. constructor(engine: Engine, options?: SceneOptions);
  92804. /**
  92805. * Gets a string idenfifying the name of the class
  92806. * @returns "Scene" string
  92807. */
  92808. getClassName(): string;
  92809. private _defaultMeshCandidates;
  92810. /**
  92811. * @hidden
  92812. */
  92813. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92814. private _defaultSubMeshCandidates;
  92815. /**
  92816. * @hidden
  92817. */
  92818. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92819. /**
  92820. * Sets the default candidate providers for the scene.
  92821. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92822. * and getCollidingSubMeshCandidates to their default function
  92823. */
  92824. setDefaultCandidateProviders(): void;
  92825. /**
  92826. * Gets the mesh that is currently under the pointer
  92827. */
  92828. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92829. /**
  92830. * Gets or sets the current on-screen X position of the pointer
  92831. */
  92832. pointerX: number;
  92833. /**
  92834. * Gets or sets the current on-screen Y position of the pointer
  92835. */
  92836. pointerY: number;
  92837. /**
  92838. * Gets the cached material (ie. the latest rendered one)
  92839. * @returns the cached material
  92840. */
  92841. getCachedMaterial(): Nullable<Material>;
  92842. /**
  92843. * Gets the cached effect (ie. the latest rendered one)
  92844. * @returns the cached effect
  92845. */
  92846. getCachedEffect(): Nullable<Effect>;
  92847. /**
  92848. * Gets the cached visibility state (ie. the latest rendered one)
  92849. * @returns the cached visibility state
  92850. */
  92851. getCachedVisibility(): Nullable<number>;
  92852. /**
  92853. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92854. * @param material defines the current material
  92855. * @param effect defines the current effect
  92856. * @param visibility defines the current visibility state
  92857. * @returns true if one parameter is not cached
  92858. */
  92859. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92860. /**
  92861. * Gets the engine associated with the scene
  92862. * @returns an Engine
  92863. */
  92864. getEngine(): Engine;
  92865. /**
  92866. * Gets the total number of vertices rendered per frame
  92867. * @returns the total number of vertices rendered per frame
  92868. */
  92869. getTotalVertices(): number;
  92870. /**
  92871. * Gets the performance counter for total vertices
  92872. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92873. */
  92874. readonly totalVerticesPerfCounter: PerfCounter;
  92875. /**
  92876. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92877. * @returns the total number of active indices rendered per frame
  92878. */
  92879. getActiveIndices(): number;
  92880. /**
  92881. * Gets the performance counter for active indices
  92882. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92883. */
  92884. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92885. /**
  92886. * Gets the total number of active particles rendered per frame
  92887. * @returns the total number of active particles rendered per frame
  92888. */
  92889. getActiveParticles(): number;
  92890. /**
  92891. * Gets the performance counter for active particles
  92892. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92893. */
  92894. readonly activeParticlesPerfCounter: PerfCounter;
  92895. /**
  92896. * Gets the total number of active bones rendered per frame
  92897. * @returns the total number of active bones rendered per frame
  92898. */
  92899. getActiveBones(): number;
  92900. /**
  92901. * Gets the performance counter for active bones
  92902. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92903. */
  92904. readonly activeBonesPerfCounter: PerfCounter;
  92905. /**
  92906. * Gets the array of active meshes
  92907. * @returns an array of AbstractMesh
  92908. */
  92909. getActiveMeshes(): SmartArray<AbstractMesh>;
  92910. /**
  92911. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92912. * @returns a number
  92913. */
  92914. getAnimationRatio(): number;
  92915. /**
  92916. * Gets an unique Id for the current render phase
  92917. * @returns a number
  92918. */
  92919. getRenderId(): number;
  92920. /**
  92921. * Gets an unique Id for the current frame
  92922. * @returns a number
  92923. */
  92924. getFrameId(): number;
  92925. /** Call this function if you want to manually increment the render Id*/
  92926. incrementRenderId(): void;
  92927. private _createUbo;
  92928. /**
  92929. * Use this method to simulate a pointer move on a mesh
  92930. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92931. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92932. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92933. * @returns the current scene
  92934. */
  92935. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92936. /**
  92937. * Use this method to simulate a pointer down on a mesh
  92938. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92939. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92940. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92941. * @returns the current scene
  92942. */
  92943. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92944. /**
  92945. * Use this method to simulate a pointer up on a mesh
  92946. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92947. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92948. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92949. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92950. * @returns the current scene
  92951. */
  92952. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92953. /**
  92954. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92955. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92956. * @returns true if the pointer was captured
  92957. */
  92958. isPointerCaptured(pointerId?: number): boolean;
  92959. /**
  92960. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92961. * @param attachUp defines if you want to attach events to pointerup
  92962. * @param attachDown defines if you want to attach events to pointerdown
  92963. * @param attachMove defines if you want to attach events to pointermove
  92964. */
  92965. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92966. /** Detaches all event handlers*/
  92967. detachControl(): void;
  92968. /**
  92969. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92970. * Delay loaded resources are not taking in account
  92971. * @return true if all required resources are ready
  92972. */
  92973. isReady(): boolean;
  92974. /** Resets all cached information relative to material (including effect and visibility) */
  92975. resetCachedMaterial(): void;
  92976. /**
  92977. * Registers a function to be called before every frame render
  92978. * @param func defines the function to register
  92979. */
  92980. registerBeforeRender(func: () => void): void;
  92981. /**
  92982. * Unregisters a function called before every frame render
  92983. * @param func defines the function to unregister
  92984. */
  92985. unregisterBeforeRender(func: () => void): void;
  92986. /**
  92987. * Registers a function to be called after every frame render
  92988. * @param func defines the function to register
  92989. */
  92990. registerAfterRender(func: () => void): void;
  92991. /**
  92992. * Unregisters a function called after every frame render
  92993. * @param func defines the function to unregister
  92994. */
  92995. unregisterAfterRender(func: () => void): void;
  92996. private _executeOnceBeforeRender;
  92997. /**
  92998. * The provided function will run before render once and will be disposed afterwards.
  92999. * A timeout delay can be provided so that the function will be executed in N ms.
  93000. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  93001. * @param func The function to be executed.
  93002. * @param timeout optional delay in ms
  93003. */
  93004. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  93005. /** @hidden */
  93006. _addPendingData(data: any): void;
  93007. /** @hidden */
  93008. _removePendingData(data: any): void;
  93009. /**
  93010. * Returns the number of items waiting to be loaded
  93011. * @returns the number of items waiting to be loaded
  93012. */
  93013. getWaitingItemsCount(): number;
  93014. /**
  93015. * Returns a boolean indicating if the scene is still loading data
  93016. */
  93017. readonly isLoading: boolean;
  93018. /**
  93019. * Registers a function to be executed when the scene is ready
  93020. * @param {Function} func - the function to be executed
  93021. */
  93022. executeWhenReady(func: () => void): void;
  93023. /**
  93024. * Returns a promise that resolves when the scene is ready
  93025. * @returns A promise that resolves when the scene is ready
  93026. */
  93027. whenReadyAsync(): Promise<void>;
  93028. /** @hidden */
  93029. _checkIsReady(): void;
  93030. /**
  93031. * Gets all animatable attached to the scene
  93032. */
  93033. readonly animatables: Animatable[];
  93034. /**
  93035. * Resets the last animation time frame.
  93036. * Useful to override when animations start running when loading a scene for the first time.
  93037. */
  93038. resetLastAnimationTimeFrame(): void;
  93039. /**
  93040. * Gets the current view matrix
  93041. * @returns a Matrix
  93042. */
  93043. getViewMatrix(): Matrix;
  93044. /**
  93045. * Gets the current projection matrix
  93046. * @returns a Matrix
  93047. */
  93048. getProjectionMatrix(): Matrix;
  93049. /**
  93050. * Gets the current transform matrix
  93051. * @returns a Matrix made of View * Projection
  93052. */
  93053. getTransformMatrix(): Matrix;
  93054. /**
  93055. * Sets the current transform matrix
  93056. * @param viewL defines the View matrix to use
  93057. * @param projectionL defines the Projection matrix to use
  93058. * @param viewR defines the right View matrix to use (if provided)
  93059. * @param projectionR defines the right Projection matrix to use (if provided)
  93060. */
  93061. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  93062. /**
  93063. * Gets the uniform buffer used to store scene data
  93064. * @returns a UniformBuffer
  93065. */
  93066. getSceneUniformBuffer(): UniformBuffer;
  93067. /**
  93068. * Gets an unique (relatively to the current scene) Id
  93069. * @returns an unique number for the scene
  93070. */
  93071. getUniqueId(): number;
  93072. /**
  93073. * Add a mesh to the list of scene's meshes
  93074. * @param newMesh defines the mesh to add
  93075. * @param recursive if all child meshes should also be added to the scene
  93076. */
  93077. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  93078. /**
  93079. * Remove a mesh for the list of scene's meshes
  93080. * @param toRemove defines the mesh to remove
  93081. * @param recursive if all child meshes should also be removed from the scene
  93082. * @returns the index where the mesh was in the mesh list
  93083. */
  93084. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  93085. /**
  93086. * Add a transform node to the list of scene's transform nodes
  93087. * @param newTransformNode defines the transform node to add
  93088. */
  93089. addTransformNode(newTransformNode: TransformNode): void;
  93090. /**
  93091. * Remove a transform node for the list of scene's transform nodes
  93092. * @param toRemove defines the transform node to remove
  93093. * @returns the index where the transform node was in the transform node list
  93094. */
  93095. removeTransformNode(toRemove: TransformNode): number;
  93096. /**
  93097. * Remove a skeleton for the list of scene's skeletons
  93098. * @param toRemove defines the skeleton to remove
  93099. * @returns the index where the skeleton was in the skeleton list
  93100. */
  93101. removeSkeleton(toRemove: Skeleton): number;
  93102. /**
  93103. * Remove a morph target for the list of scene's morph targets
  93104. * @param toRemove defines the morph target to remove
  93105. * @returns the index where the morph target was in the morph target list
  93106. */
  93107. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  93108. /**
  93109. * Remove a light for the list of scene's lights
  93110. * @param toRemove defines the light to remove
  93111. * @returns the index where the light was in the light list
  93112. */
  93113. removeLight(toRemove: Light): number;
  93114. /**
  93115. * Remove a camera for the list of scene's cameras
  93116. * @param toRemove defines the camera to remove
  93117. * @returns the index where the camera was in the camera list
  93118. */
  93119. removeCamera(toRemove: Camera): number;
  93120. /**
  93121. * Remove a particle system for the list of scene's particle systems
  93122. * @param toRemove defines the particle system to remove
  93123. * @returns the index where the particle system was in the particle system list
  93124. */
  93125. removeParticleSystem(toRemove: IParticleSystem): number;
  93126. /**
  93127. * Remove a animation for the list of scene's animations
  93128. * @param toRemove defines the animation to remove
  93129. * @returns the index where the animation was in the animation list
  93130. */
  93131. removeAnimation(toRemove: Animation): number;
  93132. /**
  93133. * Will stop the animation of the given target
  93134. * @param target - the target
  93135. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  93136. * @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)
  93137. */
  93138. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  93139. /**
  93140. * Removes the given animation group from this scene.
  93141. * @param toRemove The animation group to remove
  93142. * @returns The index of the removed animation group
  93143. */
  93144. removeAnimationGroup(toRemove: AnimationGroup): number;
  93145. /**
  93146. * Removes the given multi-material from this scene.
  93147. * @param toRemove The multi-material to remove
  93148. * @returns The index of the removed multi-material
  93149. */
  93150. removeMultiMaterial(toRemove: MultiMaterial): number;
  93151. /**
  93152. * Removes the given material from this scene.
  93153. * @param toRemove The material to remove
  93154. * @returns The index of the removed material
  93155. */
  93156. removeMaterial(toRemove: Material): number;
  93157. /**
  93158. * Removes the given action manager from this scene.
  93159. * @param toRemove The action manager to remove
  93160. * @returns The index of the removed action manager
  93161. */
  93162. removeActionManager(toRemove: AbstractActionManager): number;
  93163. /**
  93164. * Removes the given texture from this scene.
  93165. * @param toRemove The texture to remove
  93166. * @returns The index of the removed texture
  93167. */
  93168. removeTexture(toRemove: BaseTexture): number;
  93169. /**
  93170. * Adds the given light to this scene
  93171. * @param newLight The light to add
  93172. */
  93173. addLight(newLight: Light): void;
  93174. /**
  93175. * Sorts the list list based on light priorities
  93176. */
  93177. sortLightsByPriority(): void;
  93178. /**
  93179. * Adds the given camera to this scene
  93180. * @param newCamera The camera to add
  93181. */
  93182. addCamera(newCamera: Camera): void;
  93183. /**
  93184. * Adds the given skeleton to this scene
  93185. * @param newSkeleton The skeleton to add
  93186. */
  93187. addSkeleton(newSkeleton: Skeleton): void;
  93188. /**
  93189. * Adds the given particle system to this scene
  93190. * @param newParticleSystem The particle system to add
  93191. */
  93192. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93193. /**
  93194. * Adds the given animation to this scene
  93195. * @param newAnimation The animation to add
  93196. */
  93197. addAnimation(newAnimation: Animation): void;
  93198. /**
  93199. * Adds the given animation group to this scene.
  93200. * @param newAnimationGroup The animation group to add
  93201. */
  93202. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93203. /**
  93204. * Adds the given multi-material to this scene
  93205. * @param newMultiMaterial The multi-material to add
  93206. */
  93207. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93208. /**
  93209. * Adds the given material to this scene
  93210. * @param newMaterial The material to add
  93211. */
  93212. addMaterial(newMaterial: Material): void;
  93213. /**
  93214. * Adds the given morph target to this scene
  93215. * @param newMorphTargetManager The morph target to add
  93216. */
  93217. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93218. /**
  93219. * Adds the given geometry to this scene
  93220. * @param newGeometry The geometry to add
  93221. */
  93222. addGeometry(newGeometry: Geometry): void;
  93223. /**
  93224. * Adds the given action manager to this scene
  93225. * @param newActionManager The action manager to add
  93226. */
  93227. addActionManager(newActionManager: AbstractActionManager): void;
  93228. /**
  93229. * Adds the given texture to this scene.
  93230. * @param newTexture The texture to add
  93231. */
  93232. addTexture(newTexture: BaseTexture): void;
  93233. /**
  93234. * Switch active camera
  93235. * @param newCamera defines the new active camera
  93236. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93237. */
  93238. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93239. /**
  93240. * sets the active camera of the scene using its ID
  93241. * @param id defines the camera's ID
  93242. * @return the new active camera or null if none found.
  93243. */
  93244. setActiveCameraByID(id: string): Nullable<Camera>;
  93245. /**
  93246. * sets the active camera of the scene using its name
  93247. * @param name defines the camera's name
  93248. * @returns the new active camera or null if none found.
  93249. */
  93250. setActiveCameraByName(name: string): Nullable<Camera>;
  93251. /**
  93252. * get an animation group using its name
  93253. * @param name defines the material's name
  93254. * @return the animation group or null if none found.
  93255. */
  93256. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93257. /**
  93258. * Get a material using its unique id
  93259. * @param uniqueId defines the material's unique id
  93260. * @return the material or null if none found.
  93261. */
  93262. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93263. /**
  93264. * get a material using its id
  93265. * @param id defines the material's ID
  93266. * @return the material or null if none found.
  93267. */
  93268. getMaterialByID(id: string): Nullable<Material>;
  93269. /**
  93270. * Gets a material using its name
  93271. * @param name defines the material's name
  93272. * @return the material or null if none found.
  93273. */
  93274. getMaterialByName(name: string): Nullable<Material>;
  93275. /**
  93276. * Gets a camera using its id
  93277. * @param id defines the id to look for
  93278. * @returns the camera or null if not found
  93279. */
  93280. getCameraByID(id: string): Nullable<Camera>;
  93281. /**
  93282. * Gets a camera using its unique id
  93283. * @param uniqueId defines the unique id to look for
  93284. * @returns the camera or null if not found
  93285. */
  93286. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93287. /**
  93288. * Gets a camera using its name
  93289. * @param name defines the camera's name
  93290. * @return the camera or null if none found.
  93291. */
  93292. getCameraByName(name: string): Nullable<Camera>;
  93293. /**
  93294. * Gets a bone using its id
  93295. * @param id defines the bone's id
  93296. * @return the bone or null if not found
  93297. */
  93298. getBoneByID(id: string): Nullable<Bone>;
  93299. /**
  93300. * Gets a bone using its id
  93301. * @param name defines the bone's name
  93302. * @return the bone or null if not found
  93303. */
  93304. getBoneByName(name: string): Nullable<Bone>;
  93305. /**
  93306. * Gets a light node using its name
  93307. * @param name defines the the light's name
  93308. * @return the light or null if none found.
  93309. */
  93310. getLightByName(name: string): Nullable<Light>;
  93311. /**
  93312. * Gets a light node using its id
  93313. * @param id defines the light's id
  93314. * @return the light or null if none found.
  93315. */
  93316. getLightByID(id: string): Nullable<Light>;
  93317. /**
  93318. * Gets a light node using its scene-generated unique ID
  93319. * @param uniqueId defines the light's unique id
  93320. * @return the light or null if none found.
  93321. */
  93322. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93323. /**
  93324. * Gets a particle system by id
  93325. * @param id defines the particle system id
  93326. * @return the corresponding system or null if none found
  93327. */
  93328. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93329. /**
  93330. * Gets a geometry using its ID
  93331. * @param id defines the geometry's id
  93332. * @return the geometry or null if none found.
  93333. */
  93334. getGeometryByID(id: string): Nullable<Geometry>;
  93335. private _getGeometryByUniqueID;
  93336. /**
  93337. * Add a new geometry to this scene
  93338. * @param geometry defines the geometry to be added to the scene.
  93339. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93340. * @return a boolean defining if the geometry was added or not
  93341. */
  93342. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93343. /**
  93344. * Removes an existing geometry
  93345. * @param geometry defines the geometry to be removed from the scene
  93346. * @return a boolean defining if the geometry was removed or not
  93347. */
  93348. removeGeometry(geometry: Geometry): boolean;
  93349. /**
  93350. * Gets the list of geometries attached to the scene
  93351. * @returns an array of Geometry
  93352. */
  93353. getGeometries(): Geometry[];
  93354. /**
  93355. * Gets the first added mesh found of a given ID
  93356. * @param id defines the id to search for
  93357. * @return the mesh found or null if not found at all
  93358. */
  93359. getMeshByID(id: string): Nullable<AbstractMesh>;
  93360. /**
  93361. * Gets a list of meshes using their id
  93362. * @param id defines the id to search for
  93363. * @returns a list of meshes
  93364. */
  93365. getMeshesByID(id: string): Array<AbstractMesh>;
  93366. /**
  93367. * Gets the first added transform node found of a given ID
  93368. * @param id defines the id to search for
  93369. * @return the found transform node or null if not found at all.
  93370. */
  93371. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93372. /**
  93373. * Gets a transform node with its auto-generated unique id
  93374. * @param uniqueId efines the unique id to search for
  93375. * @return the found transform node or null if not found at all.
  93376. */
  93377. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93378. /**
  93379. * Gets a list of transform nodes using their id
  93380. * @param id defines the id to search for
  93381. * @returns a list of transform nodes
  93382. */
  93383. getTransformNodesByID(id: string): Array<TransformNode>;
  93384. /**
  93385. * Gets a mesh with its auto-generated unique id
  93386. * @param uniqueId defines the unique id to search for
  93387. * @return the found mesh or null if not found at all.
  93388. */
  93389. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93390. /**
  93391. * Gets a the last added mesh using a given id
  93392. * @param id defines the id to search for
  93393. * @return the found mesh or null if not found at all.
  93394. */
  93395. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93396. /**
  93397. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93398. * @param id defines the id to search for
  93399. * @return the found node or null if not found at all
  93400. */
  93401. getLastEntryByID(id: string): Nullable<Node>;
  93402. /**
  93403. * Gets a node (Mesh, Camera, Light) using a given id
  93404. * @param id defines the id to search for
  93405. * @return the found node or null if not found at all
  93406. */
  93407. getNodeByID(id: string): Nullable<Node>;
  93408. /**
  93409. * Gets a node (Mesh, Camera, Light) using a given name
  93410. * @param name defines the name to search for
  93411. * @return the found node or null if not found at all.
  93412. */
  93413. getNodeByName(name: string): Nullable<Node>;
  93414. /**
  93415. * Gets a mesh using a given name
  93416. * @param name defines the name to search for
  93417. * @return the found mesh or null if not found at all.
  93418. */
  93419. getMeshByName(name: string): Nullable<AbstractMesh>;
  93420. /**
  93421. * Gets a transform node using a given name
  93422. * @param name defines the name to search for
  93423. * @return the found transform node or null if not found at all.
  93424. */
  93425. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93426. /**
  93427. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93428. * @param id defines the id to search for
  93429. * @return the found skeleton or null if not found at all.
  93430. */
  93431. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93432. /**
  93433. * Gets a skeleton using a given auto generated unique id
  93434. * @param uniqueId defines the unique id to search for
  93435. * @return the found skeleton or null if not found at all.
  93436. */
  93437. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93438. /**
  93439. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93440. * @param id defines the id to search for
  93441. * @return the found skeleton or null if not found at all.
  93442. */
  93443. getSkeletonById(id: string): Nullable<Skeleton>;
  93444. /**
  93445. * Gets a skeleton using a given name
  93446. * @param name defines the name to search for
  93447. * @return the found skeleton or null if not found at all.
  93448. */
  93449. getSkeletonByName(name: string): Nullable<Skeleton>;
  93450. /**
  93451. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93452. * @param id defines the id to search for
  93453. * @return the found morph target manager or null if not found at all.
  93454. */
  93455. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93456. /**
  93457. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93458. * @param id defines the id to search for
  93459. * @return the found morph target or null if not found at all.
  93460. */
  93461. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93462. /**
  93463. * Gets a boolean indicating if the given mesh is active
  93464. * @param mesh defines the mesh to look for
  93465. * @returns true if the mesh is in the active list
  93466. */
  93467. isActiveMesh(mesh: AbstractMesh): boolean;
  93468. /**
  93469. * Return a unique id as a string which can serve as an identifier for the scene
  93470. */
  93471. readonly uid: string;
  93472. /**
  93473. * Add an externaly attached data from its key.
  93474. * This method call will fail and return false, if such key already exists.
  93475. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93476. * @param key the unique key that identifies the data
  93477. * @param data the data object to associate to the key for this Engine instance
  93478. * @return true if no such key were already present and the data was added successfully, false otherwise
  93479. */
  93480. addExternalData<T>(key: string, data: T): boolean;
  93481. /**
  93482. * Get an externaly attached data from its key
  93483. * @param key the unique key that identifies the data
  93484. * @return the associated data, if present (can be null), or undefined if not present
  93485. */
  93486. getExternalData<T>(key: string): Nullable<T>;
  93487. /**
  93488. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93489. * @param key the unique key that identifies the data
  93490. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93491. * @return the associated data, can be null if the factory returned null.
  93492. */
  93493. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93494. /**
  93495. * Remove an externaly attached data from the Engine instance
  93496. * @param key the unique key that identifies the data
  93497. * @return true if the data was successfully removed, false if it doesn't exist
  93498. */
  93499. removeExternalData(key: string): boolean;
  93500. private _evaluateSubMesh;
  93501. /**
  93502. * Clear the processed materials smart array preventing retention point in material dispose.
  93503. */
  93504. freeProcessedMaterials(): void;
  93505. private _preventFreeActiveMeshesAndRenderingGroups;
  93506. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93507. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93508. * when disposing several meshes in a row or a hierarchy of meshes.
  93509. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93510. */
  93511. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93512. /**
  93513. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93514. */
  93515. freeActiveMeshes(): void;
  93516. /**
  93517. * Clear the info related to rendering groups preventing retention points during dispose.
  93518. */
  93519. freeRenderingGroups(): void;
  93520. /** @hidden */
  93521. _isInIntermediateRendering(): boolean;
  93522. /**
  93523. * Lambda returning the list of potentially active meshes.
  93524. */
  93525. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93526. /**
  93527. * Lambda returning the list of potentially active sub meshes.
  93528. */
  93529. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93530. /**
  93531. * Lambda returning the list of potentially intersecting sub meshes.
  93532. */
  93533. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93534. /**
  93535. * Lambda returning the list of potentially colliding sub meshes.
  93536. */
  93537. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93538. private _activeMeshesFrozen;
  93539. /**
  93540. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93541. * @returns the current scene
  93542. */
  93543. freezeActiveMeshes(): Scene;
  93544. /**
  93545. * Use this function to restart evaluating active meshes on every frame
  93546. * @returns the current scene
  93547. */
  93548. unfreezeActiveMeshes(): Scene;
  93549. private _evaluateActiveMeshes;
  93550. private _activeMesh;
  93551. /**
  93552. * Update the transform matrix to update from the current active camera
  93553. * @param force defines a boolean used to force the update even if cache is up to date
  93554. */
  93555. updateTransformMatrix(force?: boolean): void;
  93556. private _bindFrameBuffer;
  93557. /** @hidden */
  93558. _allowPostProcessClearColor: boolean;
  93559. /** @hidden */
  93560. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93561. private _processSubCameras;
  93562. private _checkIntersections;
  93563. /** @hidden */
  93564. _advancePhysicsEngineStep(step: number): void;
  93565. /**
  93566. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93567. */
  93568. getDeterministicFrameTime: () => number;
  93569. /** @hidden */
  93570. _animate(): void;
  93571. /** Execute all animations (for a frame) */
  93572. animate(): void;
  93573. /**
  93574. * Render the scene
  93575. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93576. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93577. */
  93578. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93579. /**
  93580. * Freeze all materials
  93581. * A frozen material will not be updatable but should be faster to render
  93582. */
  93583. freezeMaterials(): void;
  93584. /**
  93585. * Unfreeze all materials
  93586. * A frozen material will not be updatable but should be faster to render
  93587. */
  93588. unfreezeMaterials(): void;
  93589. /**
  93590. * Releases all held ressources
  93591. */
  93592. dispose(): void;
  93593. /**
  93594. * Gets if the scene is already disposed
  93595. */
  93596. readonly isDisposed: boolean;
  93597. /**
  93598. * Call this function to reduce memory footprint of the scene.
  93599. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93600. */
  93601. clearCachedVertexData(): void;
  93602. /**
  93603. * This function will remove the local cached buffer data from texture.
  93604. * It will save memory but will prevent the texture from being rebuilt
  93605. */
  93606. cleanCachedTextureBuffer(): void;
  93607. /**
  93608. * Get the world extend vectors with an optional filter
  93609. *
  93610. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93611. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93612. */
  93613. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93614. min: Vector3;
  93615. max: Vector3;
  93616. };
  93617. /**
  93618. * Creates a ray that can be used to pick in the scene
  93619. * @param x defines the x coordinate of the origin (on-screen)
  93620. * @param y defines the y coordinate of the origin (on-screen)
  93621. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93622. * @param camera defines the camera to use for the picking
  93623. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93624. * @returns a Ray
  93625. */
  93626. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93627. /**
  93628. * Creates a ray that can be used to pick in the scene
  93629. * @param x defines the x coordinate of the origin (on-screen)
  93630. * @param y defines the y coordinate of the origin (on-screen)
  93631. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93632. * @param result defines the ray where to store the picking ray
  93633. * @param camera defines the camera to use for the picking
  93634. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93635. * @returns the current scene
  93636. */
  93637. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93638. /**
  93639. * Creates a ray that can be used to pick in the scene
  93640. * @param x defines the x coordinate of the origin (on-screen)
  93641. * @param y defines the y coordinate of the origin (on-screen)
  93642. * @param camera defines the camera to use for the picking
  93643. * @returns a Ray
  93644. */
  93645. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93646. /**
  93647. * Creates a ray that can be used to pick in the scene
  93648. * @param x defines the x coordinate of the origin (on-screen)
  93649. * @param y defines the y coordinate of the origin (on-screen)
  93650. * @param result defines the ray where to store the picking ray
  93651. * @param camera defines the camera to use for the picking
  93652. * @returns the current scene
  93653. */
  93654. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93655. /** Launch a ray to try to pick a mesh in the scene
  93656. * @param x position on screen
  93657. * @param y position on screen
  93658. * @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
  93659. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93660. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93661. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93662. * @returns a PickingInfo
  93663. */
  93664. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93665. /** Use the given ray to pick a mesh in the scene
  93666. * @param ray The ray to use to pick meshes
  93667. * @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
  93668. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93669. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93670. * @returns a PickingInfo
  93671. */
  93672. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93673. /**
  93674. * Launch a ray to try to pick a mesh in the scene
  93675. * @param x X position on screen
  93676. * @param y Y position on screen
  93677. * @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
  93678. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93679. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93680. * @returns an array of PickingInfo
  93681. */
  93682. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93683. /**
  93684. * Launch a ray to try to pick a mesh in the scene
  93685. * @param ray Ray to use
  93686. * @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
  93687. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93688. * @returns an array of PickingInfo
  93689. */
  93690. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93691. /**
  93692. * Force the value of meshUnderPointer
  93693. * @param mesh defines the mesh to use
  93694. */
  93695. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93696. /**
  93697. * Gets the mesh under the pointer
  93698. * @returns a Mesh or null if no mesh is under the pointer
  93699. */
  93700. getPointerOverMesh(): Nullable<AbstractMesh>;
  93701. /** @hidden */
  93702. _rebuildGeometries(): void;
  93703. /** @hidden */
  93704. _rebuildTextures(): void;
  93705. private _getByTags;
  93706. /**
  93707. * Get a list of meshes by tags
  93708. * @param tagsQuery defines the tags query to use
  93709. * @param forEach defines a predicate used to filter results
  93710. * @returns an array of Mesh
  93711. */
  93712. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93713. /**
  93714. * Get a list of cameras by tags
  93715. * @param tagsQuery defines the tags query to use
  93716. * @param forEach defines a predicate used to filter results
  93717. * @returns an array of Camera
  93718. */
  93719. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93720. /**
  93721. * Get a list of lights by tags
  93722. * @param tagsQuery defines the tags query to use
  93723. * @param forEach defines a predicate used to filter results
  93724. * @returns an array of Light
  93725. */
  93726. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93727. /**
  93728. * Get a list of materials by tags
  93729. * @param tagsQuery defines the tags query to use
  93730. * @param forEach defines a predicate used to filter results
  93731. * @returns an array of Material
  93732. */
  93733. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93734. /**
  93735. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93736. * This allowed control for front to back rendering or reversly depending of the special needs.
  93737. *
  93738. * @param renderingGroupId The rendering group id corresponding to its index
  93739. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93740. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93741. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93742. */
  93743. 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;
  93744. /**
  93745. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93746. *
  93747. * @param renderingGroupId The rendering group id corresponding to its index
  93748. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93749. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93750. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93751. */
  93752. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93753. /**
  93754. * Gets the current auto clear configuration for one rendering group of the rendering
  93755. * manager.
  93756. * @param index the rendering group index to get the information for
  93757. * @returns The auto clear setup for the requested rendering group
  93758. */
  93759. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93760. private _blockMaterialDirtyMechanism;
  93761. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93762. blockMaterialDirtyMechanism: boolean;
  93763. /**
  93764. * Will flag all materials as dirty to trigger new shader compilation
  93765. * @param flag defines the flag used to specify which material part must be marked as dirty
  93766. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93767. */
  93768. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93769. /** @hidden */
  93770. _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;
  93771. /** @hidden */
  93772. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93773. }
  93774. }
  93775. declare module BABYLON {
  93776. /**
  93777. * Set of assets to keep when moving a scene into an asset container.
  93778. */
  93779. export class KeepAssets extends AbstractScene {
  93780. }
  93781. /**
  93782. * Container with a set of assets that can be added or removed from a scene.
  93783. */
  93784. export class AssetContainer extends AbstractScene {
  93785. /**
  93786. * The scene the AssetContainer belongs to.
  93787. */
  93788. scene: Scene;
  93789. /**
  93790. * Instantiates an AssetContainer.
  93791. * @param scene The scene the AssetContainer belongs to.
  93792. */
  93793. constructor(scene: Scene);
  93794. /**
  93795. * Adds all the assets from the container to the scene.
  93796. */
  93797. addAllToScene(): void;
  93798. /**
  93799. * Removes all the assets in the container from the scene
  93800. */
  93801. removeAllFromScene(): void;
  93802. /**
  93803. * Disposes all the assets in the container
  93804. */
  93805. dispose(): void;
  93806. private _moveAssets;
  93807. /**
  93808. * Removes all the assets contained in the scene and adds them to the container.
  93809. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93810. */
  93811. moveAllFromScene(keepAssets?: KeepAssets): void;
  93812. /**
  93813. * 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.
  93814. * @returns the root mesh
  93815. */
  93816. createRootMesh(): Mesh;
  93817. }
  93818. }
  93819. declare module BABYLON {
  93820. /**
  93821. * Defines how the parser contract is defined.
  93822. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93823. */
  93824. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93825. /**
  93826. * Defines how the individual parser contract is defined.
  93827. * These parser can parse an individual asset
  93828. */
  93829. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93830. /**
  93831. * Base class of the scene acting as a container for the different elements composing a scene.
  93832. * This class is dynamically extended by the different components of the scene increasing
  93833. * flexibility and reducing coupling
  93834. */
  93835. export abstract class AbstractScene {
  93836. /**
  93837. * Stores the list of available parsers in the application.
  93838. */
  93839. private static _BabylonFileParsers;
  93840. /**
  93841. * Stores the list of available individual parsers in the application.
  93842. */
  93843. private static _IndividualBabylonFileParsers;
  93844. /**
  93845. * Adds a parser in the list of available ones
  93846. * @param name Defines the name of the parser
  93847. * @param parser Defines the parser to add
  93848. */
  93849. static AddParser(name: string, parser: BabylonFileParser): void;
  93850. /**
  93851. * Gets a general parser from the list of avaialble ones
  93852. * @param name Defines the name of the parser
  93853. * @returns the requested parser or null
  93854. */
  93855. static GetParser(name: string): Nullable<BabylonFileParser>;
  93856. /**
  93857. * Adds n individual parser in the list of available ones
  93858. * @param name Defines the name of the parser
  93859. * @param parser Defines the parser to add
  93860. */
  93861. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93862. /**
  93863. * Gets an individual parser from the list of avaialble ones
  93864. * @param name Defines the name of the parser
  93865. * @returns the requested parser or null
  93866. */
  93867. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93868. /**
  93869. * Parser json data and populate both a scene and its associated container object
  93870. * @param jsonData Defines the data to parse
  93871. * @param scene Defines the scene to parse the data for
  93872. * @param container Defines the container attached to the parsing sequence
  93873. * @param rootUrl Defines the root url of the data
  93874. */
  93875. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93876. /**
  93877. * Gets the list of root nodes (ie. nodes with no parent)
  93878. */
  93879. rootNodes: Node[];
  93880. /** All of the cameras added to this scene
  93881. * @see http://doc.babylonjs.com/babylon101/cameras
  93882. */
  93883. cameras: Camera[];
  93884. /**
  93885. * All of the lights added to this scene
  93886. * @see http://doc.babylonjs.com/babylon101/lights
  93887. */
  93888. lights: Light[];
  93889. /**
  93890. * All of the (abstract) meshes added to this scene
  93891. */
  93892. meshes: AbstractMesh[];
  93893. /**
  93894. * The list of skeletons added to the scene
  93895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93896. */
  93897. skeletons: Skeleton[];
  93898. /**
  93899. * All of the particle systems added to this scene
  93900. * @see http://doc.babylonjs.com/babylon101/particles
  93901. */
  93902. particleSystems: IParticleSystem[];
  93903. /**
  93904. * Gets a list of Animations associated with the scene
  93905. */
  93906. animations: Animation[];
  93907. /**
  93908. * All of the animation groups added to this scene
  93909. * @see http://doc.babylonjs.com/how_to/group
  93910. */
  93911. animationGroups: AnimationGroup[];
  93912. /**
  93913. * All of the multi-materials added to this scene
  93914. * @see http://doc.babylonjs.com/how_to/multi_materials
  93915. */
  93916. multiMaterials: MultiMaterial[];
  93917. /**
  93918. * All of the materials added to this scene
  93919. * In the context of a Scene, it is not supposed to be modified manually.
  93920. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93921. * Note also that the order of the Material wihin the array is not significant and might change.
  93922. * @see http://doc.babylonjs.com/babylon101/materials
  93923. */
  93924. materials: Material[];
  93925. /**
  93926. * The list of morph target managers added to the scene
  93927. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93928. */
  93929. morphTargetManagers: MorphTargetManager[];
  93930. /**
  93931. * The list of geometries used in the scene.
  93932. */
  93933. geometries: Geometry[];
  93934. /**
  93935. * All of the tranform nodes added to this scene
  93936. * In the context of a Scene, it is not supposed to be modified manually.
  93937. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93938. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93939. * @see http://doc.babylonjs.com/how_to/transformnode
  93940. */
  93941. transformNodes: TransformNode[];
  93942. /**
  93943. * ActionManagers available on the scene.
  93944. */
  93945. actionManagers: AbstractActionManager[];
  93946. /**
  93947. * Textures to keep.
  93948. */
  93949. textures: BaseTexture[];
  93950. /**
  93951. * Environment texture for the scene
  93952. */
  93953. environmentTexture: Nullable<BaseTexture>;
  93954. }
  93955. }
  93956. declare module BABYLON {
  93957. /**
  93958. * Defines a sound that can be played in the application.
  93959. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93961. */
  93962. export class Sound {
  93963. /**
  93964. * The name of the sound in the scene.
  93965. */
  93966. name: string;
  93967. /**
  93968. * Does the sound autoplay once loaded.
  93969. */
  93970. autoplay: boolean;
  93971. /**
  93972. * Does the sound loop after it finishes playing once.
  93973. */
  93974. loop: boolean;
  93975. /**
  93976. * Does the sound use a custom attenuation curve to simulate the falloff
  93977. * happening when the source gets further away from the camera.
  93978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93979. */
  93980. useCustomAttenuation: boolean;
  93981. /**
  93982. * The sound track id this sound belongs to.
  93983. */
  93984. soundTrackId: number;
  93985. /**
  93986. * Is this sound currently played.
  93987. */
  93988. isPlaying: boolean;
  93989. /**
  93990. * Is this sound currently paused.
  93991. */
  93992. isPaused: boolean;
  93993. /**
  93994. * Does this sound enables spatial sound.
  93995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93996. */
  93997. spatialSound: boolean;
  93998. /**
  93999. * Define the reference distance the sound should be heard perfectly.
  94000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94001. */
  94002. refDistance: number;
  94003. /**
  94004. * Define the roll off factor of spatial sounds.
  94005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94006. */
  94007. rolloffFactor: number;
  94008. /**
  94009. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  94010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94011. */
  94012. maxDistance: number;
  94013. /**
  94014. * Define the distance attenuation model the sound will follow.
  94015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94016. */
  94017. distanceModel: string;
  94018. /**
  94019. * @hidden
  94020. * Back Compat
  94021. **/
  94022. onended: () => any;
  94023. /**
  94024. * Observable event when the current playing sound finishes.
  94025. */
  94026. onEndedObservable: Observable<Sound>;
  94027. private _panningModel;
  94028. private _playbackRate;
  94029. private _streaming;
  94030. private _startTime;
  94031. private _startOffset;
  94032. private _position;
  94033. /** @hidden */
  94034. _positionInEmitterSpace: boolean;
  94035. private _localDirection;
  94036. private _volume;
  94037. private _isReadyToPlay;
  94038. private _isDirectional;
  94039. private _readyToPlayCallback;
  94040. private _audioBuffer;
  94041. private _soundSource;
  94042. private _streamingSource;
  94043. private _soundPanner;
  94044. private _soundGain;
  94045. private _inputAudioNode;
  94046. private _outputAudioNode;
  94047. private _coneInnerAngle;
  94048. private _coneOuterAngle;
  94049. private _coneOuterGain;
  94050. private _scene;
  94051. private _connectedTransformNode;
  94052. private _customAttenuationFunction;
  94053. private _registerFunc;
  94054. private _isOutputConnected;
  94055. private _htmlAudioElement;
  94056. private _urlType;
  94057. /** @hidden */
  94058. static _SceneComponentInitialization: (scene: Scene) => void;
  94059. /**
  94060. * Create a sound and attach it to a scene
  94061. * @param name Name of your sound
  94062. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  94063. * @param scene defines the scene the sound belongs to
  94064. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  94065. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  94066. */
  94067. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  94068. /**
  94069. * Release the sound and its associated resources
  94070. */
  94071. dispose(): void;
  94072. /**
  94073. * Gets if the sounds is ready to be played or not.
  94074. * @returns true if ready, otherwise false
  94075. */
  94076. isReady(): boolean;
  94077. private _soundLoaded;
  94078. /**
  94079. * Sets the data of the sound from an audiobuffer
  94080. * @param audioBuffer The audioBuffer containing the data
  94081. */
  94082. setAudioBuffer(audioBuffer: AudioBuffer): void;
  94083. /**
  94084. * Updates the current sounds options such as maxdistance, loop...
  94085. * @param options A JSON object containing values named as the object properties
  94086. */
  94087. updateOptions(options: any): void;
  94088. private _createSpatialParameters;
  94089. private _updateSpatialParameters;
  94090. /**
  94091. * Switch the panning model to HRTF:
  94092. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94094. */
  94095. switchPanningModelToHRTF(): void;
  94096. /**
  94097. * Switch the panning model to Equal Power:
  94098. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94100. */
  94101. switchPanningModelToEqualPower(): void;
  94102. private _switchPanningModel;
  94103. /**
  94104. * Connect this sound to a sound track audio node like gain...
  94105. * @param soundTrackAudioNode the sound track audio node to connect to
  94106. */
  94107. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  94108. /**
  94109. * Transform this sound into a directional source
  94110. * @param coneInnerAngle Size of the inner cone in degree
  94111. * @param coneOuterAngle Size of the outer cone in degree
  94112. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  94113. */
  94114. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  94115. /**
  94116. * Gets or sets the inner angle for the directional cone.
  94117. */
  94118. /**
  94119. * Gets or sets the inner angle for the directional cone.
  94120. */
  94121. directionalConeInnerAngle: number;
  94122. /**
  94123. * Gets or sets the outer angle for the directional cone.
  94124. */
  94125. /**
  94126. * Gets or sets the outer angle for the directional cone.
  94127. */
  94128. directionalConeOuterAngle: number;
  94129. /**
  94130. * Sets the position of the emitter if spatial sound is enabled
  94131. * @param newPosition Defines the new posisiton
  94132. */
  94133. setPosition(newPosition: Vector3): void;
  94134. /**
  94135. * Sets the local direction of the emitter if spatial sound is enabled
  94136. * @param newLocalDirection Defines the new local direction
  94137. */
  94138. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  94139. private _updateDirection;
  94140. /** @hidden */
  94141. updateDistanceFromListener(): void;
  94142. /**
  94143. * Sets a new custom attenuation function for the sound.
  94144. * @param callback Defines the function used for the attenuation
  94145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  94146. */
  94147. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  94148. /**
  94149. * Play the sound
  94150. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  94151. * @param offset (optional) Start the sound setting it at a specific time
  94152. */
  94153. play(time?: number, offset?: number): void;
  94154. private _onended;
  94155. /**
  94156. * Stop the sound
  94157. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  94158. */
  94159. stop(time?: number): void;
  94160. /**
  94161. * Put the sound in pause
  94162. */
  94163. pause(): void;
  94164. /**
  94165. * Sets a dedicated volume for this sounds
  94166. * @param newVolume Define the new volume of the sound
  94167. * @param time Define in how long the sound should be at this value
  94168. */
  94169. setVolume(newVolume: number, time?: number): void;
  94170. /**
  94171. * Set the sound play back rate
  94172. * @param newPlaybackRate Define the playback rate the sound should be played at
  94173. */
  94174. setPlaybackRate(newPlaybackRate: number): void;
  94175. /**
  94176. * Gets the volume of the sound.
  94177. * @returns the volume of the sound
  94178. */
  94179. getVolume(): number;
  94180. /**
  94181. * Attach the sound to a dedicated mesh
  94182. * @param transformNode The transform node to connect the sound with
  94183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94184. */
  94185. attachToMesh(transformNode: TransformNode): void;
  94186. /**
  94187. * Detach the sound from the previously attached mesh
  94188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94189. */
  94190. detachFromMesh(): void;
  94191. private _onRegisterAfterWorldMatrixUpdate;
  94192. /**
  94193. * Clone the current sound in the scene.
  94194. * @returns the new sound clone
  94195. */
  94196. clone(): Nullable<Sound>;
  94197. /**
  94198. * Gets the current underlying audio buffer containing the data
  94199. * @returns the audio buffer
  94200. */
  94201. getAudioBuffer(): Nullable<AudioBuffer>;
  94202. /**
  94203. * Serializes the Sound in a JSON representation
  94204. * @returns the JSON representation of the sound
  94205. */
  94206. serialize(): any;
  94207. /**
  94208. * Parse a JSON representation of a sound to innstantiate in a given scene
  94209. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94210. * @param scene Define the scene the new parsed sound should be created in
  94211. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94212. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94213. * @returns the newly parsed sound
  94214. */
  94215. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94216. }
  94217. }
  94218. declare module BABYLON {
  94219. /**
  94220. * This defines an action helpful to play a defined sound on a triggered action.
  94221. */
  94222. export class PlaySoundAction extends Action {
  94223. private _sound;
  94224. /**
  94225. * Instantiate the action
  94226. * @param triggerOptions defines the trigger options
  94227. * @param sound defines the sound to play
  94228. * @param condition defines the trigger related conditions
  94229. */
  94230. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94231. /** @hidden */
  94232. _prepare(): void;
  94233. /**
  94234. * Execute the action and play the sound.
  94235. */
  94236. execute(): void;
  94237. /**
  94238. * Serializes the actions and its related information.
  94239. * @param parent defines the object to serialize in
  94240. * @returns the serialized object
  94241. */
  94242. serialize(parent: any): any;
  94243. }
  94244. /**
  94245. * This defines an action helpful to stop a defined sound on a triggered action.
  94246. */
  94247. export class StopSoundAction extends Action {
  94248. private _sound;
  94249. /**
  94250. * Instantiate the action
  94251. * @param triggerOptions defines the trigger options
  94252. * @param sound defines the sound to stop
  94253. * @param condition defines the trigger related conditions
  94254. */
  94255. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94256. /** @hidden */
  94257. _prepare(): void;
  94258. /**
  94259. * Execute the action and stop the sound.
  94260. */
  94261. execute(): void;
  94262. /**
  94263. * Serializes the actions and its related information.
  94264. * @param parent defines the object to serialize in
  94265. * @returns the serialized object
  94266. */
  94267. serialize(parent: any): any;
  94268. }
  94269. }
  94270. declare module BABYLON {
  94271. /**
  94272. * This defines an action responsible to change the value of a property
  94273. * by interpolating between its current value and the newly set one once triggered.
  94274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94275. */
  94276. export class InterpolateValueAction extends Action {
  94277. /**
  94278. * Defines the path of the property where the value should be interpolated
  94279. */
  94280. propertyPath: string;
  94281. /**
  94282. * Defines the target value at the end of the interpolation.
  94283. */
  94284. value: any;
  94285. /**
  94286. * Defines the time it will take for the property to interpolate to the value.
  94287. */
  94288. duration: number;
  94289. /**
  94290. * Defines if the other scene animations should be stopped when the action has been triggered
  94291. */
  94292. stopOtherAnimations?: boolean;
  94293. /**
  94294. * Defines a callback raised once the interpolation animation has been done.
  94295. */
  94296. onInterpolationDone?: () => void;
  94297. /**
  94298. * Observable triggered once the interpolation animation has been done.
  94299. */
  94300. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94301. private _target;
  94302. private _effectiveTarget;
  94303. private _property;
  94304. /**
  94305. * Instantiate the action
  94306. * @param triggerOptions defines the trigger options
  94307. * @param target defines the object containing the value to interpolate
  94308. * @param propertyPath defines the path to the property in the target object
  94309. * @param value defines the target value at the end of the interpolation
  94310. * @param duration deines the time it will take for the property to interpolate to the value.
  94311. * @param condition defines the trigger related conditions
  94312. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94313. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94314. */
  94315. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94316. /** @hidden */
  94317. _prepare(): void;
  94318. /**
  94319. * Execute the action starts the value interpolation.
  94320. */
  94321. execute(): void;
  94322. /**
  94323. * Serializes the actions and its related information.
  94324. * @param parent defines the object to serialize in
  94325. * @returns the serialized object
  94326. */
  94327. serialize(parent: any): any;
  94328. }
  94329. }
  94330. declare module BABYLON {
  94331. /**
  94332. * Options allowed during the creation of a sound track.
  94333. */
  94334. export interface ISoundTrackOptions {
  94335. /**
  94336. * The volume the sound track should take during creation
  94337. */
  94338. volume?: number;
  94339. /**
  94340. * Define if the sound track is the main sound track of the scene
  94341. */
  94342. mainTrack?: boolean;
  94343. }
  94344. /**
  94345. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94346. * It will be also used in a future release to apply effects on a specific track.
  94347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94348. */
  94349. export class SoundTrack {
  94350. /**
  94351. * The unique identifier of the sound track in the scene.
  94352. */
  94353. id: number;
  94354. /**
  94355. * The list of sounds included in the sound track.
  94356. */
  94357. soundCollection: Array<Sound>;
  94358. private _outputAudioNode;
  94359. private _scene;
  94360. private _isMainTrack;
  94361. private _connectedAnalyser;
  94362. private _options;
  94363. private _isInitialized;
  94364. /**
  94365. * Creates a new sound track.
  94366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94367. * @param scene Define the scene the sound track belongs to
  94368. * @param options
  94369. */
  94370. constructor(scene: Scene, options?: ISoundTrackOptions);
  94371. private _initializeSoundTrackAudioGraph;
  94372. /**
  94373. * Release the sound track and its associated resources
  94374. */
  94375. dispose(): void;
  94376. /**
  94377. * Adds a sound to this sound track
  94378. * @param sound define the cound to add
  94379. * @ignoreNaming
  94380. */
  94381. AddSound(sound: Sound): void;
  94382. /**
  94383. * Removes a sound to this sound track
  94384. * @param sound define the cound to remove
  94385. * @ignoreNaming
  94386. */
  94387. RemoveSound(sound: Sound): void;
  94388. /**
  94389. * Set a global volume for the full sound track.
  94390. * @param newVolume Define the new volume of the sound track
  94391. */
  94392. setVolume(newVolume: number): void;
  94393. /**
  94394. * Switch the panning model to HRTF:
  94395. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94396. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94397. */
  94398. switchPanningModelToHRTF(): void;
  94399. /**
  94400. * Switch the panning model to Equal Power:
  94401. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94403. */
  94404. switchPanningModelToEqualPower(): void;
  94405. /**
  94406. * Connect the sound track to an audio analyser allowing some amazing
  94407. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94409. * @param analyser The analyser to connect to the engine
  94410. */
  94411. connectToAnalyser(analyser: Analyser): void;
  94412. }
  94413. }
  94414. declare module BABYLON {
  94415. interface AbstractScene {
  94416. /**
  94417. * The list of sounds used in the scene.
  94418. */
  94419. sounds: Nullable<Array<Sound>>;
  94420. }
  94421. interface Scene {
  94422. /**
  94423. * @hidden
  94424. * Backing field
  94425. */
  94426. _mainSoundTrack: SoundTrack;
  94427. /**
  94428. * The main sound track played by the scene.
  94429. * It cotains your primary collection of sounds.
  94430. */
  94431. mainSoundTrack: SoundTrack;
  94432. /**
  94433. * The list of sound tracks added to the scene
  94434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94435. */
  94436. soundTracks: Nullable<Array<SoundTrack>>;
  94437. /**
  94438. * Gets a sound using a given name
  94439. * @param name defines the name to search for
  94440. * @return the found sound or null if not found at all.
  94441. */
  94442. getSoundByName(name: string): Nullable<Sound>;
  94443. /**
  94444. * Gets or sets if audio support is enabled
  94445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94446. */
  94447. audioEnabled: boolean;
  94448. /**
  94449. * Gets or sets if audio will be output to headphones
  94450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94451. */
  94452. headphone: boolean;
  94453. }
  94454. /**
  94455. * Defines the sound scene component responsible to manage any sounds
  94456. * in a given scene.
  94457. */
  94458. export class AudioSceneComponent implements ISceneSerializableComponent {
  94459. /**
  94460. * The component name helpfull to identify the component in the list of scene components.
  94461. */
  94462. readonly name: string;
  94463. /**
  94464. * The scene the component belongs to.
  94465. */
  94466. scene: Scene;
  94467. private _audioEnabled;
  94468. /**
  94469. * Gets whether audio is enabled or not.
  94470. * Please use related enable/disable method to switch state.
  94471. */
  94472. readonly audioEnabled: boolean;
  94473. private _headphone;
  94474. /**
  94475. * Gets whether audio is outputing to headphone or not.
  94476. * Please use the according Switch methods to change output.
  94477. */
  94478. readonly headphone: boolean;
  94479. /**
  94480. * Creates a new instance of the component for the given scene
  94481. * @param scene Defines the scene to register the component in
  94482. */
  94483. constructor(scene: Scene);
  94484. /**
  94485. * Registers the component in a given scene
  94486. */
  94487. register(): void;
  94488. /**
  94489. * Rebuilds the elements related to this component in case of
  94490. * context lost for instance.
  94491. */
  94492. rebuild(): void;
  94493. /**
  94494. * Serializes the component data to the specified json object
  94495. * @param serializationObject The object to serialize to
  94496. */
  94497. serialize(serializationObject: any): void;
  94498. /**
  94499. * Adds all the element from the container to the scene
  94500. * @param container the container holding the elements
  94501. */
  94502. addFromContainer(container: AbstractScene): void;
  94503. /**
  94504. * Removes all the elements in the container from the scene
  94505. * @param container contains the elements to remove
  94506. * @param dispose if the removed element should be disposed (default: false)
  94507. */
  94508. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94509. /**
  94510. * Disposes the component and the associated ressources.
  94511. */
  94512. dispose(): void;
  94513. /**
  94514. * Disables audio in the associated scene.
  94515. */
  94516. disableAudio(): void;
  94517. /**
  94518. * Enables audio in the associated scene.
  94519. */
  94520. enableAudio(): void;
  94521. /**
  94522. * Switch audio to headphone output.
  94523. */
  94524. switchAudioModeForHeadphones(): void;
  94525. /**
  94526. * Switch audio to normal speakers.
  94527. */
  94528. switchAudioModeForNormalSpeakers(): void;
  94529. private _afterRender;
  94530. }
  94531. }
  94532. declare module BABYLON {
  94533. /**
  94534. * Wraps one or more Sound objects and selects one with random weight for playback.
  94535. */
  94536. export class WeightedSound {
  94537. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94538. loop: boolean;
  94539. private _coneInnerAngle;
  94540. private _coneOuterAngle;
  94541. private _volume;
  94542. /** A Sound is currently playing. */
  94543. isPlaying: boolean;
  94544. /** A Sound is currently paused. */
  94545. isPaused: boolean;
  94546. private _sounds;
  94547. private _weights;
  94548. private _currentIndex?;
  94549. /**
  94550. * Creates a new WeightedSound from the list of sounds given.
  94551. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94552. * @param sounds Array of Sounds that will be selected from.
  94553. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94554. */
  94555. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94556. /**
  94557. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94558. */
  94559. /**
  94560. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94561. */
  94562. directionalConeInnerAngle: number;
  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. /**
  94568. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94569. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94570. */
  94571. directionalConeOuterAngle: number;
  94572. /**
  94573. * Playback volume.
  94574. */
  94575. /**
  94576. * Playback volume.
  94577. */
  94578. volume: number;
  94579. private _onended;
  94580. /**
  94581. * Suspend playback
  94582. */
  94583. pause(): void;
  94584. /**
  94585. * Stop playback
  94586. */
  94587. stop(): void;
  94588. /**
  94589. * Start playback.
  94590. * @param startOffset Position the clip head at a specific time in seconds.
  94591. */
  94592. play(startOffset?: number): void;
  94593. }
  94594. }
  94595. declare module BABYLON {
  94596. /**
  94597. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94598. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94599. */
  94600. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94601. /**
  94602. * Gets the name of the behavior.
  94603. */
  94604. readonly name: string;
  94605. /**
  94606. * The easing function used by animations
  94607. */
  94608. static EasingFunction: BackEase;
  94609. /**
  94610. * The easing mode used by animations
  94611. */
  94612. static EasingMode: number;
  94613. /**
  94614. * The duration of the animation, in milliseconds
  94615. */
  94616. transitionDuration: number;
  94617. /**
  94618. * Length of the distance animated by the transition when lower radius is reached
  94619. */
  94620. lowerRadiusTransitionRange: number;
  94621. /**
  94622. * Length of the distance animated by the transition when upper radius is reached
  94623. */
  94624. upperRadiusTransitionRange: number;
  94625. private _autoTransitionRange;
  94626. /**
  94627. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94628. */
  94629. /**
  94630. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94631. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94632. */
  94633. autoTransitionRange: boolean;
  94634. private _attachedCamera;
  94635. private _onAfterCheckInputsObserver;
  94636. private _onMeshTargetChangedObserver;
  94637. /**
  94638. * Initializes the behavior.
  94639. */
  94640. init(): void;
  94641. /**
  94642. * Attaches the behavior to its arc rotate camera.
  94643. * @param camera Defines the camera to attach the behavior to
  94644. */
  94645. attach(camera: ArcRotateCamera): void;
  94646. /**
  94647. * Detaches the behavior from its current arc rotate camera.
  94648. */
  94649. detach(): void;
  94650. private _radiusIsAnimating;
  94651. private _radiusBounceTransition;
  94652. private _animatables;
  94653. private _cachedWheelPrecision;
  94654. /**
  94655. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94656. * @param radiusLimit The limit to check against.
  94657. * @return Bool to indicate if at limit.
  94658. */
  94659. private _isRadiusAtLimit;
  94660. /**
  94661. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94662. * @param radiusDelta The delta by which to animate to. Can be negative.
  94663. */
  94664. private _applyBoundRadiusAnimation;
  94665. /**
  94666. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94667. */
  94668. protected _clearAnimationLocks(): void;
  94669. /**
  94670. * Stops and removes all animations that have been applied to the camera
  94671. */
  94672. stopAllAnimations(): void;
  94673. }
  94674. }
  94675. declare module BABYLON {
  94676. /**
  94677. * 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.
  94678. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94679. */
  94680. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94681. /**
  94682. * Gets the name of the behavior.
  94683. */
  94684. readonly name: string;
  94685. private _mode;
  94686. private _radiusScale;
  94687. private _positionScale;
  94688. private _defaultElevation;
  94689. private _elevationReturnTime;
  94690. private _elevationReturnWaitTime;
  94691. private _zoomStopsAnimation;
  94692. private _framingTime;
  94693. /**
  94694. * The easing function used by animations
  94695. */
  94696. static EasingFunction: ExponentialEase;
  94697. /**
  94698. * The easing mode used by animations
  94699. */
  94700. static EasingMode: number;
  94701. /**
  94702. * Sets the current mode used by the behavior
  94703. */
  94704. /**
  94705. * Gets current mode used by the behavior.
  94706. */
  94707. mode: number;
  94708. /**
  94709. * Sets the scale applied to the radius (1 by default)
  94710. */
  94711. /**
  94712. * Gets the scale applied to the radius
  94713. */
  94714. radiusScale: number;
  94715. /**
  94716. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94717. */
  94718. /**
  94719. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94720. */
  94721. positionScale: number;
  94722. /**
  94723. * Sets 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. /**
  94727. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94728. * behaviour is triggered, in radians.
  94729. */
  94730. defaultElevation: number;
  94731. /**
  94732. * Sets the time (in milliseconds) taken to return to the default beta position.
  94733. * Negative value indicates camera should not return to default.
  94734. */
  94735. /**
  94736. * Gets the time (in milliseconds) taken to return to the default beta position.
  94737. * Negative value indicates camera should not return to default.
  94738. */
  94739. elevationReturnTime: number;
  94740. /**
  94741. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94742. */
  94743. /**
  94744. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94745. */
  94746. elevationReturnWaitTime: number;
  94747. /**
  94748. * Sets the flag that indicates if user zooming should stop animation.
  94749. */
  94750. /**
  94751. * Gets the flag that indicates if user zooming should stop animation.
  94752. */
  94753. zoomStopsAnimation: boolean;
  94754. /**
  94755. * Sets the transition time when framing the mesh, in milliseconds
  94756. */
  94757. /**
  94758. * Gets the transition time when framing the mesh, in milliseconds
  94759. */
  94760. framingTime: number;
  94761. /**
  94762. * Define if the behavior should automatically change the configured
  94763. * camera limits and sensibilities.
  94764. */
  94765. autoCorrectCameraLimitsAndSensibility: boolean;
  94766. private _onPrePointerObservableObserver;
  94767. private _onAfterCheckInputsObserver;
  94768. private _onMeshTargetChangedObserver;
  94769. private _attachedCamera;
  94770. private _isPointerDown;
  94771. private _lastInteractionTime;
  94772. /**
  94773. * Initializes the behavior.
  94774. */
  94775. init(): void;
  94776. /**
  94777. * Attaches the behavior to its arc rotate camera.
  94778. * @param camera Defines the camera to attach the behavior to
  94779. */
  94780. attach(camera: ArcRotateCamera): void;
  94781. /**
  94782. * Detaches the behavior from its current arc rotate camera.
  94783. */
  94784. detach(): void;
  94785. private _animatables;
  94786. private _betaIsAnimating;
  94787. private _betaTransition;
  94788. private _radiusTransition;
  94789. private _vectorTransition;
  94790. /**
  94791. * Targets the given mesh and updates zoom level accordingly.
  94792. * @param mesh The mesh to target.
  94793. * @param radius Optional. If a cached radius position already exists, overrides default.
  94794. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94795. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94796. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94797. */
  94798. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94799. /**
  94800. * Targets the given mesh with its children and updates zoom level accordingly.
  94801. * @param mesh The mesh to target.
  94802. * @param radius Optional. If a cached radius position already exists, overrides default.
  94803. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94804. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94805. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94806. */
  94807. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94808. /**
  94809. * Targets the given meshes with their children and updates zoom level accordingly.
  94810. * @param meshes The mesh to target.
  94811. * @param radius Optional. If a cached radius position already exists, overrides default.
  94812. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94813. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94814. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94815. */
  94816. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94817. /**
  94818. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94819. * @param minimumWorld Determines the smaller position of the bounding box extend
  94820. * @param maximumWorld Determines the bigger position of the bounding box extend
  94821. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94822. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94823. */
  94824. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94825. /**
  94826. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94827. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94828. * frustum width.
  94829. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94830. * to fully enclose the mesh in the viewing frustum.
  94831. */
  94832. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94833. /**
  94834. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94835. * is automatically returned to its default position (expected to be above ground plane).
  94836. */
  94837. private _maintainCameraAboveGround;
  94838. /**
  94839. * Returns the frustum slope based on the canvas ratio and camera FOV
  94840. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94841. */
  94842. private _getFrustumSlope;
  94843. /**
  94844. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94845. */
  94846. private _clearAnimationLocks;
  94847. /**
  94848. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94849. */
  94850. private _applyUserInteraction;
  94851. /**
  94852. * Stops and removes all animations that have been applied to the camera
  94853. */
  94854. stopAllAnimations(): void;
  94855. /**
  94856. * Gets a value indicating if the user is moving the camera
  94857. */
  94858. readonly isUserIsMoving: boolean;
  94859. /**
  94860. * The camera can move all the way towards the mesh.
  94861. */
  94862. static IgnoreBoundsSizeMode: number;
  94863. /**
  94864. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94865. */
  94866. static FitFrustumSidesMode: number;
  94867. }
  94868. }
  94869. declare module BABYLON {
  94870. /**
  94871. * Base class for Camera Pointer Inputs.
  94872. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94873. * for example usage.
  94874. */
  94875. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94876. /**
  94877. * Defines the camera the input is attached to.
  94878. */
  94879. abstract camera: Camera;
  94880. /**
  94881. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94882. */
  94883. protected _altKey: boolean;
  94884. protected _ctrlKey: boolean;
  94885. protected _metaKey: boolean;
  94886. protected _shiftKey: boolean;
  94887. /**
  94888. * Which mouse buttons were pressed at time of last mouse event.
  94889. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94890. */
  94891. protected _buttonsPressed: number;
  94892. /**
  94893. * Defines the buttons associated with the input to handle camera move.
  94894. */
  94895. buttons: number[];
  94896. /**
  94897. * Attach the input controls to a specific dom element to get the input from.
  94898. * @param element Defines the element the controls should be listened from
  94899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94900. */
  94901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94902. /**
  94903. * Detach the current controls from the specified dom element.
  94904. * @param element Defines the element to stop listening the inputs from
  94905. */
  94906. detachControl(element: Nullable<HTMLElement>): void;
  94907. /**
  94908. * Gets the class name of the current input.
  94909. * @returns the class name
  94910. */
  94911. getClassName(): string;
  94912. /**
  94913. * Get the friendly name associated with the input class.
  94914. * @returns the input friendly name
  94915. */
  94916. getSimpleName(): string;
  94917. /**
  94918. * Called on pointer POINTERDOUBLETAP event.
  94919. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94920. */
  94921. protected onDoubleTap(type: string): void;
  94922. /**
  94923. * Called on pointer POINTERMOVE event if only a single touch is active.
  94924. * Override this method to provide functionality.
  94925. */
  94926. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94927. /**
  94928. * Called on pointer POINTERMOVE event if multiple touches are active.
  94929. * Override this method to provide functionality.
  94930. */
  94931. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94932. /**
  94933. * Called on JS contextmenu event.
  94934. * Override this method to provide functionality.
  94935. */
  94936. protected onContextMenu(evt: PointerEvent): void;
  94937. /**
  94938. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94939. * press.
  94940. * Override this method to provide functionality.
  94941. */
  94942. protected onButtonDown(evt: PointerEvent): void;
  94943. /**
  94944. * Called each time a new POINTERUP event occurs. Ie, for each button
  94945. * release.
  94946. * Override this method to provide functionality.
  94947. */
  94948. protected onButtonUp(evt: PointerEvent): void;
  94949. /**
  94950. * Called when window becomes inactive.
  94951. * Override this method to provide functionality.
  94952. */
  94953. protected onLostFocus(): void;
  94954. private _pointerInput;
  94955. private _observer;
  94956. private _onLostFocus;
  94957. private pointA;
  94958. private pointB;
  94959. }
  94960. }
  94961. declare module BABYLON {
  94962. /**
  94963. * Manage the pointers inputs to control an arc rotate camera.
  94964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94965. */
  94966. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94967. /**
  94968. * Defines the camera the input is attached to.
  94969. */
  94970. camera: ArcRotateCamera;
  94971. /**
  94972. * Gets the class name of the current input.
  94973. * @returns the class name
  94974. */
  94975. getClassName(): string;
  94976. /**
  94977. * Defines the buttons associated with the input to handle camera move.
  94978. */
  94979. buttons: number[];
  94980. /**
  94981. * Defines the pointer angular sensibility along the X axis or how fast is
  94982. * the camera rotating.
  94983. */
  94984. angularSensibilityX: number;
  94985. /**
  94986. * Defines the pointer angular sensibility along the Y axis or how fast is
  94987. * the camera rotating.
  94988. */
  94989. angularSensibilityY: number;
  94990. /**
  94991. * Defines the pointer pinch precision or how fast is the camera zooming.
  94992. */
  94993. pinchPrecision: number;
  94994. /**
  94995. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94996. * from 0.
  94997. * It defines the percentage of current camera.radius to use as delta when
  94998. * pinch zoom is used.
  94999. */
  95000. pinchDeltaPercentage: number;
  95001. /**
  95002. * Defines the pointer panning sensibility or how fast is the camera moving.
  95003. */
  95004. panningSensibility: number;
  95005. /**
  95006. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  95007. */
  95008. multiTouchPanning: boolean;
  95009. /**
  95010. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  95011. * zoom (pinch) through multitouch.
  95012. */
  95013. multiTouchPanAndZoom: boolean;
  95014. /**
  95015. * Revers pinch action direction.
  95016. */
  95017. pinchInwards: boolean;
  95018. private _isPanClick;
  95019. private _twoFingerActivityCount;
  95020. private _isPinching;
  95021. /**
  95022. * Called on pointer POINTERMOVE event if only a single touch is active.
  95023. */
  95024. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95025. /**
  95026. * Called on pointer POINTERDOUBLETAP event.
  95027. */
  95028. protected onDoubleTap(type: string): void;
  95029. /**
  95030. * Called on pointer POINTERMOVE event if multiple touches are active.
  95031. */
  95032. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95033. /**
  95034. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  95035. * press.
  95036. */
  95037. protected onButtonDown(evt: PointerEvent): void;
  95038. /**
  95039. * Called each time a new POINTERUP event occurs. Ie, for each button
  95040. * release.
  95041. */
  95042. protected onButtonUp(evt: PointerEvent): void;
  95043. /**
  95044. * Called when window becomes inactive.
  95045. */
  95046. protected onLostFocus(): void;
  95047. }
  95048. }
  95049. declare module BABYLON {
  95050. /**
  95051. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  95052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95053. */
  95054. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  95055. /**
  95056. * Defines the camera the input is attached to.
  95057. */
  95058. camera: ArcRotateCamera;
  95059. /**
  95060. * Defines the list of key codes associated with the up action (increase alpha)
  95061. */
  95062. keysUp: number[];
  95063. /**
  95064. * Defines the list of key codes associated with the down action (decrease alpha)
  95065. */
  95066. keysDown: number[];
  95067. /**
  95068. * Defines the list of key codes associated with the left action (increase beta)
  95069. */
  95070. keysLeft: number[];
  95071. /**
  95072. * Defines the list of key codes associated with the right action (decrease beta)
  95073. */
  95074. keysRight: number[];
  95075. /**
  95076. * Defines the list of key codes associated with the reset action.
  95077. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  95078. */
  95079. keysReset: number[];
  95080. /**
  95081. * Defines the panning sensibility of the inputs.
  95082. * (How fast is the camera paning)
  95083. */
  95084. panningSensibility: number;
  95085. /**
  95086. * Defines the zooming sensibility of the inputs.
  95087. * (How fast is the camera zooming)
  95088. */
  95089. zoomingSensibility: number;
  95090. /**
  95091. * Defines wether maintaining the alt key down switch the movement mode from
  95092. * orientation to zoom.
  95093. */
  95094. useAltToZoom: boolean;
  95095. /**
  95096. * Rotation speed of the camera
  95097. */
  95098. angularSpeed: number;
  95099. private _keys;
  95100. private _ctrlPressed;
  95101. private _altPressed;
  95102. private _onCanvasBlurObserver;
  95103. private _onKeyboardObserver;
  95104. private _engine;
  95105. private _scene;
  95106. /**
  95107. * Attach the input controls to a specific dom element to get the input from.
  95108. * @param element Defines the element the controls should be listened from
  95109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95110. */
  95111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95112. /**
  95113. * Detach the current controls from the specified dom element.
  95114. * @param element Defines the element to stop listening the inputs from
  95115. */
  95116. detachControl(element: Nullable<HTMLElement>): void;
  95117. /**
  95118. * Update the current camera state depending on the inputs that have been used this frame.
  95119. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95120. */
  95121. checkInputs(): void;
  95122. /**
  95123. * Gets the class name of the current intput.
  95124. * @returns the class name
  95125. */
  95126. getClassName(): string;
  95127. /**
  95128. * Get the friendly name associated with the input class.
  95129. * @returns the input friendly name
  95130. */
  95131. getSimpleName(): string;
  95132. }
  95133. }
  95134. declare module BABYLON {
  95135. /**
  95136. * Manage the mouse wheel inputs to control an arc rotate camera.
  95137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95138. */
  95139. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  95140. /**
  95141. * Defines the camera the input is attached to.
  95142. */
  95143. camera: ArcRotateCamera;
  95144. /**
  95145. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95146. */
  95147. wheelPrecision: number;
  95148. /**
  95149. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95150. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95151. */
  95152. wheelDeltaPercentage: number;
  95153. private _wheel;
  95154. private _observer;
  95155. private computeDeltaFromMouseWheelLegacyEvent;
  95156. /**
  95157. * Attach the input controls to a specific dom element to get the input from.
  95158. * @param element Defines the element the controls should be listened from
  95159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95160. */
  95161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95162. /**
  95163. * Detach the current controls from the specified dom element.
  95164. * @param element Defines the element to stop listening the inputs from
  95165. */
  95166. detachControl(element: Nullable<HTMLElement>): void;
  95167. /**
  95168. * Gets the class name of the current intput.
  95169. * @returns the class name
  95170. */
  95171. getClassName(): string;
  95172. /**
  95173. * Get the friendly name associated with the input class.
  95174. * @returns the input friendly name
  95175. */
  95176. getSimpleName(): string;
  95177. }
  95178. }
  95179. declare module BABYLON {
  95180. /**
  95181. * Default Inputs manager for the ArcRotateCamera.
  95182. * It groups all the default supported inputs for ease of use.
  95183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95184. */
  95185. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  95186. /**
  95187. * Instantiates a new ArcRotateCameraInputsManager.
  95188. * @param camera Defines the camera the inputs belong to
  95189. */
  95190. constructor(camera: ArcRotateCamera);
  95191. /**
  95192. * Add mouse wheel input support to the input manager.
  95193. * @returns the current input manager
  95194. */
  95195. addMouseWheel(): ArcRotateCameraInputsManager;
  95196. /**
  95197. * Add pointers input support to the input manager.
  95198. * @returns the current input manager
  95199. */
  95200. addPointers(): ArcRotateCameraInputsManager;
  95201. /**
  95202. * Add keyboard input support to the input manager.
  95203. * @returns the current input manager
  95204. */
  95205. addKeyboard(): ArcRotateCameraInputsManager;
  95206. }
  95207. }
  95208. declare module BABYLON {
  95209. /**
  95210. * This represents an orbital type of camera.
  95211. *
  95212. * 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.
  95213. * 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.
  95214. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95215. */
  95216. export class ArcRotateCamera extends TargetCamera {
  95217. /**
  95218. * Defines the rotation angle of the camera along the longitudinal axis.
  95219. */
  95220. alpha: number;
  95221. /**
  95222. * Defines the rotation angle of the camera along the latitudinal axis.
  95223. */
  95224. beta: number;
  95225. /**
  95226. * Defines the radius of the camera from it s target point.
  95227. */
  95228. radius: number;
  95229. protected _target: Vector3;
  95230. protected _targetHost: Nullable<AbstractMesh>;
  95231. /**
  95232. * Defines the target point of the camera.
  95233. * The camera looks towards it form the radius distance.
  95234. */
  95235. target: Vector3;
  95236. /**
  95237. * Define the current local position of the camera in the scene
  95238. */
  95239. position: Vector3;
  95240. protected _upVector: Vector3;
  95241. protected _upToYMatrix: Matrix;
  95242. protected _YToUpMatrix: Matrix;
  95243. /**
  95244. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95245. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95246. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95247. */
  95248. upVector: Vector3;
  95249. /**
  95250. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95251. */
  95252. setMatUp(): void;
  95253. /**
  95254. * Current inertia value on the longitudinal axis.
  95255. * The bigger this number the longer it will take for the camera to stop.
  95256. */
  95257. inertialAlphaOffset: number;
  95258. /**
  95259. * Current inertia value on the latitudinal axis.
  95260. * The bigger this number the longer it will take for the camera to stop.
  95261. */
  95262. inertialBetaOffset: number;
  95263. /**
  95264. * Current inertia value on the radius axis.
  95265. * The bigger this number the longer it will take for the camera to stop.
  95266. */
  95267. inertialRadiusOffset: number;
  95268. /**
  95269. * Minimum allowed angle on the longitudinal axis.
  95270. * This can help limiting how the Camera is able to move in the scene.
  95271. */
  95272. lowerAlphaLimit: Nullable<number>;
  95273. /**
  95274. * Maximum allowed angle on the longitudinal axis.
  95275. * This can help limiting how the Camera is able to move in the scene.
  95276. */
  95277. upperAlphaLimit: Nullable<number>;
  95278. /**
  95279. * Minimum allowed angle on the latitudinal axis.
  95280. * This can help limiting how the Camera is able to move in the scene.
  95281. */
  95282. lowerBetaLimit: number;
  95283. /**
  95284. * Maximum allowed angle on the latitudinal axis.
  95285. * This can help limiting how the Camera is able to move in the scene.
  95286. */
  95287. upperBetaLimit: number;
  95288. /**
  95289. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95290. * This can help limiting how the Camera is able to move in the scene.
  95291. */
  95292. lowerRadiusLimit: Nullable<number>;
  95293. /**
  95294. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95295. * This can help limiting how the Camera is able to move in the scene.
  95296. */
  95297. upperRadiusLimit: Nullable<number>;
  95298. /**
  95299. * Defines the current inertia value used during panning of the camera along the X axis.
  95300. */
  95301. inertialPanningX: number;
  95302. /**
  95303. * Defines the current inertia value used during panning of the camera along the Y axis.
  95304. */
  95305. inertialPanningY: number;
  95306. /**
  95307. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95308. * Basically if your fingers moves away from more than this distance you will be considered
  95309. * in pinch mode.
  95310. */
  95311. pinchToPanMaxDistance: number;
  95312. /**
  95313. * Defines the maximum distance the camera can pan.
  95314. * This could help keeping the cammera always in your scene.
  95315. */
  95316. panningDistanceLimit: Nullable<number>;
  95317. /**
  95318. * Defines the target of the camera before paning.
  95319. */
  95320. panningOriginTarget: Vector3;
  95321. /**
  95322. * Defines the value of the inertia used during panning.
  95323. * 0 would mean stop inertia and one would mean no decelleration at all.
  95324. */
  95325. panningInertia: number;
  95326. /**
  95327. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95328. */
  95329. angularSensibilityX: number;
  95330. /**
  95331. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95332. */
  95333. angularSensibilityY: number;
  95334. /**
  95335. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95336. */
  95337. pinchPrecision: number;
  95338. /**
  95339. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95340. * It will be used instead of pinchDeltaPrecision if different from 0.
  95341. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95342. */
  95343. pinchDeltaPercentage: number;
  95344. /**
  95345. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95346. */
  95347. panningSensibility: number;
  95348. /**
  95349. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95350. */
  95351. keysUp: number[];
  95352. /**
  95353. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95354. */
  95355. keysDown: number[];
  95356. /**
  95357. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95358. */
  95359. keysLeft: number[];
  95360. /**
  95361. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95362. */
  95363. keysRight: number[];
  95364. /**
  95365. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95366. */
  95367. wheelPrecision: number;
  95368. /**
  95369. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95370. * It will be used instead of pinchDeltaPrecision if different from 0.
  95371. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95372. */
  95373. wheelDeltaPercentage: number;
  95374. /**
  95375. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95376. */
  95377. zoomOnFactor: number;
  95378. /**
  95379. * Defines a screen offset for the camera position.
  95380. */
  95381. targetScreenOffset: Vector2;
  95382. /**
  95383. * Allows the camera to be completely reversed.
  95384. * If false the camera can not arrive upside down.
  95385. */
  95386. allowUpsideDown: boolean;
  95387. /**
  95388. * Define if double tap/click is used to restore the previously saved state of the camera.
  95389. */
  95390. useInputToRestoreState: boolean;
  95391. /** @hidden */
  95392. _viewMatrix: Matrix;
  95393. /** @hidden */
  95394. _useCtrlForPanning: boolean;
  95395. /** @hidden */
  95396. _panningMouseButton: number;
  95397. /**
  95398. * Defines the input associated to the camera.
  95399. */
  95400. inputs: ArcRotateCameraInputsManager;
  95401. /** @hidden */
  95402. _reset: () => void;
  95403. /**
  95404. * Defines the allowed panning axis.
  95405. */
  95406. panningAxis: Vector3;
  95407. protected _localDirection: Vector3;
  95408. protected _transformedDirection: Vector3;
  95409. private _bouncingBehavior;
  95410. /**
  95411. * Gets the bouncing behavior of the camera if it has been enabled.
  95412. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95413. */
  95414. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95415. /**
  95416. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95417. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95418. */
  95419. useBouncingBehavior: boolean;
  95420. private _framingBehavior;
  95421. /**
  95422. * Gets the framing behavior of the camera if it has been enabled.
  95423. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95424. */
  95425. readonly framingBehavior: Nullable<FramingBehavior>;
  95426. /**
  95427. * Defines if the framing behavior of the camera is enabled on the camera.
  95428. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95429. */
  95430. useFramingBehavior: boolean;
  95431. private _autoRotationBehavior;
  95432. /**
  95433. * Gets the auto rotation behavior of the camera if it has been enabled.
  95434. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95435. */
  95436. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95437. /**
  95438. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95439. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95440. */
  95441. useAutoRotationBehavior: boolean;
  95442. /**
  95443. * Observable triggered when the mesh target has been changed on the camera.
  95444. */
  95445. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95446. /**
  95447. * Event raised when the camera is colliding with a mesh.
  95448. */
  95449. onCollide: (collidedMesh: AbstractMesh) => void;
  95450. /**
  95451. * Defines whether the camera should check collision with the objects oh the scene.
  95452. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95453. */
  95454. checkCollisions: boolean;
  95455. /**
  95456. * Defines the collision radius of the camera.
  95457. * This simulates a sphere around the camera.
  95458. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95459. */
  95460. collisionRadius: Vector3;
  95461. protected _collider: Collider;
  95462. protected _previousPosition: Vector3;
  95463. protected _collisionVelocity: Vector3;
  95464. protected _newPosition: Vector3;
  95465. protected _previousAlpha: number;
  95466. protected _previousBeta: number;
  95467. protected _previousRadius: number;
  95468. protected _collisionTriggered: boolean;
  95469. protected _targetBoundingCenter: Nullable<Vector3>;
  95470. private _computationVector;
  95471. /**
  95472. * Instantiates a new ArcRotateCamera in a given scene
  95473. * @param name Defines the name of the camera
  95474. * @param alpha Defines the camera rotation along the logitudinal axis
  95475. * @param beta Defines the camera rotation along the latitudinal axis
  95476. * @param radius Defines the camera distance from its target
  95477. * @param target Defines the camera target
  95478. * @param scene Defines the scene the camera belongs to
  95479. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95480. */
  95481. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95482. /** @hidden */
  95483. _initCache(): void;
  95484. /** @hidden */
  95485. _updateCache(ignoreParentClass?: boolean): void;
  95486. protected _getTargetPosition(): Vector3;
  95487. private _storedAlpha;
  95488. private _storedBeta;
  95489. private _storedRadius;
  95490. private _storedTarget;
  95491. /**
  95492. * Stores the current state of the camera (alpha, beta, radius and target)
  95493. * @returns the camera itself
  95494. */
  95495. storeState(): Camera;
  95496. /**
  95497. * @hidden
  95498. * Restored camera state. You must call storeState() first
  95499. */
  95500. _restoreStateValues(): boolean;
  95501. /** @hidden */
  95502. _isSynchronizedViewMatrix(): boolean;
  95503. /**
  95504. * Attached controls to the current camera.
  95505. * @param element Defines the element the controls should be listened from
  95506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95507. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95508. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95509. */
  95510. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95511. /**
  95512. * Detach the current controls from the camera.
  95513. * The camera will stop reacting to inputs.
  95514. * @param element Defines the element to stop listening the inputs from
  95515. */
  95516. detachControl(element: HTMLElement): void;
  95517. /** @hidden */
  95518. _checkInputs(): void;
  95519. protected _checkLimits(): void;
  95520. /**
  95521. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95522. */
  95523. rebuildAnglesAndRadius(): void;
  95524. /**
  95525. * Use a position to define the current camera related information like aplha, beta and radius
  95526. * @param position Defines the position to set the camera at
  95527. */
  95528. setPosition(position: Vector3): void;
  95529. /**
  95530. * Defines the target the camera should look at.
  95531. * This will automatically adapt alpha beta and radius to fit within the new target.
  95532. * @param target Defines the new target as a Vector or a mesh
  95533. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95534. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95535. */
  95536. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95537. /** @hidden */
  95538. _getViewMatrix(): Matrix;
  95539. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95540. /**
  95541. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95542. * @param meshes Defines the mesh to zoom on
  95543. * @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)
  95544. */
  95545. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95546. /**
  95547. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95548. * The target will be changed but the radius
  95549. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95550. * @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)
  95551. */
  95552. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95553. min: Vector3;
  95554. max: Vector3;
  95555. distance: number;
  95556. }, doNotUpdateMaxZ?: boolean): void;
  95557. /**
  95558. * @override
  95559. * Override Camera.createRigCamera
  95560. */
  95561. createRigCamera(name: string, cameraIndex: number): Camera;
  95562. /**
  95563. * @hidden
  95564. * @override
  95565. * Override Camera._updateRigCameras
  95566. */
  95567. _updateRigCameras(): void;
  95568. /**
  95569. * Destroy the camera and release the current resources hold by it.
  95570. */
  95571. dispose(): void;
  95572. /**
  95573. * Gets the current object class name.
  95574. * @return the class name
  95575. */
  95576. getClassName(): string;
  95577. }
  95578. }
  95579. declare module BABYLON {
  95580. /**
  95581. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95582. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95583. */
  95584. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95585. /**
  95586. * Gets the name of the behavior.
  95587. */
  95588. readonly name: string;
  95589. private _zoomStopsAnimation;
  95590. private _idleRotationSpeed;
  95591. private _idleRotationWaitTime;
  95592. private _idleRotationSpinupTime;
  95593. /**
  95594. * Sets the flag that indicates if user zooming should stop animation.
  95595. */
  95596. /**
  95597. * Gets the flag that indicates if user zooming should stop animation.
  95598. */
  95599. zoomStopsAnimation: boolean;
  95600. /**
  95601. * Sets the default speed at which the camera rotates around the model.
  95602. */
  95603. /**
  95604. * Gets the default speed at which the camera rotates around the model.
  95605. */
  95606. idleRotationSpeed: number;
  95607. /**
  95608. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95609. */
  95610. /**
  95611. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95612. */
  95613. idleRotationWaitTime: number;
  95614. /**
  95615. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95616. */
  95617. /**
  95618. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95619. */
  95620. idleRotationSpinupTime: number;
  95621. /**
  95622. * Gets a value indicating if the camera is currently rotating because of this behavior
  95623. */
  95624. readonly rotationInProgress: boolean;
  95625. private _onPrePointerObservableObserver;
  95626. private _onAfterCheckInputsObserver;
  95627. private _attachedCamera;
  95628. private _isPointerDown;
  95629. private _lastFrameTime;
  95630. private _lastInteractionTime;
  95631. private _cameraRotationSpeed;
  95632. /**
  95633. * Initializes the behavior.
  95634. */
  95635. init(): void;
  95636. /**
  95637. * Attaches the behavior to its arc rotate camera.
  95638. * @param camera Defines the camera to attach the behavior to
  95639. */
  95640. attach(camera: ArcRotateCamera): void;
  95641. /**
  95642. * Detaches the behavior from its current arc rotate camera.
  95643. */
  95644. detach(): void;
  95645. /**
  95646. * Returns true if user is scrolling.
  95647. * @return true if user is scrolling.
  95648. */
  95649. private _userIsZooming;
  95650. private _lastFrameRadius;
  95651. private _shouldAnimationStopForInteraction;
  95652. /**
  95653. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95654. */
  95655. private _applyUserInteraction;
  95656. private _userIsMoving;
  95657. }
  95658. }
  95659. declare module BABYLON {
  95660. /**
  95661. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95662. */
  95663. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95664. private ui;
  95665. /**
  95666. * The name of the behavior
  95667. */
  95668. name: string;
  95669. /**
  95670. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95671. */
  95672. distanceAwayFromFace: number;
  95673. /**
  95674. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95675. */
  95676. distanceAwayFromBottomOfFace: number;
  95677. private _faceVectors;
  95678. private _target;
  95679. private _scene;
  95680. private _onRenderObserver;
  95681. private _tmpMatrix;
  95682. private _tmpVector;
  95683. /**
  95684. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95685. * @param ui The transform node that should be attched to the mesh
  95686. */
  95687. constructor(ui: TransformNode);
  95688. /**
  95689. * Initializes the behavior
  95690. */
  95691. init(): void;
  95692. private _closestFace;
  95693. private _zeroVector;
  95694. private _lookAtTmpMatrix;
  95695. private _lookAtToRef;
  95696. /**
  95697. * Attaches the AttachToBoxBehavior to the passed in mesh
  95698. * @param target The mesh that the specified node will be attached to
  95699. */
  95700. attach(target: Mesh): void;
  95701. /**
  95702. * Detaches the behavior from the mesh
  95703. */
  95704. detach(): void;
  95705. }
  95706. }
  95707. declare module BABYLON {
  95708. /**
  95709. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95710. */
  95711. export class FadeInOutBehavior implements Behavior<Mesh> {
  95712. /**
  95713. * Time in milliseconds to delay before fading in (Default: 0)
  95714. */
  95715. delay: number;
  95716. /**
  95717. * Time in milliseconds for the mesh to fade in (Default: 300)
  95718. */
  95719. fadeInTime: number;
  95720. private _millisecondsPerFrame;
  95721. private _hovered;
  95722. private _hoverValue;
  95723. private _ownerNode;
  95724. /**
  95725. * Instatiates the FadeInOutBehavior
  95726. */
  95727. constructor();
  95728. /**
  95729. * The name of the behavior
  95730. */
  95731. readonly name: string;
  95732. /**
  95733. * Initializes the behavior
  95734. */
  95735. init(): void;
  95736. /**
  95737. * Attaches the fade behavior on the passed in mesh
  95738. * @param ownerNode The mesh that will be faded in/out once attached
  95739. */
  95740. attach(ownerNode: Mesh): void;
  95741. /**
  95742. * Detaches the behavior from the mesh
  95743. */
  95744. detach(): void;
  95745. /**
  95746. * Triggers the mesh to begin fading in or out
  95747. * @param value if the object should fade in or out (true to fade in)
  95748. */
  95749. fadeIn(value: boolean): void;
  95750. private _update;
  95751. private _setAllVisibility;
  95752. }
  95753. }
  95754. declare module BABYLON {
  95755. /**
  95756. * Class containing a set of static utilities functions for managing Pivots
  95757. * @hidden
  95758. */
  95759. export class PivotTools {
  95760. private static _PivotCached;
  95761. private static _OldPivotPoint;
  95762. private static _PivotTranslation;
  95763. private static _PivotTmpVector;
  95764. /** @hidden */
  95765. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95766. /** @hidden */
  95767. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95768. }
  95769. }
  95770. declare module BABYLON {
  95771. /**
  95772. * Class containing static functions to help procedurally build meshes
  95773. */
  95774. export class PlaneBuilder {
  95775. /**
  95776. * Creates a plane mesh
  95777. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95778. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95779. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95783. * @param name defines the name of the mesh
  95784. * @param options defines the options used to create the mesh
  95785. * @param scene defines the hosting scene
  95786. * @returns the plane mesh
  95787. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95788. */
  95789. static CreatePlane(name: string, options: {
  95790. size?: number;
  95791. width?: number;
  95792. height?: number;
  95793. sideOrientation?: number;
  95794. frontUVs?: Vector4;
  95795. backUVs?: Vector4;
  95796. updatable?: boolean;
  95797. sourcePlane?: Plane;
  95798. }, scene?: Nullable<Scene>): Mesh;
  95799. }
  95800. }
  95801. declare module BABYLON {
  95802. /**
  95803. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95804. */
  95805. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95806. private static _AnyMouseID;
  95807. private _attachedNode;
  95808. private _dragPlane;
  95809. private _scene;
  95810. private _pointerObserver;
  95811. private _beforeRenderObserver;
  95812. private static _planeScene;
  95813. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95814. /**
  95815. * 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)
  95816. */
  95817. maxDragAngle: number;
  95818. /**
  95819. * @hidden
  95820. */
  95821. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95822. /**
  95823. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95824. */
  95825. currentDraggingPointerID: number;
  95826. /**
  95827. * The last position where the pointer hit the drag plane in world space
  95828. */
  95829. lastDragPosition: Vector3;
  95830. /**
  95831. * If the behavior is currently in a dragging state
  95832. */
  95833. dragging: boolean;
  95834. /**
  95835. * 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)
  95836. */
  95837. dragDeltaRatio: number;
  95838. /**
  95839. * If the drag plane orientation should be updated during the dragging (Default: true)
  95840. */
  95841. updateDragPlane: boolean;
  95842. private _debugMode;
  95843. private _moving;
  95844. /**
  95845. * Fires each time the attached mesh is dragged with the pointer
  95846. * * delta between last drag position and current drag position in world space
  95847. * * dragDistance along the drag axis
  95848. * * dragPlaneNormal normal of the current drag plane used during the drag
  95849. * * dragPlanePoint in world space where the drag intersects the drag plane
  95850. */
  95851. onDragObservable: Observable<{
  95852. delta: Vector3;
  95853. dragPlanePoint: Vector3;
  95854. dragPlaneNormal: Vector3;
  95855. dragDistance: number;
  95856. pointerId: number;
  95857. }>;
  95858. /**
  95859. * Fires each time a drag begins (eg. mouse down on mesh)
  95860. */
  95861. onDragStartObservable: Observable<{
  95862. dragPlanePoint: Vector3;
  95863. pointerId: number;
  95864. }>;
  95865. /**
  95866. * Fires each time a drag ends (eg. mouse release after drag)
  95867. */
  95868. onDragEndObservable: Observable<{
  95869. dragPlanePoint: Vector3;
  95870. pointerId: number;
  95871. }>;
  95872. /**
  95873. * If the attached mesh should be moved when dragged
  95874. */
  95875. moveAttached: boolean;
  95876. /**
  95877. * If the drag behavior will react to drag events (Default: true)
  95878. */
  95879. enabled: boolean;
  95880. /**
  95881. * If camera controls should be detached during the drag
  95882. */
  95883. detachCameraControls: boolean;
  95884. /**
  95885. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95886. */
  95887. useObjectOrienationForDragging: boolean;
  95888. private _options;
  95889. /**
  95890. * Creates a pointer drag behavior that can be attached to a mesh
  95891. * @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)
  95892. */
  95893. constructor(options?: {
  95894. dragAxis?: Vector3;
  95895. dragPlaneNormal?: Vector3;
  95896. });
  95897. /**
  95898. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95899. */
  95900. validateDrag: (targetPosition: Vector3) => boolean;
  95901. /**
  95902. * The name of the behavior
  95903. */
  95904. readonly name: string;
  95905. /**
  95906. * Initializes the behavior
  95907. */
  95908. init(): void;
  95909. private _tmpVector;
  95910. private _alternatePickedPoint;
  95911. private _worldDragAxis;
  95912. private _targetPosition;
  95913. private _attachedElement;
  95914. /**
  95915. * Attaches the drag behavior the passed in mesh
  95916. * @param ownerNode The mesh that will be dragged around once attached
  95917. */
  95918. attach(ownerNode: AbstractMesh): void;
  95919. /**
  95920. * Force relase the drag action by code.
  95921. */
  95922. releaseDrag(): void;
  95923. private _startDragRay;
  95924. private _lastPointerRay;
  95925. /**
  95926. * Simulates the start of a pointer drag event on the behavior
  95927. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95928. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95929. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95930. */
  95931. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95932. private _startDrag;
  95933. private _dragDelta;
  95934. private _moveDrag;
  95935. private _pickWithRayOnDragPlane;
  95936. private _pointA;
  95937. private _pointB;
  95938. private _pointC;
  95939. private _lineA;
  95940. private _lineB;
  95941. private _localAxis;
  95942. private _lookAt;
  95943. private _updateDragPlanePosition;
  95944. /**
  95945. * Detaches the behavior from the mesh
  95946. */
  95947. detach(): void;
  95948. }
  95949. }
  95950. declare module BABYLON {
  95951. /**
  95952. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95953. */
  95954. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95955. private _dragBehaviorA;
  95956. private _dragBehaviorB;
  95957. private _startDistance;
  95958. private _initialScale;
  95959. private _targetScale;
  95960. private _ownerNode;
  95961. private _sceneRenderObserver;
  95962. /**
  95963. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95964. */
  95965. constructor();
  95966. /**
  95967. * The name of the behavior
  95968. */
  95969. readonly name: string;
  95970. /**
  95971. * Initializes the behavior
  95972. */
  95973. init(): void;
  95974. private _getCurrentDistance;
  95975. /**
  95976. * Attaches the scale behavior the passed in mesh
  95977. * @param ownerNode The mesh that will be scaled around once attached
  95978. */
  95979. attach(ownerNode: Mesh): void;
  95980. /**
  95981. * Detaches the behavior from the mesh
  95982. */
  95983. detach(): void;
  95984. }
  95985. }
  95986. declare module BABYLON {
  95987. /**
  95988. * 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
  95989. */
  95990. export class SixDofDragBehavior implements Behavior<Mesh> {
  95991. private static _virtualScene;
  95992. private _ownerNode;
  95993. private _sceneRenderObserver;
  95994. private _scene;
  95995. private _targetPosition;
  95996. private _virtualOriginMesh;
  95997. private _virtualDragMesh;
  95998. private _pointerObserver;
  95999. private _moving;
  96000. private _startingOrientation;
  96001. /**
  96002. * 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)
  96003. */
  96004. private zDragFactor;
  96005. /**
  96006. * If the object should rotate to face the drag origin
  96007. */
  96008. rotateDraggedObject: boolean;
  96009. /**
  96010. * If the behavior is currently in a dragging state
  96011. */
  96012. dragging: boolean;
  96013. /**
  96014. * 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)
  96015. */
  96016. dragDeltaRatio: number;
  96017. /**
  96018. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  96019. */
  96020. currentDraggingPointerID: number;
  96021. /**
  96022. * If camera controls should be detached during the drag
  96023. */
  96024. detachCameraControls: boolean;
  96025. /**
  96026. * Fires each time a drag starts
  96027. */
  96028. onDragStartObservable: Observable<{}>;
  96029. /**
  96030. * Fires each time a drag ends (eg. mouse release after drag)
  96031. */
  96032. onDragEndObservable: Observable<{}>;
  96033. /**
  96034. * 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
  96035. */
  96036. constructor();
  96037. /**
  96038. * The name of the behavior
  96039. */
  96040. readonly name: string;
  96041. /**
  96042. * Initializes the behavior
  96043. */
  96044. init(): void;
  96045. /**
  96046. * Attaches the scale behavior the passed in mesh
  96047. * @param ownerNode The mesh that will be scaled around once attached
  96048. */
  96049. attach(ownerNode: Mesh): void;
  96050. /**
  96051. * Detaches the behavior from the mesh
  96052. */
  96053. detach(): void;
  96054. }
  96055. }
  96056. declare module BABYLON {
  96057. /**
  96058. * Class used to apply inverse kinematics to bones
  96059. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  96060. */
  96061. export class BoneIKController {
  96062. private static _tmpVecs;
  96063. private static _tmpQuat;
  96064. private static _tmpMats;
  96065. /**
  96066. * Gets or sets the target mesh
  96067. */
  96068. targetMesh: AbstractMesh;
  96069. /** Gets or sets the mesh used as pole */
  96070. poleTargetMesh: AbstractMesh;
  96071. /**
  96072. * Gets or sets the bone used as pole
  96073. */
  96074. poleTargetBone: Nullable<Bone>;
  96075. /**
  96076. * Gets or sets the target position
  96077. */
  96078. targetPosition: Vector3;
  96079. /**
  96080. * Gets or sets the pole target position
  96081. */
  96082. poleTargetPosition: Vector3;
  96083. /**
  96084. * Gets or sets the pole target local offset
  96085. */
  96086. poleTargetLocalOffset: Vector3;
  96087. /**
  96088. * Gets or sets the pole angle
  96089. */
  96090. poleAngle: number;
  96091. /**
  96092. * Gets or sets the mesh associated with the controller
  96093. */
  96094. mesh: AbstractMesh;
  96095. /**
  96096. * 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)
  96097. */
  96098. slerpAmount: number;
  96099. private _bone1Quat;
  96100. private _bone1Mat;
  96101. private _bone2Ang;
  96102. private _bone1;
  96103. private _bone2;
  96104. private _bone1Length;
  96105. private _bone2Length;
  96106. private _maxAngle;
  96107. private _maxReach;
  96108. private _rightHandedSystem;
  96109. private _bendAxis;
  96110. private _slerping;
  96111. private _adjustRoll;
  96112. /**
  96113. * Gets or sets maximum allowed angle
  96114. */
  96115. maxAngle: number;
  96116. /**
  96117. * Creates a new BoneIKController
  96118. * @param mesh defines the mesh to control
  96119. * @param bone defines the bone to control
  96120. * @param options defines options to set up the controller
  96121. */
  96122. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  96123. targetMesh?: AbstractMesh;
  96124. poleTargetMesh?: AbstractMesh;
  96125. poleTargetBone?: Bone;
  96126. poleTargetLocalOffset?: Vector3;
  96127. poleAngle?: number;
  96128. bendAxis?: Vector3;
  96129. maxAngle?: number;
  96130. slerpAmount?: number;
  96131. });
  96132. private _setMaxAngle;
  96133. /**
  96134. * Force the controller to update the bones
  96135. */
  96136. update(): void;
  96137. }
  96138. }
  96139. declare module BABYLON {
  96140. /**
  96141. * Class used to make a bone look toward a point in space
  96142. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  96143. */
  96144. export class BoneLookController {
  96145. private static _tmpVecs;
  96146. private static _tmpQuat;
  96147. private static _tmpMats;
  96148. /**
  96149. * The target Vector3 that the bone will look at
  96150. */
  96151. target: Vector3;
  96152. /**
  96153. * The mesh that the bone is attached to
  96154. */
  96155. mesh: AbstractMesh;
  96156. /**
  96157. * The bone that will be looking to the target
  96158. */
  96159. bone: Bone;
  96160. /**
  96161. * The up axis of the coordinate system that is used when the bone is rotated
  96162. */
  96163. upAxis: Vector3;
  96164. /**
  96165. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  96166. */
  96167. upAxisSpace: Space;
  96168. /**
  96169. * Used to make an adjustment to the yaw of the bone
  96170. */
  96171. adjustYaw: number;
  96172. /**
  96173. * Used to make an adjustment to the pitch of the bone
  96174. */
  96175. adjustPitch: number;
  96176. /**
  96177. * Used to make an adjustment to the roll of the bone
  96178. */
  96179. adjustRoll: number;
  96180. /**
  96181. * 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)
  96182. */
  96183. slerpAmount: number;
  96184. private _minYaw;
  96185. private _maxYaw;
  96186. private _minPitch;
  96187. private _maxPitch;
  96188. private _minYawSin;
  96189. private _minYawCos;
  96190. private _maxYawSin;
  96191. private _maxYawCos;
  96192. private _midYawConstraint;
  96193. private _minPitchTan;
  96194. private _maxPitchTan;
  96195. private _boneQuat;
  96196. private _slerping;
  96197. private _transformYawPitch;
  96198. private _transformYawPitchInv;
  96199. private _firstFrameSkipped;
  96200. private _yawRange;
  96201. private _fowardAxis;
  96202. /**
  96203. * Gets or sets the minimum yaw angle that the bone can look to
  96204. */
  96205. minYaw: number;
  96206. /**
  96207. * Gets or sets the maximum yaw angle that the bone can look to
  96208. */
  96209. maxYaw: number;
  96210. /**
  96211. * Gets or sets the minimum pitch angle that the bone can look to
  96212. */
  96213. minPitch: number;
  96214. /**
  96215. * Gets or sets the maximum pitch angle that the bone can look to
  96216. */
  96217. maxPitch: number;
  96218. /**
  96219. * Create a BoneLookController
  96220. * @param mesh the mesh that the bone belongs to
  96221. * @param bone the bone that will be looking to the target
  96222. * @param target the target Vector3 to look at
  96223. * @param options optional settings:
  96224. * * maxYaw: the maximum angle the bone will yaw to
  96225. * * minYaw: the minimum angle the bone will yaw to
  96226. * * maxPitch: the maximum angle the bone will pitch to
  96227. * * minPitch: the minimum angle the bone will yaw to
  96228. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96229. * * upAxis: the up axis of the coordinate system
  96230. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96231. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96232. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96233. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96234. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96235. * * adjustRoll: used to make an adjustment to the roll of the bone
  96236. **/
  96237. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96238. maxYaw?: number;
  96239. minYaw?: number;
  96240. maxPitch?: number;
  96241. minPitch?: number;
  96242. slerpAmount?: number;
  96243. upAxis?: Vector3;
  96244. upAxisSpace?: Space;
  96245. yawAxis?: Vector3;
  96246. pitchAxis?: Vector3;
  96247. adjustYaw?: number;
  96248. adjustPitch?: number;
  96249. adjustRoll?: number;
  96250. });
  96251. /**
  96252. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96253. */
  96254. update(): void;
  96255. private _getAngleDiff;
  96256. private _getAngleBetween;
  96257. private _isAngleBetween;
  96258. }
  96259. }
  96260. declare module BABYLON {
  96261. /**
  96262. * Manage the gamepad inputs to control an arc rotate camera.
  96263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96264. */
  96265. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96266. /**
  96267. * Defines the camera the input is attached to.
  96268. */
  96269. camera: ArcRotateCamera;
  96270. /**
  96271. * Defines the gamepad the input is gathering event from.
  96272. */
  96273. gamepad: Nullable<Gamepad>;
  96274. /**
  96275. * Defines the gamepad rotation sensiblity.
  96276. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96277. */
  96278. gamepadRotationSensibility: number;
  96279. /**
  96280. * Defines the gamepad move sensiblity.
  96281. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96282. */
  96283. gamepadMoveSensibility: number;
  96284. private _onGamepadConnectedObserver;
  96285. private _onGamepadDisconnectedObserver;
  96286. /**
  96287. * Attach the input controls to a specific dom element to get the input from.
  96288. * @param element Defines the element the controls should be listened from
  96289. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96290. */
  96291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96292. /**
  96293. * Detach the current controls from the specified dom element.
  96294. * @param element Defines the element to stop listening the inputs from
  96295. */
  96296. detachControl(element: Nullable<HTMLElement>): void;
  96297. /**
  96298. * Update the current camera state depending on the inputs that have been used this frame.
  96299. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96300. */
  96301. checkInputs(): void;
  96302. /**
  96303. * Gets the class name of the current intput.
  96304. * @returns the class name
  96305. */
  96306. getClassName(): string;
  96307. /**
  96308. * Get the friendly name associated with the input class.
  96309. * @returns the input friendly name
  96310. */
  96311. getSimpleName(): string;
  96312. }
  96313. }
  96314. declare module BABYLON {
  96315. interface ArcRotateCameraInputsManager {
  96316. /**
  96317. * Add orientation input support to the input manager.
  96318. * @returns the current input manager
  96319. */
  96320. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96321. }
  96322. /**
  96323. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96325. */
  96326. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96327. /**
  96328. * Defines the camera the input is attached to.
  96329. */
  96330. camera: ArcRotateCamera;
  96331. /**
  96332. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96333. */
  96334. alphaCorrection: number;
  96335. /**
  96336. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96337. */
  96338. gammaCorrection: number;
  96339. private _alpha;
  96340. private _gamma;
  96341. private _dirty;
  96342. private _deviceOrientationHandler;
  96343. /**
  96344. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96345. */
  96346. constructor();
  96347. /**
  96348. * Attach the input controls to a specific dom element to get the input from.
  96349. * @param element Defines the element the controls should be listened from
  96350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96351. */
  96352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96353. /** @hidden */
  96354. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96355. /**
  96356. * Update the current camera state depending on the inputs that have been used this frame.
  96357. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96358. */
  96359. checkInputs(): void;
  96360. /**
  96361. * Detach the current controls from the specified dom element.
  96362. * @param element Defines the element to stop listening the inputs from
  96363. */
  96364. detachControl(element: Nullable<HTMLElement>): void;
  96365. /**
  96366. * Gets the class name of the current intput.
  96367. * @returns the class name
  96368. */
  96369. getClassName(): string;
  96370. /**
  96371. * Get the friendly name associated with the input class.
  96372. * @returns the input friendly name
  96373. */
  96374. getSimpleName(): string;
  96375. }
  96376. }
  96377. declare module BABYLON {
  96378. /**
  96379. * Listen to mouse events to control the camera.
  96380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96381. */
  96382. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96383. /**
  96384. * Defines the camera the input is attached to.
  96385. */
  96386. camera: FlyCamera;
  96387. /**
  96388. * Defines if touch is enabled. (Default is true.)
  96389. */
  96390. touchEnabled: boolean;
  96391. /**
  96392. * Defines the buttons associated with the input to handle camera rotation.
  96393. */
  96394. buttons: number[];
  96395. /**
  96396. * Assign buttons for Yaw control.
  96397. */
  96398. buttonsYaw: number[];
  96399. /**
  96400. * Assign buttons for Pitch control.
  96401. */
  96402. buttonsPitch: number[];
  96403. /**
  96404. * Assign buttons for Roll control.
  96405. */
  96406. buttonsRoll: number[];
  96407. /**
  96408. * Detect if any button is being pressed while mouse is moved.
  96409. * -1 = Mouse locked.
  96410. * 0 = Left button.
  96411. * 1 = Middle Button.
  96412. * 2 = Right Button.
  96413. */
  96414. activeButton: number;
  96415. /**
  96416. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96417. * Higher values reduce its sensitivity.
  96418. */
  96419. angularSensibility: number;
  96420. private _mousemoveCallback;
  96421. private _observer;
  96422. private _rollObserver;
  96423. private previousPosition;
  96424. private noPreventDefault;
  96425. private element;
  96426. /**
  96427. * Listen to mouse events to control the camera.
  96428. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96430. */
  96431. constructor(touchEnabled?: boolean);
  96432. /**
  96433. * Attach the mouse control to the HTML DOM element.
  96434. * @param element Defines the element that listens to the input events.
  96435. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96436. */
  96437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96438. /**
  96439. * Detach the current controls from the specified dom element.
  96440. * @param element Defines the element to stop listening the inputs from
  96441. */
  96442. detachControl(element: Nullable<HTMLElement>): void;
  96443. /**
  96444. * Gets the class name of the current input.
  96445. * @returns the class name.
  96446. */
  96447. getClassName(): string;
  96448. /**
  96449. * Get the friendly name associated with the input class.
  96450. * @returns the input's friendly name.
  96451. */
  96452. getSimpleName(): string;
  96453. private _pointerInput;
  96454. private _onMouseMove;
  96455. /**
  96456. * Rotate camera by mouse offset.
  96457. */
  96458. private rotateCamera;
  96459. }
  96460. }
  96461. declare module BABYLON {
  96462. /**
  96463. * Default Inputs manager for the FlyCamera.
  96464. * It groups all the default supported inputs for ease of use.
  96465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96466. */
  96467. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96468. /**
  96469. * Instantiates a new FlyCameraInputsManager.
  96470. * @param camera Defines the camera the inputs belong to.
  96471. */
  96472. constructor(camera: FlyCamera);
  96473. /**
  96474. * Add keyboard input support to the input manager.
  96475. * @returns the new FlyCameraKeyboardMoveInput().
  96476. */
  96477. addKeyboard(): FlyCameraInputsManager;
  96478. /**
  96479. * Add mouse input support to the input manager.
  96480. * @param touchEnabled Enable touch screen support.
  96481. * @returns the new FlyCameraMouseInput().
  96482. */
  96483. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96484. }
  96485. }
  96486. declare module BABYLON {
  96487. /**
  96488. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96489. * such as in a 3D Space Shooter or a Flight Simulator.
  96490. */
  96491. export class FlyCamera extends TargetCamera {
  96492. /**
  96493. * Define the collision ellipsoid of the camera.
  96494. * This is helpful for simulating a camera body, like a player's body.
  96495. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96496. */
  96497. ellipsoid: Vector3;
  96498. /**
  96499. * Define an offset for the position of the ellipsoid around the camera.
  96500. * This can be helpful if the camera is attached away from the player's body center,
  96501. * such as at its head.
  96502. */
  96503. ellipsoidOffset: Vector3;
  96504. /**
  96505. * Enable or disable collisions of the camera with the rest of the scene objects.
  96506. */
  96507. checkCollisions: boolean;
  96508. /**
  96509. * Enable or disable gravity on the camera.
  96510. */
  96511. applyGravity: boolean;
  96512. /**
  96513. * Define the current direction the camera is moving to.
  96514. */
  96515. cameraDirection: Vector3;
  96516. /**
  96517. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96518. * This overrides and empties cameraRotation.
  96519. */
  96520. rotationQuaternion: Quaternion;
  96521. /**
  96522. * Track Roll to maintain the wanted Rolling when looking around.
  96523. */
  96524. _trackRoll: number;
  96525. /**
  96526. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96527. */
  96528. rollCorrect: number;
  96529. /**
  96530. * Mimic a banked turn, Rolling the camera when Yawing.
  96531. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96532. */
  96533. bankedTurn: boolean;
  96534. /**
  96535. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96536. */
  96537. bankedTurnLimit: number;
  96538. /**
  96539. * Value of 0 disables the banked Roll.
  96540. * Value of 1 is equal to the Yaw angle in radians.
  96541. */
  96542. bankedTurnMultiplier: number;
  96543. /**
  96544. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96545. */
  96546. inputs: FlyCameraInputsManager;
  96547. /**
  96548. * Gets the input sensibility for mouse input.
  96549. * Higher values reduce sensitivity.
  96550. */
  96551. /**
  96552. * Sets the input sensibility for a mouse input.
  96553. * Higher values reduce sensitivity.
  96554. */
  96555. angularSensibility: number;
  96556. /**
  96557. * Get the keys for camera movement forward.
  96558. */
  96559. /**
  96560. * Set the keys for camera movement forward.
  96561. */
  96562. keysForward: number[];
  96563. /**
  96564. * Get the keys for camera movement backward.
  96565. */
  96566. keysBackward: number[];
  96567. /**
  96568. * Get the keys for camera movement up.
  96569. */
  96570. /**
  96571. * Set the keys for camera movement up.
  96572. */
  96573. keysUp: number[];
  96574. /**
  96575. * Get the keys for camera movement down.
  96576. */
  96577. /**
  96578. * Set the keys for camera movement down.
  96579. */
  96580. keysDown: number[];
  96581. /**
  96582. * Get the keys for camera movement left.
  96583. */
  96584. /**
  96585. * Set the keys for camera movement left.
  96586. */
  96587. keysLeft: number[];
  96588. /**
  96589. * Set the keys for camera movement right.
  96590. */
  96591. /**
  96592. * Set the keys for camera movement right.
  96593. */
  96594. keysRight: number[];
  96595. /**
  96596. * Event raised when the camera collides with a mesh in the scene.
  96597. */
  96598. onCollide: (collidedMesh: AbstractMesh) => void;
  96599. private _collider;
  96600. private _needMoveForGravity;
  96601. private _oldPosition;
  96602. private _diffPosition;
  96603. private _newPosition;
  96604. /** @hidden */
  96605. _localDirection: Vector3;
  96606. /** @hidden */
  96607. _transformedDirection: Vector3;
  96608. /**
  96609. * Instantiates a FlyCamera.
  96610. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96611. * such as in a 3D Space Shooter or a Flight Simulator.
  96612. * @param name Define the name of the camera in the scene.
  96613. * @param position Define the starting position of the camera in the scene.
  96614. * @param scene Define the scene the camera belongs to.
  96615. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96616. */
  96617. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96618. /**
  96619. * Attach a control to the HTML DOM element.
  96620. * @param element Defines the element that listens to the input events.
  96621. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96622. */
  96623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96624. /**
  96625. * Detach a control from the HTML DOM element.
  96626. * The camera will stop reacting to that input.
  96627. * @param element Defines the element that listens to the input events.
  96628. */
  96629. detachControl(element: HTMLElement): void;
  96630. private _collisionMask;
  96631. /**
  96632. * Get the mask that the camera ignores in collision events.
  96633. */
  96634. /**
  96635. * Set the mask that the camera ignores in collision events.
  96636. */
  96637. collisionMask: number;
  96638. /** @hidden */
  96639. _collideWithWorld(displacement: Vector3): void;
  96640. /** @hidden */
  96641. private _onCollisionPositionChange;
  96642. /** @hidden */
  96643. _checkInputs(): void;
  96644. /** @hidden */
  96645. _decideIfNeedsToMove(): boolean;
  96646. /** @hidden */
  96647. _updatePosition(): void;
  96648. /**
  96649. * Restore the Roll to its target value at the rate specified.
  96650. * @param rate - Higher means slower restoring.
  96651. * @hidden
  96652. */
  96653. restoreRoll(rate: number): void;
  96654. /**
  96655. * Destroy the camera and release the current resources held by it.
  96656. */
  96657. dispose(): void;
  96658. /**
  96659. * Get the current object class name.
  96660. * @returns the class name.
  96661. */
  96662. getClassName(): string;
  96663. }
  96664. }
  96665. declare module BABYLON {
  96666. /**
  96667. * Listen to keyboard events to control the camera.
  96668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96669. */
  96670. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96671. /**
  96672. * Defines the camera the input is attached to.
  96673. */
  96674. camera: FlyCamera;
  96675. /**
  96676. * The list of keyboard keys used to control the forward move of the camera.
  96677. */
  96678. keysForward: number[];
  96679. /**
  96680. * The list of keyboard keys used to control the backward move of the camera.
  96681. */
  96682. keysBackward: number[];
  96683. /**
  96684. * The list of keyboard keys used to control the forward move of the camera.
  96685. */
  96686. keysUp: number[];
  96687. /**
  96688. * The list of keyboard keys used to control the backward move of the camera.
  96689. */
  96690. keysDown: number[];
  96691. /**
  96692. * The list of keyboard keys used to control the right strafe move of the camera.
  96693. */
  96694. keysRight: number[];
  96695. /**
  96696. * The list of keyboard keys used to control the left strafe move of the camera.
  96697. */
  96698. keysLeft: number[];
  96699. private _keys;
  96700. private _onCanvasBlurObserver;
  96701. private _onKeyboardObserver;
  96702. private _engine;
  96703. private _scene;
  96704. /**
  96705. * Attach the input controls to a specific dom element to get the input from.
  96706. * @param element Defines the element the controls should be listened from
  96707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96708. */
  96709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96710. /**
  96711. * Detach the current controls from the specified dom element.
  96712. * @param element Defines the element to stop listening the inputs from
  96713. */
  96714. detachControl(element: Nullable<HTMLElement>): void;
  96715. /**
  96716. * Gets the class name of the current intput.
  96717. * @returns the class name
  96718. */
  96719. getClassName(): string;
  96720. /** @hidden */
  96721. _onLostFocus(e: FocusEvent): void;
  96722. /**
  96723. * Get the friendly name associated with the input class.
  96724. * @returns the input friendly name
  96725. */
  96726. getSimpleName(): string;
  96727. /**
  96728. * Update the current camera state depending on the inputs that have been used this frame.
  96729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96730. */
  96731. checkInputs(): void;
  96732. }
  96733. }
  96734. declare module BABYLON {
  96735. /**
  96736. * Manage the mouse wheel inputs to control a follow camera.
  96737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96738. */
  96739. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96740. /**
  96741. * Defines the camera the input is attached to.
  96742. */
  96743. camera: FollowCamera;
  96744. /**
  96745. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96746. */
  96747. axisControlRadius: boolean;
  96748. /**
  96749. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96750. */
  96751. axisControlHeight: boolean;
  96752. /**
  96753. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96754. */
  96755. axisControlRotation: boolean;
  96756. /**
  96757. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96758. * relation to mouseWheel events.
  96759. */
  96760. wheelPrecision: number;
  96761. /**
  96762. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96763. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96764. */
  96765. wheelDeltaPercentage: number;
  96766. private _wheel;
  96767. private _observer;
  96768. /**
  96769. * Attach the input controls to a specific dom element to get the input from.
  96770. * @param element Defines the element the controls should be listened from
  96771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96772. */
  96773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96774. /**
  96775. * Detach the current controls from the specified dom element.
  96776. * @param element Defines the element to stop listening the inputs from
  96777. */
  96778. detachControl(element: Nullable<HTMLElement>): void;
  96779. /**
  96780. * Gets the class name of the current intput.
  96781. * @returns the class name
  96782. */
  96783. getClassName(): string;
  96784. /**
  96785. * Get the friendly name associated with the input class.
  96786. * @returns the input friendly name
  96787. */
  96788. getSimpleName(): string;
  96789. }
  96790. }
  96791. declare module BABYLON {
  96792. /**
  96793. * Manage the pointers inputs to control an follow camera.
  96794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96795. */
  96796. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96797. /**
  96798. * Defines the camera the input is attached to.
  96799. */
  96800. camera: FollowCamera;
  96801. /**
  96802. * Gets the class name of the current input.
  96803. * @returns the class name
  96804. */
  96805. getClassName(): string;
  96806. /**
  96807. * Defines the pointer angular sensibility along the X axis or how fast is
  96808. * the camera rotating.
  96809. * A negative number will reverse the axis direction.
  96810. */
  96811. angularSensibilityX: number;
  96812. /**
  96813. * Defines the pointer angular sensibility along the Y axis or how fast is
  96814. * the camera rotating.
  96815. * A negative number will reverse the axis direction.
  96816. */
  96817. angularSensibilityY: number;
  96818. /**
  96819. * Defines the pointer pinch precision or how fast is the camera zooming.
  96820. * A negative number will reverse the axis direction.
  96821. */
  96822. pinchPrecision: number;
  96823. /**
  96824. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96825. * from 0.
  96826. * It defines the percentage of current camera.radius to use as delta when
  96827. * pinch zoom is used.
  96828. */
  96829. pinchDeltaPercentage: number;
  96830. /**
  96831. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96832. */
  96833. axisXControlRadius: boolean;
  96834. /**
  96835. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96836. */
  96837. axisXControlHeight: boolean;
  96838. /**
  96839. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96840. */
  96841. axisXControlRotation: boolean;
  96842. /**
  96843. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96844. */
  96845. axisYControlRadius: boolean;
  96846. /**
  96847. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96848. */
  96849. axisYControlHeight: boolean;
  96850. /**
  96851. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96852. */
  96853. axisYControlRotation: boolean;
  96854. /**
  96855. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96856. */
  96857. axisPinchControlRadius: boolean;
  96858. /**
  96859. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96860. */
  96861. axisPinchControlHeight: boolean;
  96862. /**
  96863. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96864. */
  96865. axisPinchControlRotation: boolean;
  96866. /**
  96867. * Log error messages if basic misconfiguration has occurred.
  96868. */
  96869. warningEnable: boolean;
  96870. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96871. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96872. private _warningCounter;
  96873. private _warning;
  96874. }
  96875. }
  96876. declare module BABYLON {
  96877. /**
  96878. * Default Inputs manager for the FollowCamera.
  96879. * It groups all the default supported inputs for ease of use.
  96880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96881. */
  96882. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96883. /**
  96884. * Instantiates a new FollowCameraInputsManager.
  96885. * @param camera Defines the camera the inputs belong to
  96886. */
  96887. constructor(camera: FollowCamera);
  96888. /**
  96889. * Add keyboard input support to the input manager.
  96890. * @returns the current input manager
  96891. */
  96892. addKeyboard(): FollowCameraInputsManager;
  96893. /**
  96894. * Add mouse wheel input support to the input manager.
  96895. * @returns the current input manager
  96896. */
  96897. addMouseWheel(): FollowCameraInputsManager;
  96898. /**
  96899. * Add pointers input support to the input manager.
  96900. * @returns the current input manager
  96901. */
  96902. addPointers(): FollowCameraInputsManager;
  96903. /**
  96904. * Add orientation input support to the input manager.
  96905. * @returns the current input manager
  96906. */
  96907. addVRDeviceOrientation(): FollowCameraInputsManager;
  96908. }
  96909. }
  96910. declare module BABYLON {
  96911. /**
  96912. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96913. * an arc rotate version arcFollowCamera are available.
  96914. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96915. */
  96916. export class FollowCamera extends TargetCamera {
  96917. /**
  96918. * Distance the follow camera should follow an object at
  96919. */
  96920. radius: number;
  96921. /**
  96922. * Minimum allowed distance of the camera to the axis of rotation
  96923. * (The camera can not get closer).
  96924. * This can help limiting how the Camera is able to move in the scene.
  96925. */
  96926. lowerRadiusLimit: Nullable<number>;
  96927. /**
  96928. * Maximum allowed distance of the camera to the axis of rotation
  96929. * (The camera can not get further).
  96930. * This can help limiting how the Camera is able to move in the scene.
  96931. */
  96932. upperRadiusLimit: Nullable<number>;
  96933. /**
  96934. * Define a rotation offset between the camera and the object it follows
  96935. */
  96936. rotationOffset: number;
  96937. /**
  96938. * Minimum allowed angle to camera position relative to target object.
  96939. * This can help limiting how the Camera is able to move in the scene.
  96940. */
  96941. lowerRotationOffsetLimit: Nullable<number>;
  96942. /**
  96943. * Maximum allowed angle to camera position relative to target object.
  96944. * This can help limiting how the Camera is able to move in the scene.
  96945. */
  96946. upperRotationOffsetLimit: Nullable<number>;
  96947. /**
  96948. * Define a height offset between the camera and the object it follows.
  96949. * It can help following an object from the top (like a car chaing a plane)
  96950. */
  96951. heightOffset: number;
  96952. /**
  96953. * Minimum allowed height of camera position relative to target object.
  96954. * This can help limiting how the Camera is able to move in the scene.
  96955. */
  96956. lowerHeightOffsetLimit: Nullable<number>;
  96957. /**
  96958. * Maximum allowed height of camera position relative to target object.
  96959. * This can help limiting how the Camera is able to move in the scene.
  96960. */
  96961. upperHeightOffsetLimit: Nullable<number>;
  96962. /**
  96963. * Define how fast the camera can accelerate to follow it s target.
  96964. */
  96965. cameraAcceleration: number;
  96966. /**
  96967. * Define the speed limit of the camera following an object.
  96968. */
  96969. maxCameraSpeed: number;
  96970. /**
  96971. * Define the target of the camera.
  96972. */
  96973. lockedTarget: Nullable<AbstractMesh>;
  96974. /**
  96975. * Defines the input associated with the camera.
  96976. */
  96977. inputs: FollowCameraInputsManager;
  96978. /**
  96979. * Instantiates the follow camera.
  96980. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96981. * @param name Define the name of the camera in the scene
  96982. * @param position Define the position of the camera
  96983. * @param scene Define the scene the camera belong to
  96984. * @param lockedTarget Define the target of the camera
  96985. */
  96986. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96987. private _follow;
  96988. /**
  96989. * Attached controls to the current camera.
  96990. * @param element Defines the element the controls should be listened from
  96991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96992. */
  96993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96994. /**
  96995. * Detach the current controls from the camera.
  96996. * The camera will stop reacting to inputs.
  96997. * @param element Defines the element to stop listening the inputs from
  96998. */
  96999. detachControl(element: HTMLElement): void;
  97000. /** @hidden */
  97001. _checkInputs(): void;
  97002. private _checkLimits;
  97003. /**
  97004. * Gets the camera class name.
  97005. * @returns the class name
  97006. */
  97007. getClassName(): string;
  97008. }
  97009. /**
  97010. * Arc Rotate version of the follow camera.
  97011. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  97012. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  97013. */
  97014. export class ArcFollowCamera extends TargetCamera {
  97015. /** The longitudinal angle of the camera */
  97016. alpha: number;
  97017. /** The latitudinal angle of the camera */
  97018. beta: number;
  97019. /** The radius of the camera from its target */
  97020. radius: number;
  97021. /** Define the camera target (the messh it should follow) */
  97022. target: Nullable<AbstractMesh>;
  97023. private _cartesianCoordinates;
  97024. /**
  97025. * Instantiates a new ArcFollowCamera
  97026. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  97027. * @param name Define the name of the camera
  97028. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  97029. * @param beta Define the rotation angle of the camera around the elevation axis
  97030. * @param radius Define the radius of the camera from its target point
  97031. * @param target Define the target of the camera
  97032. * @param scene Define the scene the camera belongs to
  97033. */
  97034. constructor(name: string,
  97035. /** The longitudinal angle of the camera */
  97036. alpha: number,
  97037. /** The latitudinal angle of the camera */
  97038. beta: number,
  97039. /** The radius of the camera from its target */
  97040. radius: number,
  97041. /** Define the camera target (the messh it should follow) */
  97042. target: Nullable<AbstractMesh>, scene: Scene);
  97043. private _follow;
  97044. /** @hidden */
  97045. _checkInputs(): void;
  97046. /**
  97047. * Returns the class name of the object.
  97048. * It is mostly used internally for serialization purposes.
  97049. */
  97050. getClassName(): string;
  97051. }
  97052. }
  97053. declare module BABYLON {
  97054. /**
  97055. * Manage the keyboard inputs to control the movement of a follow camera.
  97056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97057. */
  97058. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  97059. /**
  97060. * Defines the camera the input is attached to.
  97061. */
  97062. camera: FollowCamera;
  97063. /**
  97064. * Defines the list of key codes associated with the up action (increase heightOffset)
  97065. */
  97066. keysHeightOffsetIncr: number[];
  97067. /**
  97068. * Defines the list of key codes associated with the down action (decrease heightOffset)
  97069. */
  97070. keysHeightOffsetDecr: number[];
  97071. /**
  97072. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  97073. */
  97074. keysHeightOffsetModifierAlt: boolean;
  97075. /**
  97076. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  97077. */
  97078. keysHeightOffsetModifierCtrl: boolean;
  97079. /**
  97080. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  97081. */
  97082. keysHeightOffsetModifierShift: boolean;
  97083. /**
  97084. * Defines the list of key codes associated with the left action (increase rotationOffset)
  97085. */
  97086. keysRotationOffsetIncr: number[];
  97087. /**
  97088. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  97089. */
  97090. keysRotationOffsetDecr: number[];
  97091. /**
  97092. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  97093. */
  97094. keysRotationOffsetModifierAlt: boolean;
  97095. /**
  97096. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  97097. */
  97098. keysRotationOffsetModifierCtrl: boolean;
  97099. /**
  97100. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  97101. */
  97102. keysRotationOffsetModifierShift: boolean;
  97103. /**
  97104. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  97105. */
  97106. keysRadiusIncr: number[];
  97107. /**
  97108. * Defines the list of key codes associated with the zoom-out action (increase radius)
  97109. */
  97110. keysRadiusDecr: number[];
  97111. /**
  97112. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  97113. */
  97114. keysRadiusModifierAlt: boolean;
  97115. /**
  97116. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  97117. */
  97118. keysRadiusModifierCtrl: boolean;
  97119. /**
  97120. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  97121. */
  97122. keysRadiusModifierShift: boolean;
  97123. /**
  97124. * Defines the rate of change of heightOffset.
  97125. */
  97126. heightSensibility: number;
  97127. /**
  97128. * Defines the rate of change of rotationOffset.
  97129. */
  97130. rotationSensibility: number;
  97131. /**
  97132. * Defines the rate of change of radius.
  97133. */
  97134. radiusSensibility: number;
  97135. private _keys;
  97136. private _ctrlPressed;
  97137. private _altPressed;
  97138. private _shiftPressed;
  97139. private _onCanvasBlurObserver;
  97140. private _onKeyboardObserver;
  97141. private _engine;
  97142. private _scene;
  97143. /**
  97144. * Attach the input controls to a specific dom element to get the input from.
  97145. * @param element Defines the element the controls should be listened from
  97146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97147. */
  97148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97149. /**
  97150. * Detach the current controls from the specified dom element.
  97151. * @param element Defines the element to stop listening the inputs from
  97152. */
  97153. detachControl(element: Nullable<HTMLElement>): void;
  97154. /**
  97155. * Update the current camera state depending on the inputs that have been used this frame.
  97156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97157. */
  97158. checkInputs(): void;
  97159. /**
  97160. * Gets the class name of the current input.
  97161. * @returns the class name
  97162. */
  97163. getClassName(): string;
  97164. /**
  97165. * Get the friendly name associated with the input class.
  97166. * @returns the input friendly name
  97167. */
  97168. getSimpleName(): string;
  97169. /**
  97170. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97171. * allow modification of the heightOffset value.
  97172. */
  97173. private _modifierHeightOffset;
  97174. /**
  97175. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97176. * allow modification of the rotationOffset value.
  97177. */
  97178. private _modifierRotationOffset;
  97179. /**
  97180. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97181. * allow modification of the radius value.
  97182. */
  97183. private _modifierRadius;
  97184. }
  97185. }
  97186. declare module BABYLON {
  97187. interface FreeCameraInputsManager {
  97188. /**
  97189. * @hidden
  97190. */
  97191. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97192. /**
  97193. * Add orientation input support to the input manager.
  97194. * @returns the current input manager
  97195. */
  97196. addDeviceOrientation(): FreeCameraInputsManager;
  97197. }
  97198. /**
  97199. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97200. * Screen rotation is taken into account.
  97201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97202. */
  97203. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97204. private _camera;
  97205. private _screenOrientationAngle;
  97206. private _constantTranform;
  97207. private _screenQuaternion;
  97208. private _alpha;
  97209. private _beta;
  97210. private _gamma;
  97211. /**
  97212. * @hidden
  97213. */
  97214. _onDeviceOrientationChangedObservable: Observable<void>;
  97215. /**
  97216. * Instantiates a new input
  97217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97218. */
  97219. constructor();
  97220. /**
  97221. * Define the camera controlled by the input.
  97222. */
  97223. camera: FreeCamera;
  97224. /**
  97225. * Attach the input controls to a specific dom element to get the input from.
  97226. * @param element Defines the element the controls should be listened from
  97227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97228. */
  97229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97230. private _orientationChanged;
  97231. private _deviceOrientation;
  97232. /**
  97233. * Detach the current controls from the specified dom element.
  97234. * @param element Defines the element to stop listening the inputs from
  97235. */
  97236. detachControl(element: Nullable<HTMLElement>): void;
  97237. /**
  97238. * Update the current camera state depending on the inputs that have been used this frame.
  97239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97240. */
  97241. checkInputs(): void;
  97242. /**
  97243. * Gets the class name of the current intput.
  97244. * @returns the class name
  97245. */
  97246. getClassName(): string;
  97247. /**
  97248. * Get the friendly name associated with the input class.
  97249. * @returns the input friendly name
  97250. */
  97251. getSimpleName(): string;
  97252. }
  97253. }
  97254. declare module BABYLON {
  97255. /**
  97256. * Manage the gamepad inputs to control a free camera.
  97257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97258. */
  97259. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97260. /**
  97261. * Define the camera the input is attached to.
  97262. */
  97263. camera: FreeCamera;
  97264. /**
  97265. * Define the Gamepad controlling the input
  97266. */
  97267. gamepad: Nullable<Gamepad>;
  97268. /**
  97269. * Defines the gamepad rotation sensiblity.
  97270. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97271. */
  97272. gamepadAngularSensibility: number;
  97273. /**
  97274. * Defines the gamepad move sensiblity.
  97275. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97276. */
  97277. gamepadMoveSensibility: number;
  97278. private _onGamepadConnectedObserver;
  97279. private _onGamepadDisconnectedObserver;
  97280. private _cameraTransform;
  97281. private _deltaTransform;
  97282. private _vector3;
  97283. private _vector2;
  97284. /**
  97285. * Attach the input controls to a specific dom element to get the input from.
  97286. * @param element Defines the element the controls should be listened from
  97287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97288. */
  97289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97290. /**
  97291. * Detach the current controls from the specified dom element.
  97292. * @param element Defines the element to stop listening the inputs from
  97293. */
  97294. detachControl(element: Nullable<HTMLElement>): void;
  97295. /**
  97296. * Update the current camera state depending on the inputs that have been used this frame.
  97297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97298. */
  97299. checkInputs(): void;
  97300. /**
  97301. * Gets the class name of the current intput.
  97302. * @returns the class name
  97303. */
  97304. getClassName(): string;
  97305. /**
  97306. * Get the friendly name associated with the input class.
  97307. * @returns the input friendly name
  97308. */
  97309. getSimpleName(): string;
  97310. }
  97311. }
  97312. declare module BABYLON {
  97313. /**
  97314. * Defines the potential axis of a Joystick
  97315. */
  97316. export enum JoystickAxis {
  97317. /** X axis */
  97318. X = 0,
  97319. /** Y axis */
  97320. Y = 1,
  97321. /** Z axis */
  97322. Z = 2
  97323. }
  97324. /**
  97325. * Class used to define virtual joystick (used in touch mode)
  97326. */
  97327. export class VirtualJoystick {
  97328. /**
  97329. * Gets or sets a boolean indicating that left and right values must be inverted
  97330. */
  97331. reverseLeftRight: boolean;
  97332. /**
  97333. * Gets or sets a boolean indicating that up and down values must be inverted
  97334. */
  97335. reverseUpDown: boolean;
  97336. /**
  97337. * Gets the offset value for the position (ie. the change of the position value)
  97338. */
  97339. deltaPosition: Vector3;
  97340. /**
  97341. * Gets a boolean indicating if the virtual joystick was pressed
  97342. */
  97343. pressed: boolean;
  97344. /**
  97345. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97346. */
  97347. static Canvas: Nullable<HTMLCanvasElement>;
  97348. private static _globalJoystickIndex;
  97349. private static vjCanvasContext;
  97350. private static vjCanvasWidth;
  97351. private static vjCanvasHeight;
  97352. private static halfWidth;
  97353. private _action;
  97354. private _axisTargetedByLeftAndRight;
  97355. private _axisTargetedByUpAndDown;
  97356. private _joystickSensibility;
  97357. private _inversedSensibility;
  97358. private _joystickPointerID;
  97359. private _joystickColor;
  97360. private _joystickPointerPos;
  97361. private _joystickPreviousPointerPos;
  97362. private _joystickPointerStartPos;
  97363. private _deltaJoystickVector;
  97364. private _leftJoystick;
  97365. private _touches;
  97366. private _onPointerDownHandlerRef;
  97367. private _onPointerMoveHandlerRef;
  97368. private _onPointerUpHandlerRef;
  97369. private _onResize;
  97370. /**
  97371. * Creates a new virtual joystick
  97372. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97373. */
  97374. constructor(leftJoystick?: boolean);
  97375. /**
  97376. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97377. * @param newJoystickSensibility defines the new sensibility
  97378. */
  97379. setJoystickSensibility(newJoystickSensibility: number): void;
  97380. private _onPointerDown;
  97381. private _onPointerMove;
  97382. private _onPointerUp;
  97383. /**
  97384. * Change the color of the virtual joystick
  97385. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97386. */
  97387. setJoystickColor(newColor: string): void;
  97388. /**
  97389. * Defines a callback to call when the joystick is touched
  97390. * @param action defines the callback
  97391. */
  97392. setActionOnTouch(action: () => any): void;
  97393. /**
  97394. * Defines which axis you'd like to control for left & right
  97395. * @param axis defines the axis to use
  97396. */
  97397. setAxisForLeftRight(axis: JoystickAxis): void;
  97398. /**
  97399. * Defines which axis you'd like to control for up & down
  97400. * @param axis defines the axis to use
  97401. */
  97402. setAxisForUpDown(axis: JoystickAxis): void;
  97403. private _drawVirtualJoystick;
  97404. /**
  97405. * Release internal HTML canvas
  97406. */
  97407. releaseCanvas(): void;
  97408. }
  97409. }
  97410. declare module BABYLON {
  97411. interface FreeCameraInputsManager {
  97412. /**
  97413. * Add virtual joystick input support to the input manager.
  97414. * @returns the current input manager
  97415. */
  97416. addVirtualJoystick(): FreeCameraInputsManager;
  97417. }
  97418. /**
  97419. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97421. */
  97422. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97423. /**
  97424. * Defines the camera the input is attached to.
  97425. */
  97426. camera: FreeCamera;
  97427. private _leftjoystick;
  97428. private _rightjoystick;
  97429. /**
  97430. * Gets the left stick of the virtual joystick.
  97431. * @returns The virtual Joystick
  97432. */
  97433. getLeftJoystick(): VirtualJoystick;
  97434. /**
  97435. * Gets the right stick of the virtual joystick.
  97436. * @returns The virtual Joystick
  97437. */
  97438. getRightJoystick(): VirtualJoystick;
  97439. /**
  97440. * Update the current camera state depending on the inputs that have been used this frame.
  97441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97442. */
  97443. checkInputs(): void;
  97444. /**
  97445. * Attach the input controls to a specific dom element to get the input from.
  97446. * @param element Defines the element the controls should be listened from
  97447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97448. */
  97449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97450. /**
  97451. * Detach the current controls from the specified dom element.
  97452. * @param element Defines the element to stop listening the inputs from
  97453. */
  97454. detachControl(element: Nullable<HTMLElement>): void;
  97455. /**
  97456. * Gets the class name of the current intput.
  97457. * @returns the class name
  97458. */
  97459. getClassName(): string;
  97460. /**
  97461. * Get the friendly name associated with the input class.
  97462. * @returns the input friendly name
  97463. */
  97464. getSimpleName(): string;
  97465. }
  97466. }
  97467. declare module BABYLON {
  97468. /**
  97469. * This represents a FPS type of camera controlled by touch.
  97470. * This is like a universal camera minus the Gamepad controls.
  97471. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97472. */
  97473. export class TouchCamera extends FreeCamera {
  97474. /**
  97475. * Defines the touch sensibility for rotation.
  97476. * The higher the faster.
  97477. */
  97478. touchAngularSensibility: number;
  97479. /**
  97480. * Defines the touch sensibility for move.
  97481. * The higher the faster.
  97482. */
  97483. touchMoveSensibility: number;
  97484. /**
  97485. * Instantiates a new touch camera.
  97486. * This represents a FPS type of camera controlled by touch.
  97487. * This is like a universal camera minus the Gamepad controls.
  97488. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97489. * @param name Define the name of the camera in the scene
  97490. * @param position Define the start position of the camera in the scene
  97491. * @param scene Define the scene the camera belongs to
  97492. */
  97493. constructor(name: string, position: Vector3, scene: Scene);
  97494. /**
  97495. * Gets the current object class name.
  97496. * @return the class name
  97497. */
  97498. getClassName(): string;
  97499. /** @hidden */
  97500. _setupInputs(): void;
  97501. }
  97502. }
  97503. declare module BABYLON {
  97504. /**
  97505. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97506. * being tilted forward or back and left or right.
  97507. */
  97508. export class DeviceOrientationCamera extends FreeCamera {
  97509. private _initialQuaternion;
  97510. private _quaternionCache;
  97511. private _tmpDragQuaternion;
  97512. /**
  97513. * Creates a new device orientation camera
  97514. * @param name The name of the camera
  97515. * @param position The start position camera
  97516. * @param scene The scene the camera belongs to
  97517. */
  97518. constructor(name: string, position: Vector3, scene: Scene);
  97519. /**
  97520. * @hidden
  97521. * Disabled pointer input on first orientation sensor update (Default: true)
  97522. */
  97523. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97524. private _dragFactor;
  97525. /**
  97526. * Enabled turning on the y axis when the orientation sensor is active
  97527. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97528. */
  97529. enableHorizontalDragging(dragFactor?: number): void;
  97530. /**
  97531. * Gets the current instance class name ("DeviceOrientationCamera").
  97532. * This helps avoiding instanceof at run time.
  97533. * @returns the class name
  97534. */
  97535. getClassName(): string;
  97536. /**
  97537. * @hidden
  97538. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97539. */
  97540. _checkInputs(): void;
  97541. /**
  97542. * Reset the camera to its default orientation on the specified axis only.
  97543. * @param axis The axis to reset
  97544. */
  97545. resetToCurrentRotation(axis?: Axis): void;
  97546. }
  97547. }
  97548. declare module BABYLON {
  97549. /**
  97550. * Defines supported buttons for XBox360 compatible gamepads
  97551. */
  97552. export enum Xbox360Button {
  97553. /** A */
  97554. A = 0,
  97555. /** B */
  97556. B = 1,
  97557. /** X */
  97558. X = 2,
  97559. /** Y */
  97560. Y = 3,
  97561. /** Start */
  97562. Start = 4,
  97563. /** Back */
  97564. Back = 5,
  97565. /** Left button */
  97566. LB = 6,
  97567. /** Right button */
  97568. RB = 7,
  97569. /** Left stick */
  97570. LeftStick = 8,
  97571. /** Right stick */
  97572. RightStick = 9
  97573. }
  97574. /** Defines values for XBox360 DPad */
  97575. export enum Xbox360Dpad {
  97576. /** Up */
  97577. Up = 0,
  97578. /** Down */
  97579. Down = 1,
  97580. /** Left */
  97581. Left = 2,
  97582. /** Right */
  97583. Right = 3
  97584. }
  97585. /**
  97586. * Defines a XBox360 gamepad
  97587. */
  97588. export class Xbox360Pad extends Gamepad {
  97589. private _leftTrigger;
  97590. private _rightTrigger;
  97591. private _onlefttriggerchanged;
  97592. private _onrighttriggerchanged;
  97593. private _onbuttondown;
  97594. private _onbuttonup;
  97595. private _ondpaddown;
  97596. private _ondpadup;
  97597. /** Observable raised when a button is pressed */
  97598. onButtonDownObservable: Observable<Xbox360Button>;
  97599. /** Observable raised when a button is released */
  97600. onButtonUpObservable: Observable<Xbox360Button>;
  97601. /** Observable raised when a pad is pressed */
  97602. onPadDownObservable: Observable<Xbox360Dpad>;
  97603. /** Observable raised when a pad is released */
  97604. onPadUpObservable: Observable<Xbox360Dpad>;
  97605. private _buttonA;
  97606. private _buttonB;
  97607. private _buttonX;
  97608. private _buttonY;
  97609. private _buttonBack;
  97610. private _buttonStart;
  97611. private _buttonLB;
  97612. private _buttonRB;
  97613. private _buttonLeftStick;
  97614. private _buttonRightStick;
  97615. private _dPadUp;
  97616. private _dPadDown;
  97617. private _dPadLeft;
  97618. private _dPadRight;
  97619. private _isXboxOnePad;
  97620. /**
  97621. * Creates a new XBox360 gamepad object
  97622. * @param id defines the id of this gamepad
  97623. * @param index defines its index
  97624. * @param gamepad defines the internal HTML gamepad object
  97625. * @param xboxOne defines if it is a XBox One gamepad
  97626. */
  97627. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97628. /**
  97629. * Defines the callback to call when left trigger is pressed
  97630. * @param callback defines the callback to use
  97631. */
  97632. onlefttriggerchanged(callback: (value: number) => void): void;
  97633. /**
  97634. * Defines the callback to call when right trigger is pressed
  97635. * @param callback defines the callback to use
  97636. */
  97637. onrighttriggerchanged(callback: (value: number) => void): void;
  97638. /**
  97639. * Gets the left trigger value
  97640. */
  97641. /**
  97642. * Sets the left trigger value
  97643. */
  97644. leftTrigger: number;
  97645. /**
  97646. * Gets the right trigger value
  97647. */
  97648. /**
  97649. * Sets the right trigger value
  97650. */
  97651. rightTrigger: number;
  97652. /**
  97653. * Defines the callback to call when a button is pressed
  97654. * @param callback defines the callback to use
  97655. */
  97656. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97657. /**
  97658. * Defines the callback to call when a button is released
  97659. * @param callback defines the callback to use
  97660. */
  97661. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97662. /**
  97663. * Defines the callback to call when a pad is pressed
  97664. * @param callback defines the callback to use
  97665. */
  97666. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97667. /**
  97668. * Defines the callback to call when a pad is released
  97669. * @param callback defines the callback to use
  97670. */
  97671. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97672. private _setButtonValue;
  97673. private _setDPadValue;
  97674. /**
  97675. * Gets the value of the `A` button
  97676. */
  97677. /**
  97678. * Sets the value of the `A` button
  97679. */
  97680. buttonA: number;
  97681. /**
  97682. * Gets the value of the `B` button
  97683. */
  97684. /**
  97685. * Sets the value of the `B` button
  97686. */
  97687. buttonB: number;
  97688. /**
  97689. * Gets the value of the `X` button
  97690. */
  97691. /**
  97692. * Sets the value of the `X` button
  97693. */
  97694. buttonX: number;
  97695. /**
  97696. * Gets the value of the `Y` button
  97697. */
  97698. /**
  97699. * Sets the value of the `Y` button
  97700. */
  97701. buttonY: number;
  97702. /**
  97703. * Gets the value of the `Start` button
  97704. */
  97705. /**
  97706. * Sets the value of the `Start` button
  97707. */
  97708. buttonStart: number;
  97709. /**
  97710. * Gets the value of the `Back` button
  97711. */
  97712. /**
  97713. * Sets the value of the `Back` button
  97714. */
  97715. buttonBack: number;
  97716. /**
  97717. * Gets the value of the `Left` button
  97718. */
  97719. /**
  97720. * Sets the value of the `Left` button
  97721. */
  97722. buttonLB: number;
  97723. /**
  97724. * Gets the value of the `Right` button
  97725. */
  97726. /**
  97727. * Sets the value of the `Right` button
  97728. */
  97729. buttonRB: number;
  97730. /**
  97731. * Gets the value of the Left joystick
  97732. */
  97733. /**
  97734. * Sets the value of the Left joystick
  97735. */
  97736. buttonLeftStick: number;
  97737. /**
  97738. * Gets the value of the Right joystick
  97739. */
  97740. /**
  97741. * Sets the value of the Right joystick
  97742. */
  97743. buttonRightStick: number;
  97744. /**
  97745. * Gets the value of D-pad up
  97746. */
  97747. /**
  97748. * Sets the value of D-pad up
  97749. */
  97750. dPadUp: number;
  97751. /**
  97752. * Gets the value of D-pad down
  97753. */
  97754. /**
  97755. * Sets the value of D-pad down
  97756. */
  97757. dPadDown: number;
  97758. /**
  97759. * Gets the value of D-pad left
  97760. */
  97761. /**
  97762. * Sets the value of D-pad left
  97763. */
  97764. dPadLeft: number;
  97765. /**
  97766. * Gets the value of D-pad right
  97767. */
  97768. /**
  97769. * Sets the value of D-pad right
  97770. */
  97771. dPadRight: number;
  97772. /**
  97773. * Force the gamepad to synchronize with device values
  97774. */
  97775. update(): void;
  97776. /**
  97777. * Disposes the gamepad
  97778. */
  97779. dispose(): void;
  97780. }
  97781. }
  97782. declare module BABYLON {
  97783. /**
  97784. * Manager for handling gamepads
  97785. */
  97786. export class GamepadManager {
  97787. private _scene?;
  97788. private _babylonGamepads;
  97789. private _oneGamepadConnected;
  97790. /** @hidden */
  97791. _isMonitoring: boolean;
  97792. private _gamepadEventSupported;
  97793. private _gamepadSupport;
  97794. /**
  97795. * observable to be triggered when the gamepad controller has been connected
  97796. */
  97797. onGamepadConnectedObservable: Observable<Gamepad>;
  97798. /**
  97799. * observable to be triggered when the gamepad controller has been disconnected
  97800. */
  97801. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97802. private _onGamepadConnectedEvent;
  97803. private _onGamepadDisconnectedEvent;
  97804. /**
  97805. * Initializes the gamepad manager
  97806. * @param _scene BabylonJS scene
  97807. */
  97808. constructor(_scene?: Scene | undefined);
  97809. /**
  97810. * The gamepads in the game pad manager
  97811. */
  97812. readonly gamepads: Gamepad[];
  97813. /**
  97814. * Get the gamepad controllers based on type
  97815. * @param type The type of gamepad controller
  97816. * @returns Nullable gamepad
  97817. */
  97818. getGamepadByType(type?: number): Nullable<Gamepad>;
  97819. /**
  97820. * Disposes the gamepad manager
  97821. */
  97822. dispose(): void;
  97823. private _addNewGamepad;
  97824. private _startMonitoringGamepads;
  97825. private _stopMonitoringGamepads;
  97826. /** @hidden */
  97827. _checkGamepadsStatus(): void;
  97828. private _updateGamepadObjects;
  97829. }
  97830. }
  97831. declare module BABYLON {
  97832. interface Scene {
  97833. /** @hidden */
  97834. _gamepadManager: Nullable<GamepadManager>;
  97835. /**
  97836. * Gets the gamepad manager associated with the scene
  97837. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97838. */
  97839. gamepadManager: GamepadManager;
  97840. }
  97841. /**
  97842. * Interface representing a free camera inputs manager
  97843. */
  97844. interface FreeCameraInputsManager {
  97845. /**
  97846. * Adds gamepad input support to the FreeCameraInputsManager.
  97847. * @returns the FreeCameraInputsManager
  97848. */
  97849. addGamepad(): FreeCameraInputsManager;
  97850. }
  97851. /**
  97852. * Interface representing an arc rotate camera inputs manager
  97853. */
  97854. interface ArcRotateCameraInputsManager {
  97855. /**
  97856. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97857. * @returns the camera inputs manager
  97858. */
  97859. addGamepad(): ArcRotateCameraInputsManager;
  97860. }
  97861. /**
  97862. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97863. */
  97864. export class GamepadSystemSceneComponent implements ISceneComponent {
  97865. /**
  97866. * The component name helpfull to identify the component in the list of scene components.
  97867. */
  97868. readonly name: string;
  97869. /**
  97870. * The scene the component belongs to.
  97871. */
  97872. scene: Scene;
  97873. /**
  97874. * Creates a new instance of the component for the given scene
  97875. * @param scene Defines the scene to register the component in
  97876. */
  97877. constructor(scene: Scene);
  97878. /**
  97879. * Registers the component in a given scene
  97880. */
  97881. register(): void;
  97882. /**
  97883. * Rebuilds the elements related to this component in case of
  97884. * context lost for instance.
  97885. */
  97886. rebuild(): void;
  97887. /**
  97888. * Disposes the component and the associated ressources
  97889. */
  97890. dispose(): void;
  97891. private _beforeCameraUpdate;
  97892. }
  97893. }
  97894. declare module BABYLON {
  97895. /**
  97896. * 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,
  97897. * which still works and will still be found in many Playgrounds.
  97898. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97899. */
  97900. export class UniversalCamera extends TouchCamera {
  97901. /**
  97902. * Defines the gamepad rotation sensiblity.
  97903. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97904. */
  97905. gamepadAngularSensibility: number;
  97906. /**
  97907. * Defines the gamepad move sensiblity.
  97908. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97909. */
  97910. gamepadMoveSensibility: number;
  97911. /**
  97912. * 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,
  97913. * which still works and will still be found in many Playgrounds.
  97914. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97915. * @param name Define the name of the camera in the scene
  97916. * @param position Define the start position of the camera in the scene
  97917. * @param scene Define the scene the camera belongs to
  97918. */
  97919. constructor(name: string, position: Vector3, scene: Scene);
  97920. /**
  97921. * Gets the current object class name.
  97922. * @return the class name
  97923. */
  97924. getClassName(): string;
  97925. }
  97926. }
  97927. declare module BABYLON {
  97928. /**
  97929. * This represents a FPS type of camera. This is only here for back compat purpose.
  97930. * Please use the UniversalCamera instead as both are identical.
  97931. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97932. */
  97933. export class GamepadCamera extends UniversalCamera {
  97934. /**
  97935. * Instantiates a new Gamepad Camera
  97936. * This represents a FPS type of camera. This is only here for back compat purpose.
  97937. * Please use the UniversalCamera instead as both are identical.
  97938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97939. * @param name Define the name of the camera in the scene
  97940. * @param position Define the start position of the camera in the scene
  97941. * @param scene Define the scene the camera belongs to
  97942. */
  97943. constructor(name: string, position: Vector3, scene: Scene);
  97944. /**
  97945. * Gets the current object class name.
  97946. * @return the class name
  97947. */
  97948. getClassName(): string;
  97949. }
  97950. }
  97951. declare module BABYLON {
  97952. /** @hidden */
  97953. export var passPixelShader: {
  97954. name: string;
  97955. shader: string;
  97956. };
  97957. }
  97958. declare module BABYLON {
  97959. /** @hidden */
  97960. export var passCubePixelShader: {
  97961. name: string;
  97962. shader: string;
  97963. };
  97964. }
  97965. declare module BABYLON {
  97966. /**
  97967. * PassPostProcess which produces an output the same as it's input
  97968. */
  97969. export class PassPostProcess extends PostProcess {
  97970. /**
  97971. * Creates the PassPostProcess
  97972. * @param name The name of the effect.
  97973. * @param options The required width/height ratio to downsize to before computing the render pass.
  97974. * @param camera The camera to apply the render pass to.
  97975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97976. * @param engine The engine which the post process will be applied. (default: current engine)
  97977. * @param reusable If the post process can be reused on the same frame. (default: false)
  97978. * @param textureType The type of texture to be used when performing the post processing.
  97979. * @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)
  97980. */
  97981. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97982. }
  97983. /**
  97984. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97985. */
  97986. export class PassCubePostProcess extends PostProcess {
  97987. private _face;
  97988. /**
  97989. * Gets or sets the cube face to display.
  97990. * * 0 is +X
  97991. * * 1 is -X
  97992. * * 2 is +Y
  97993. * * 3 is -Y
  97994. * * 4 is +Z
  97995. * * 5 is -Z
  97996. */
  97997. face: number;
  97998. /**
  97999. * Creates the PassCubePostProcess
  98000. * @param name The name of the effect.
  98001. * @param options The required width/height ratio to downsize to before computing the render pass.
  98002. * @param camera The camera to apply the render pass to.
  98003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  98004. * @param engine The engine which the post process will be applied. (default: current engine)
  98005. * @param reusable If the post process can be reused on the same frame. (default: false)
  98006. * @param textureType The type of texture to be used when performing the post processing.
  98007. * @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)
  98008. */
  98009. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  98010. }
  98011. }
  98012. declare module BABYLON {
  98013. /** @hidden */
  98014. export var anaglyphPixelShader: {
  98015. name: string;
  98016. shader: string;
  98017. };
  98018. }
  98019. declare module BABYLON {
  98020. /**
  98021. * Postprocess used to generate anaglyphic rendering
  98022. */
  98023. export class AnaglyphPostProcess extends PostProcess {
  98024. private _passedProcess;
  98025. /**
  98026. * Creates a new AnaglyphPostProcess
  98027. * @param name defines postprocess name
  98028. * @param options defines creation options or target ratio scale
  98029. * @param rigCameras defines cameras using this postprocess
  98030. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  98031. * @param engine defines hosting engine
  98032. * @param reusable defines if the postprocess will be reused multiple times per frame
  98033. */
  98034. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  98035. }
  98036. }
  98037. declare module BABYLON {
  98038. /**
  98039. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  98040. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  98041. */
  98042. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  98043. /**
  98044. * Creates a new AnaglyphArcRotateCamera
  98045. * @param name defines camera name
  98046. * @param alpha defines alpha angle (in radians)
  98047. * @param beta defines beta angle (in radians)
  98048. * @param radius defines radius
  98049. * @param target defines camera target
  98050. * @param interaxialDistance defines distance between each color axis
  98051. * @param scene defines the hosting scene
  98052. */
  98053. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  98054. /**
  98055. * Gets camera class name
  98056. * @returns AnaglyphArcRotateCamera
  98057. */
  98058. getClassName(): string;
  98059. }
  98060. }
  98061. declare module BABYLON {
  98062. /**
  98063. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  98064. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  98065. */
  98066. export class AnaglyphFreeCamera extends FreeCamera {
  98067. /**
  98068. * Creates a new AnaglyphFreeCamera
  98069. * @param name defines camera name
  98070. * @param position defines initial position
  98071. * @param interaxialDistance defines distance between each color axis
  98072. * @param scene defines the hosting scene
  98073. */
  98074. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  98075. /**
  98076. * Gets camera class name
  98077. * @returns AnaglyphFreeCamera
  98078. */
  98079. getClassName(): string;
  98080. }
  98081. }
  98082. declare module BABYLON {
  98083. /**
  98084. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  98085. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  98086. */
  98087. export class AnaglyphGamepadCamera extends GamepadCamera {
  98088. /**
  98089. * Creates a new AnaglyphGamepadCamera
  98090. * @param name defines camera name
  98091. * @param position defines initial position
  98092. * @param interaxialDistance defines distance between each color axis
  98093. * @param scene defines the hosting scene
  98094. */
  98095. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  98096. /**
  98097. * Gets camera class name
  98098. * @returns AnaglyphGamepadCamera
  98099. */
  98100. getClassName(): string;
  98101. }
  98102. }
  98103. declare module BABYLON {
  98104. /**
  98105. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  98106. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  98107. */
  98108. export class AnaglyphUniversalCamera extends UniversalCamera {
  98109. /**
  98110. * Creates a new AnaglyphUniversalCamera
  98111. * @param name defines camera name
  98112. * @param position defines initial position
  98113. * @param interaxialDistance defines distance between each color axis
  98114. * @param scene defines the hosting scene
  98115. */
  98116. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  98117. /**
  98118. * Gets camera class name
  98119. * @returns AnaglyphUniversalCamera
  98120. */
  98121. getClassName(): string;
  98122. }
  98123. }
  98124. declare module BABYLON {
  98125. /** @hidden */
  98126. export var stereoscopicInterlacePixelShader: {
  98127. name: string;
  98128. shader: string;
  98129. };
  98130. }
  98131. declare module BABYLON {
  98132. /**
  98133. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  98134. */
  98135. export class StereoscopicInterlacePostProcess extends PostProcess {
  98136. private _stepSize;
  98137. private _passedProcess;
  98138. /**
  98139. * Initializes a StereoscopicInterlacePostProcess
  98140. * @param name The name of the effect.
  98141. * @param rigCameras The rig cameras to be appled to the post process
  98142. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  98143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  98144. * @param engine The engine which the post process will be applied. (default: current engine)
  98145. * @param reusable If the post process can be reused on the same frame. (default: false)
  98146. */
  98147. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  98148. }
  98149. }
  98150. declare module BABYLON {
  98151. /**
  98152. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  98153. * @see http://doc.babylonjs.com/features/cameras
  98154. */
  98155. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  98156. /**
  98157. * Creates a new StereoscopicArcRotateCamera
  98158. * @param name defines camera name
  98159. * @param alpha defines alpha angle (in radians)
  98160. * @param beta defines beta angle (in radians)
  98161. * @param radius defines radius
  98162. * @param target defines camera target
  98163. * @param interaxialDistance defines distance between each color axis
  98164. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98165. * @param scene defines the hosting scene
  98166. */
  98167. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98168. /**
  98169. * Gets camera class name
  98170. * @returns StereoscopicArcRotateCamera
  98171. */
  98172. getClassName(): string;
  98173. }
  98174. }
  98175. declare module BABYLON {
  98176. /**
  98177. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  98178. * @see http://doc.babylonjs.com/features/cameras
  98179. */
  98180. export class StereoscopicFreeCamera extends FreeCamera {
  98181. /**
  98182. * Creates a new StereoscopicFreeCamera
  98183. * @param name defines camera name
  98184. * @param position defines initial position
  98185. * @param interaxialDistance defines distance between each color axis
  98186. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98187. * @param scene defines the hosting scene
  98188. */
  98189. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98190. /**
  98191. * Gets camera class name
  98192. * @returns StereoscopicFreeCamera
  98193. */
  98194. getClassName(): string;
  98195. }
  98196. }
  98197. declare module BABYLON {
  98198. /**
  98199. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  98200. * @see http://doc.babylonjs.com/features/cameras
  98201. */
  98202. export class StereoscopicGamepadCamera extends GamepadCamera {
  98203. /**
  98204. * Creates a new StereoscopicGamepadCamera
  98205. * @param name defines camera name
  98206. * @param position defines initial position
  98207. * @param interaxialDistance defines distance between each color axis
  98208. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98209. * @param scene defines the hosting scene
  98210. */
  98211. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98212. /**
  98213. * Gets camera class name
  98214. * @returns StereoscopicGamepadCamera
  98215. */
  98216. getClassName(): string;
  98217. }
  98218. }
  98219. declare module BABYLON {
  98220. /**
  98221. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  98222. * @see http://doc.babylonjs.com/features/cameras
  98223. */
  98224. export class StereoscopicUniversalCamera extends UniversalCamera {
  98225. /**
  98226. * Creates a new StereoscopicUniversalCamera
  98227. * @param name defines camera name
  98228. * @param position defines initial position
  98229. * @param interaxialDistance defines distance between each color axis
  98230. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98231. * @param scene defines the hosting scene
  98232. */
  98233. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98234. /**
  98235. * Gets camera class name
  98236. * @returns StereoscopicUniversalCamera
  98237. */
  98238. getClassName(): string;
  98239. }
  98240. }
  98241. declare module BABYLON {
  98242. /**
  98243. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98244. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  98245. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  98246. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  98247. */
  98248. export class VirtualJoysticksCamera extends FreeCamera {
  98249. /**
  98250. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  98251. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  98252. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  98253. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  98254. * @param name Define the name of the camera in the scene
  98255. * @param position Define the start position of the camera in the scene
  98256. * @param scene Define the scene the camera belongs to
  98257. */
  98258. constructor(name: string, position: Vector3, scene: Scene);
  98259. /**
  98260. * Gets the current object class name.
  98261. * @return the class name
  98262. */
  98263. getClassName(): string;
  98264. }
  98265. }
  98266. declare module BABYLON {
  98267. /**
  98268. * This represents all the required metrics to create a VR camera.
  98269. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  98270. */
  98271. export class VRCameraMetrics {
  98272. /**
  98273. * Define the horizontal resolution off the screen.
  98274. */
  98275. hResolution: number;
  98276. /**
  98277. * Define the vertical resolution off the screen.
  98278. */
  98279. vResolution: number;
  98280. /**
  98281. * Define the horizontal screen size.
  98282. */
  98283. hScreenSize: number;
  98284. /**
  98285. * Define the vertical screen size.
  98286. */
  98287. vScreenSize: number;
  98288. /**
  98289. * Define the vertical screen center position.
  98290. */
  98291. vScreenCenter: number;
  98292. /**
  98293. * Define the distance of the eyes to the screen.
  98294. */
  98295. eyeToScreenDistance: number;
  98296. /**
  98297. * Define the distance between both lenses
  98298. */
  98299. lensSeparationDistance: number;
  98300. /**
  98301. * Define the distance between both viewer's eyes.
  98302. */
  98303. interpupillaryDistance: number;
  98304. /**
  98305. * Define the distortion factor of the VR postprocess.
  98306. * Please, touch with care.
  98307. */
  98308. distortionK: number[];
  98309. /**
  98310. * Define the chromatic aberration correction factors for the VR post process.
  98311. */
  98312. chromaAbCorrection: number[];
  98313. /**
  98314. * Define the scale factor of the post process.
  98315. * The smaller the better but the slower.
  98316. */
  98317. postProcessScaleFactor: number;
  98318. /**
  98319. * Define an offset for the lens center.
  98320. */
  98321. lensCenterOffset: number;
  98322. /**
  98323. * Define if the current vr camera should compensate the distortion of the lense or not.
  98324. */
  98325. compensateDistortion: boolean;
  98326. /**
  98327. * Defines if multiview should be enabled when rendering (Default: false)
  98328. */
  98329. multiviewEnabled: boolean;
  98330. /**
  98331. * Gets the rendering aspect ratio based on the provided resolutions.
  98332. */
  98333. readonly aspectRatio: number;
  98334. /**
  98335. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  98336. */
  98337. readonly aspectRatioFov: number;
  98338. /**
  98339. * @hidden
  98340. */
  98341. readonly leftHMatrix: Matrix;
  98342. /**
  98343. * @hidden
  98344. */
  98345. readonly rightHMatrix: Matrix;
  98346. /**
  98347. * @hidden
  98348. */
  98349. readonly leftPreViewMatrix: Matrix;
  98350. /**
  98351. * @hidden
  98352. */
  98353. readonly rightPreViewMatrix: Matrix;
  98354. /**
  98355. * Get the default VRMetrics based on the most generic setup.
  98356. * @returns the default vr metrics
  98357. */
  98358. static GetDefault(): VRCameraMetrics;
  98359. }
  98360. }
  98361. declare module BABYLON {
  98362. /** @hidden */
  98363. export var vrDistortionCorrectionPixelShader: {
  98364. name: string;
  98365. shader: string;
  98366. };
  98367. }
  98368. declare module BABYLON {
  98369. /**
  98370. * VRDistortionCorrectionPostProcess used for mobile VR
  98371. */
  98372. export class VRDistortionCorrectionPostProcess extends PostProcess {
  98373. private _isRightEye;
  98374. private _distortionFactors;
  98375. private _postProcessScaleFactor;
  98376. private _lensCenterOffset;
  98377. private _scaleIn;
  98378. private _scaleFactor;
  98379. private _lensCenter;
  98380. /**
  98381. * Initializes the VRDistortionCorrectionPostProcess
  98382. * @param name The name of the effect.
  98383. * @param camera The camera to apply the render pass to.
  98384. * @param isRightEye If this is for the right eye distortion
  98385. * @param vrMetrics All the required metrics for the VR camera
  98386. */
  98387. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  98388. }
  98389. }
  98390. declare module BABYLON {
  98391. /**
  98392. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  98393. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98394. */
  98395. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  98396. /**
  98397. * Creates a new VRDeviceOrientationArcRotateCamera
  98398. * @param name defines camera name
  98399. * @param alpha defines the camera rotation along the logitudinal axis
  98400. * @param beta defines the camera rotation along the latitudinal axis
  98401. * @param radius defines the camera distance from its target
  98402. * @param target defines the camera target
  98403. * @param scene defines the scene the camera belongs to
  98404. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98405. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98406. */
  98407. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98408. /**
  98409. * Gets camera class name
  98410. * @returns VRDeviceOrientationArcRotateCamera
  98411. */
  98412. getClassName(): string;
  98413. }
  98414. }
  98415. declare module BABYLON {
  98416. /**
  98417. * Camera used to simulate VR rendering (based on FreeCamera)
  98418. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98419. */
  98420. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  98421. /**
  98422. * Creates a new VRDeviceOrientationFreeCamera
  98423. * @param name defines camera name
  98424. * @param position defines the start position of the camera
  98425. * @param scene defines the scene the camera belongs to
  98426. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98427. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98428. */
  98429. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98430. /**
  98431. * Gets camera class name
  98432. * @returns VRDeviceOrientationFreeCamera
  98433. */
  98434. getClassName(): string;
  98435. }
  98436. }
  98437. declare module BABYLON {
  98438. /**
  98439. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  98440. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98441. */
  98442. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  98443. /**
  98444. * Creates a new VRDeviceOrientationGamepadCamera
  98445. * @param name defines camera name
  98446. * @param position defines the start position of the camera
  98447. * @param scene defines the scene the camera belongs to
  98448. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98449. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98450. */
  98451. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98452. /**
  98453. * Gets camera class name
  98454. * @returns VRDeviceOrientationGamepadCamera
  98455. */
  98456. getClassName(): string;
  98457. }
  98458. }
  98459. declare module BABYLON {
  98460. /**
  98461. * Base class of materials working in push mode in babylon JS
  98462. * @hidden
  98463. */
  98464. export class PushMaterial extends Material {
  98465. protected _activeEffect: Effect;
  98466. protected _normalMatrix: Matrix;
  98467. /**
  98468. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98469. * This means that the material can keep using a previous shader while a new one is being compiled.
  98470. * This is mostly used when shader parallel compilation is supported (true by default)
  98471. */
  98472. allowShaderHotSwapping: boolean;
  98473. constructor(name: string, scene: Scene);
  98474. getEffect(): Effect;
  98475. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98476. /**
  98477. * Binds the given world matrix to the active effect
  98478. *
  98479. * @param world the matrix to bind
  98480. */
  98481. bindOnlyWorldMatrix(world: Matrix): void;
  98482. /**
  98483. * Binds the given normal matrix to the active effect
  98484. *
  98485. * @param normalMatrix the matrix to bind
  98486. */
  98487. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98488. bind(world: Matrix, mesh?: Mesh): void;
  98489. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98490. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98491. }
  98492. }
  98493. declare module BABYLON {
  98494. /**
  98495. * This groups all the flags used to control the materials channel.
  98496. */
  98497. export class MaterialFlags {
  98498. private static _DiffuseTextureEnabled;
  98499. /**
  98500. * Are diffuse textures enabled in the application.
  98501. */
  98502. static DiffuseTextureEnabled: boolean;
  98503. private static _AmbientTextureEnabled;
  98504. /**
  98505. * Are ambient textures enabled in the application.
  98506. */
  98507. static AmbientTextureEnabled: boolean;
  98508. private static _OpacityTextureEnabled;
  98509. /**
  98510. * Are opacity textures enabled in the application.
  98511. */
  98512. static OpacityTextureEnabled: boolean;
  98513. private static _ReflectionTextureEnabled;
  98514. /**
  98515. * Are reflection textures enabled in the application.
  98516. */
  98517. static ReflectionTextureEnabled: boolean;
  98518. private static _EmissiveTextureEnabled;
  98519. /**
  98520. * Are emissive textures enabled in the application.
  98521. */
  98522. static EmissiveTextureEnabled: boolean;
  98523. private static _SpecularTextureEnabled;
  98524. /**
  98525. * Are specular textures enabled in the application.
  98526. */
  98527. static SpecularTextureEnabled: boolean;
  98528. private static _BumpTextureEnabled;
  98529. /**
  98530. * Are bump textures enabled in the application.
  98531. */
  98532. static BumpTextureEnabled: boolean;
  98533. private static _LightmapTextureEnabled;
  98534. /**
  98535. * Are lightmap textures enabled in the application.
  98536. */
  98537. static LightmapTextureEnabled: boolean;
  98538. private static _RefractionTextureEnabled;
  98539. /**
  98540. * Are refraction textures enabled in the application.
  98541. */
  98542. static RefractionTextureEnabled: boolean;
  98543. private static _ColorGradingTextureEnabled;
  98544. /**
  98545. * Are color grading textures enabled in the application.
  98546. */
  98547. static ColorGradingTextureEnabled: boolean;
  98548. private static _FresnelEnabled;
  98549. /**
  98550. * Are fresnels enabled in the application.
  98551. */
  98552. static FresnelEnabled: boolean;
  98553. private static _ClearCoatTextureEnabled;
  98554. /**
  98555. * Are clear coat textures enabled in the application.
  98556. */
  98557. static ClearCoatTextureEnabled: boolean;
  98558. private static _ClearCoatBumpTextureEnabled;
  98559. /**
  98560. * Are clear coat bump textures enabled in the application.
  98561. */
  98562. static ClearCoatBumpTextureEnabled: boolean;
  98563. private static _ClearCoatTintTextureEnabled;
  98564. /**
  98565. * Are clear coat tint textures enabled in the application.
  98566. */
  98567. static ClearCoatTintTextureEnabled: boolean;
  98568. private static _SheenTextureEnabled;
  98569. /**
  98570. * Are sheen textures enabled in the application.
  98571. */
  98572. static SheenTextureEnabled: boolean;
  98573. private static _AnisotropicTextureEnabled;
  98574. /**
  98575. * Are anisotropic textures enabled in the application.
  98576. */
  98577. static AnisotropicTextureEnabled: boolean;
  98578. private static _ThicknessTextureEnabled;
  98579. /**
  98580. * Are thickness textures enabled in the application.
  98581. */
  98582. static ThicknessTextureEnabled: boolean;
  98583. }
  98584. }
  98585. declare module BABYLON {
  98586. /** @hidden */
  98587. export var defaultFragmentDeclaration: {
  98588. name: string;
  98589. shader: string;
  98590. };
  98591. }
  98592. declare module BABYLON {
  98593. /** @hidden */
  98594. export var defaultUboDeclaration: {
  98595. name: string;
  98596. shader: string;
  98597. };
  98598. }
  98599. declare module BABYLON {
  98600. /** @hidden */
  98601. export var lightFragmentDeclaration: {
  98602. name: string;
  98603. shader: string;
  98604. };
  98605. }
  98606. declare module BABYLON {
  98607. /** @hidden */
  98608. export var lightUboDeclaration: {
  98609. name: string;
  98610. shader: string;
  98611. };
  98612. }
  98613. declare module BABYLON {
  98614. /** @hidden */
  98615. export var lightsFragmentFunctions: {
  98616. name: string;
  98617. shader: string;
  98618. };
  98619. }
  98620. declare module BABYLON {
  98621. /** @hidden */
  98622. export var shadowsFragmentFunctions: {
  98623. name: string;
  98624. shader: string;
  98625. };
  98626. }
  98627. declare module BABYLON {
  98628. /** @hidden */
  98629. export var fresnelFunction: {
  98630. name: string;
  98631. shader: string;
  98632. };
  98633. }
  98634. declare module BABYLON {
  98635. /** @hidden */
  98636. export var reflectionFunction: {
  98637. name: string;
  98638. shader: string;
  98639. };
  98640. }
  98641. declare module BABYLON {
  98642. /** @hidden */
  98643. export var bumpFragmentFunctions: {
  98644. name: string;
  98645. shader: string;
  98646. };
  98647. }
  98648. declare module BABYLON {
  98649. /** @hidden */
  98650. export var logDepthDeclaration: {
  98651. name: string;
  98652. shader: string;
  98653. };
  98654. }
  98655. declare module BABYLON {
  98656. /** @hidden */
  98657. export var bumpFragment: {
  98658. name: string;
  98659. shader: string;
  98660. };
  98661. }
  98662. declare module BABYLON {
  98663. /** @hidden */
  98664. export var depthPrePass: {
  98665. name: string;
  98666. shader: string;
  98667. };
  98668. }
  98669. declare module BABYLON {
  98670. /** @hidden */
  98671. export var lightFragment: {
  98672. name: string;
  98673. shader: string;
  98674. };
  98675. }
  98676. declare module BABYLON {
  98677. /** @hidden */
  98678. export var logDepthFragment: {
  98679. name: string;
  98680. shader: string;
  98681. };
  98682. }
  98683. declare module BABYLON {
  98684. /** @hidden */
  98685. export var defaultPixelShader: {
  98686. name: string;
  98687. shader: string;
  98688. };
  98689. }
  98690. declare module BABYLON {
  98691. /** @hidden */
  98692. export var defaultVertexDeclaration: {
  98693. name: string;
  98694. shader: string;
  98695. };
  98696. }
  98697. declare module BABYLON {
  98698. /** @hidden */
  98699. export var bumpVertexDeclaration: {
  98700. name: string;
  98701. shader: string;
  98702. };
  98703. }
  98704. declare module BABYLON {
  98705. /** @hidden */
  98706. export var bumpVertex: {
  98707. name: string;
  98708. shader: string;
  98709. };
  98710. }
  98711. declare module BABYLON {
  98712. /** @hidden */
  98713. export var fogVertex: {
  98714. name: string;
  98715. shader: string;
  98716. };
  98717. }
  98718. declare module BABYLON {
  98719. /** @hidden */
  98720. export var shadowsVertex: {
  98721. name: string;
  98722. shader: string;
  98723. };
  98724. }
  98725. declare module BABYLON {
  98726. /** @hidden */
  98727. export var pointCloudVertex: {
  98728. name: string;
  98729. shader: string;
  98730. };
  98731. }
  98732. declare module BABYLON {
  98733. /** @hidden */
  98734. export var logDepthVertex: {
  98735. name: string;
  98736. shader: string;
  98737. };
  98738. }
  98739. declare module BABYLON {
  98740. /** @hidden */
  98741. export var defaultVertexShader: {
  98742. name: string;
  98743. shader: string;
  98744. };
  98745. }
  98746. declare module BABYLON {
  98747. /** @hidden */
  98748. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98749. MAINUV1: boolean;
  98750. MAINUV2: boolean;
  98751. DIFFUSE: boolean;
  98752. DIFFUSEDIRECTUV: number;
  98753. AMBIENT: boolean;
  98754. AMBIENTDIRECTUV: number;
  98755. OPACITY: boolean;
  98756. OPACITYDIRECTUV: number;
  98757. OPACITYRGB: boolean;
  98758. REFLECTION: boolean;
  98759. EMISSIVE: boolean;
  98760. EMISSIVEDIRECTUV: number;
  98761. SPECULAR: boolean;
  98762. SPECULARDIRECTUV: number;
  98763. BUMP: boolean;
  98764. BUMPDIRECTUV: number;
  98765. PARALLAX: boolean;
  98766. PARALLAXOCCLUSION: boolean;
  98767. SPECULAROVERALPHA: boolean;
  98768. CLIPPLANE: boolean;
  98769. CLIPPLANE2: boolean;
  98770. CLIPPLANE3: boolean;
  98771. CLIPPLANE4: boolean;
  98772. ALPHATEST: boolean;
  98773. DEPTHPREPASS: boolean;
  98774. ALPHAFROMDIFFUSE: boolean;
  98775. POINTSIZE: boolean;
  98776. FOG: boolean;
  98777. SPECULARTERM: boolean;
  98778. DIFFUSEFRESNEL: boolean;
  98779. OPACITYFRESNEL: boolean;
  98780. REFLECTIONFRESNEL: boolean;
  98781. REFRACTIONFRESNEL: boolean;
  98782. EMISSIVEFRESNEL: boolean;
  98783. FRESNEL: boolean;
  98784. NORMAL: boolean;
  98785. UV1: boolean;
  98786. UV2: boolean;
  98787. VERTEXCOLOR: boolean;
  98788. VERTEXALPHA: boolean;
  98789. NUM_BONE_INFLUENCERS: number;
  98790. BonesPerMesh: number;
  98791. BONETEXTURE: boolean;
  98792. INSTANCES: boolean;
  98793. GLOSSINESS: boolean;
  98794. ROUGHNESS: boolean;
  98795. EMISSIVEASILLUMINATION: boolean;
  98796. LINKEMISSIVEWITHDIFFUSE: boolean;
  98797. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98798. LIGHTMAP: boolean;
  98799. LIGHTMAPDIRECTUV: number;
  98800. OBJECTSPACE_NORMALMAP: boolean;
  98801. USELIGHTMAPASSHADOWMAP: boolean;
  98802. REFLECTIONMAP_3D: boolean;
  98803. REFLECTIONMAP_SPHERICAL: boolean;
  98804. REFLECTIONMAP_PLANAR: boolean;
  98805. REFLECTIONMAP_CUBIC: boolean;
  98806. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98807. REFLECTIONMAP_PROJECTION: boolean;
  98808. REFLECTIONMAP_SKYBOX: boolean;
  98809. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98810. REFLECTIONMAP_EXPLICIT: boolean;
  98811. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98812. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98813. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98814. INVERTCUBICMAP: boolean;
  98815. LOGARITHMICDEPTH: boolean;
  98816. REFRACTION: boolean;
  98817. REFRACTIONMAP_3D: boolean;
  98818. REFLECTIONOVERALPHA: boolean;
  98819. TWOSIDEDLIGHTING: boolean;
  98820. SHADOWFLOAT: boolean;
  98821. MORPHTARGETS: boolean;
  98822. MORPHTARGETS_NORMAL: boolean;
  98823. MORPHTARGETS_TANGENT: boolean;
  98824. NUM_MORPH_INFLUENCERS: number;
  98825. NONUNIFORMSCALING: boolean;
  98826. PREMULTIPLYALPHA: boolean;
  98827. IMAGEPROCESSING: boolean;
  98828. VIGNETTE: boolean;
  98829. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98830. VIGNETTEBLENDMODEOPAQUE: boolean;
  98831. TONEMAPPING: boolean;
  98832. TONEMAPPING_ACES: boolean;
  98833. CONTRAST: boolean;
  98834. COLORCURVES: boolean;
  98835. COLORGRADING: boolean;
  98836. COLORGRADING3D: boolean;
  98837. SAMPLER3DGREENDEPTH: boolean;
  98838. SAMPLER3DBGRMAP: boolean;
  98839. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98840. MULTIVIEW: boolean;
  98841. /**
  98842. * If the reflection texture on this material is in linear color space
  98843. * @hidden
  98844. */
  98845. IS_REFLECTION_LINEAR: boolean;
  98846. /**
  98847. * If the refraction texture on this material is in linear color space
  98848. * @hidden
  98849. */
  98850. IS_REFRACTION_LINEAR: boolean;
  98851. EXPOSURE: boolean;
  98852. constructor();
  98853. setReflectionMode(modeToEnable: string): void;
  98854. }
  98855. /**
  98856. * This is the default material used in Babylon. It is the best trade off between quality
  98857. * and performances.
  98858. * @see http://doc.babylonjs.com/babylon101/materials
  98859. */
  98860. export class StandardMaterial extends PushMaterial {
  98861. private _diffuseTexture;
  98862. /**
  98863. * The basic texture of the material as viewed under a light.
  98864. */
  98865. diffuseTexture: Nullable<BaseTexture>;
  98866. private _ambientTexture;
  98867. /**
  98868. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98869. */
  98870. ambientTexture: Nullable<BaseTexture>;
  98871. private _opacityTexture;
  98872. /**
  98873. * Define the transparency of the material from a texture.
  98874. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98875. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98876. */
  98877. opacityTexture: Nullable<BaseTexture>;
  98878. private _reflectionTexture;
  98879. /**
  98880. * Define the texture used to display the reflection.
  98881. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98882. */
  98883. reflectionTexture: Nullable<BaseTexture>;
  98884. private _emissiveTexture;
  98885. /**
  98886. * Define texture of the material as if self lit.
  98887. * This will be mixed in the final result even in the absence of light.
  98888. */
  98889. emissiveTexture: Nullable<BaseTexture>;
  98890. private _specularTexture;
  98891. /**
  98892. * Define how the color and intensity of the highlight given by the light in the material.
  98893. */
  98894. specularTexture: Nullable<BaseTexture>;
  98895. private _bumpTexture;
  98896. /**
  98897. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98898. * 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.
  98899. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98900. */
  98901. bumpTexture: Nullable<BaseTexture>;
  98902. private _lightmapTexture;
  98903. /**
  98904. * Complex lighting can be computationally expensive to compute at runtime.
  98905. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98906. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98907. */
  98908. lightmapTexture: Nullable<BaseTexture>;
  98909. private _refractionTexture;
  98910. /**
  98911. * Define the texture used to display the refraction.
  98912. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98913. */
  98914. refractionTexture: Nullable<BaseTexture>;
  98915. /**
  98916. * The color of the material lit by the environmental background lighting.
  98917. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98918. */
  98919. ambientColor: Color3;
  98920. /**
  98921. * The basic color of the material as viewed under a light.
  98922. */
  98923. diffuseColor: Color3;
  98924. /**
  98925. * Define how the color and intensity of the highlight given by the light in the material.
  98926. */
  98927. specularColor: Color3;
  98928. /**
  98929. * Define the color of the material as if self lit.
  98930. * This will be mixed in the final result even in the absence of light.
  98931. */
  98932. emissiveColor: Color3;
  98933. /**
  98934. * Defines how sharp are the highlights in the material.
  98935. * The bigger the value the sharper giving a more glossy feeling to the result.
  98936. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98937. */
  98938. specularPower: number;
  98939. private _useAlphaFromDiffuseTexture;
  98940. /**
  98941. * Does the transparency come from the diffuse texture alpha channel.
  98942. */
  98943. useAlphaFromDiffuseTexture: boolean;
  98944. private _useEmissiveAsIllumination;
  98945. /**
  98946. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98947. */
  98948. useEmissiveAsIllumination: boolean;
  98949. private _linkEmissiveWithDiffuse;
  98950. /**
  98951. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98952. * the emissive level when the final color is close to one.
  98953. */
  98954. linkEmissiveWithDiffuse: boolean;
  98955. private _useSpecularOverAlpha;
  98956. /**
  98957. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98958. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98959. */
  98960. useSpecularOverAlpha: boolean;
  98961. private _useReflectionOverAlpha;
  98962. /**
  98963. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98964. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98965. */
  98966. useReflectionOverAlpha: boolean;
  98967. private _disableLighting;
  98968. /**
  98969. * Does lights from the scene impacts this material.
  98970. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98971. */
  98972. disableLighting: boolean;
  98973. private _useObjectSpaceNormalMap;
  98974. /**
  98975. * Allows using an object space normal map (instead of tangent space).
  98976. */
  98977. useObjectSpaceNormalMap: boolean;
  98978. private _useParallax;
  98979. /**
  98980. * Is parallax enabled or not.
  98981. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98982. */
  98983. useParallax: boolean;
  98984. private _useParallaxOcclusion;
  98985. /**
  98986. * Is parallax occlusion enabled or not.
  98987. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98988. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98989. */
  98990. useParallaxOcclusion: boolean;
  98991. /**
  98992. * 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.
  98993. */
  98994. parallaxScaleBias: number;
  98995. private _roughness;
  98996. /**
  98997. * Helps to define how blurry the reflections should appears in the material.
  98998. */
  98999. roughness: number;
  99000. /**
  99001. * In case of refraction, define the value of the indice of refraction.
  99002. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99003. */
  99004. indexOfRefraction: number;
  99005. /**
  99006. * Invert the refraction texture alongside the y axis.
  99007. * It can be useful with procedural textures or probe for instance.
  99008. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99009. */
  99010. invertRefractionY: boolean;
  99011. /**
  99012. * Defines the alpha limits in alpha test mode.
  99013. */
  99014. alphaCutOff: number;
  99015. private _useLightmapAsShadowmap;
  99016. /**
  99017. * In case of light mapping, define whether the map contains light or shadow informations.
  99018. */
  99019. useLightmapAsShadowmap: boolean;
  99020. private _diffuseFresnelParameters;
  99021. /**
  99022. * Define the diffuse fresnel parameters of the material.
  99023. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99024. */
  99025. diffuseFresnelParameters: FresnelParameters;
  99026. private _opacityFresnelParameters;
  99027. /**
  99028. * Define the opacity fresnel parameters of the material.
  99029. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99030. */
  99031. opacityFresnelParameters: FresnelParameters;
  99032. private _reflectionFresnelParameters;
  99033. /**
  99034. * Define the reflection fresnel parameters of the material.
  99035. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99036. */
  99037. reflectionFresnelParameters: FresnelParameters;
  99038. private _refractionFresnelParameters;
  99039. /**
  99040. * Define the refraction fresnel parameters of the material.
  99041. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99042. */
  99043. refractionFresnelParameters: FresnelParameters;
  99044. private _emissiveFresnelParameters;
  99045. /**
  99046. * Define the emissive fresnel parameters of the material.
  99047. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99048. */
  99049. emissiveFresnelParameters: FresnelParameters;
  99050. private _useReflectionFresnelFromSpecular;
  99051. /**
  99052. * If true automatically deducts the fresnels values from the material specularity.
  99053. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99054. */
  99055. useReflectionFresnelFromSpecular: boolean;
  99056. private _useGlossinessFromSpecularMapAlpha;
  99057. /**
  99058. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99059. */
  99060. useGlossinessFromSpecularMapAlpha: boolean;
  99061. private _maxSimultaneousLights;
  99062. /**
  99063. * Defines the maximum number of lights that can be used in the material
  99064. */
  99065. maxSimultaneousLights: number;
  99066. private _invertNormalMapX;
  99067. /**
  99068. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99069. */
  99070. invertNormalMapX: boolean;
  99071. private _invertNormalMapY;
  99072. /**
  99073. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99074. */
  99075. invertNormalMapY: boolean;
  99076. private _twoSidedLighting;
  99077. /**
  99078. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99079. */
  99080. twoSidedLighting: boolean;
  99081. /**
  99082. * Default configuration related to image processing available in the standard Material.
  99083. */
  99084. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99085. /**
  99086. * Gets the image processing configuration used either in this material.
  99087. */
  99088. /**
  99089. * Sets the Default image processing configuration used either in the this material.
  99090. *
  99091. * If sets to null, the scene one is in use.
  99092. */
  99093. imageProcessingConfiguration: ImageProcessingConfiguration;
  99094. /**
  99095. * Keep track of the image processing observer to allow dispose and replace.
  99096. */
  99097. private _imageProcessingObserver;
  99098. /**
  99099. * Attaches a new image processing configuration to the Standard Material.
  99100. * @param configuration
  99101. */
  99102. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99103. /**
  99104. * Gets wether the color curves effect is enabled.
  99105. */
  99106. /**
  99107. * Sets wether the color curves effect is enabled.
  99108. */
  99109. cameraColorCurvesEnabled: boolean;
  99110. /**
  99111. * Gets wether the color grading effect is enabled.
  99112. */
  99113. /**
  99114. * Gets wether the color grading effect is enabled.
  99115. */
  99116. cameraColorGradingEnabled: boolean;
  99117. /**
  99118. * Gets wether tonemapping is enabled or not.
  99119. */
  99120. /**
  99121. * Sets wether tonemapping is enabled or not
  99122. */
  99123. cameraToneMappingEnabled: boolean;
  99124. /**
  99125. * The camera exposure used on this material.
  99126. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99127. * This corresponds to a photographic exposure.
  99128. */
  99129. /**
  99130. * The camera exposure used on this material.
  99131. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99132. * This corresponds to a photographic exposure.
  99133. */
  99134. cameraExposure: number;
  99135. /**
  99136. * Gets The camera contrast used on this material.
  99137. */
  99138. /**
  99139. * Sets The camera contrast used on this material.
  99140. */
  99141. cameraContrast: number;
  99142. /**
  99143. * Gets the Color Grading 2D Lookup Texture.
  99144. */
  99145. /**
  99146. * Sets the Color Grading 2D Lookup Texture.
  99147. */
  99148. cameraColorGradingTexture: Nullable<BaseTexture>;
  99149. /**
  99150. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99151. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99152. * 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;
  99153. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99154. */
  99155. /**
  99156. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99157. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99158. * 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;
  99159. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99160. */
  99161. cameraColorCurves: Nullable<ColorCurves>;
  99162. /**
  99163. * Custom callback helping to override the default shader used in the material.
  99164. */
  99165. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99166. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99167. protected _worldViewProjectionMatrix: Matrix;
  99168. protected _globalAmbientColor: Color3;
  99169. protected _useLogarithmicDepth: boolean;
  99170. /**
  99171. * Instantiates a new standard material.
  99172. * This is the default material used in Babylon. It is the best trade off between quality
  99173. * and performances.
  99174. * @see http://doc.babylonjs.com/babylon101/materials
  99175. * @param name Define the name of the material in the scene
  99176. * @param scene Define the scene the material belong to
  99177. */
  99178. constructor(name: string, scene: Scene);
  99179. /**
  99180. * Gets a boolean indicating that current material needs to register RTT
  99181. */
  99182. readonly hasRenderTargetTextures: boolean;
  99183. /**
  99184. * Gets the current class name of the material e.g. "StandardMaterial"
  99185. * Mainly use in serialization.
  99186. * @returns the class name
  99187. */
  99188. getClassName(): string;
  99189. /**
  99190. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99191. * You can try switching to logarithmic depth.
  99192. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99193. */
  99194. useLogarithmicDepth: boolean;
  99195. /**
  99196. * Specifies if the material will require alpha blending
  99197. * @returns a boolean specifying if alpha blending is needed
  99198. */
  99199. needAlphaBlending(): boolean;
  99200. /**
  99201. * Specifies if this material should be rendered in alpha test mode
  99202. * @returns a boolean specifying if an alpha test is needed.
  99203. */
  99204. needAlphaTesting(): boolean;
  99205. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99206. /**
  99207. * Get the texture used for alpha test purpose.
  99208. * @returns the diffuse texture in case of the standard material.
  99209. */
  99210. getAlphaTestTexture(): Nullable<BaseTexture>;
  99211. /**
  99212. * Get if the submesh is ready to be used and all its information available.
  99213. * Child classes can use it to update shaders
  99214. * @param mesh defines the mesh to check
  99215. * @param subMesh defines which submesh to check
  99216. * @param useInstances specifies that instances should be used
  99217. * @returns a boolean indicating that the submesh is ready or not
  99218. */
  99219. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99220. /**
  99221. * Builds the material UBO layouts.
  99222. * Used internally during the effect preparation.
  99223. */
  99224. buildUniformLayout(): void;
  99225. /**
  99226. * Unbinds the material from the mesh
  99227. */
  99228. unbind(): void;
  99229. /**
  99230. * Binds the submesh to this material by preparing the effect and shader to draw
  99231. * @param world defines the world transformation matrix
  99232. * @param mesh defines the mesh containing the submesh
  99233. * @param subMesh defines the submesh to bind the material to
  99234. */
  99235. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99236. /**
  99237. * Get the list of animatables in the material.
  99238. * @returns the list of animatables object used in the material
  99239. */
  99240. getAnimatables(): IAnimatable[];
  99241. /**
  99242. * Gets the active textures from the material
  99243. * @returns an array of textures
  99244. */
  99245. getActiveTextures(): BaseTexture[];
  99246. /**
  99247. * Specifies if the material uses a texture
  99248. * @param texture defines the texture to check against the material
  99249. * @returns a boolean specifying if the material uses the texture
  99250. */
  99251. hasTexture(texture: BaseTexture): boolean;
  99252. /**
  99253. * Disposes the material
  99254. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99255. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99256. */
  99257. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99258. /**
  99259. * Makes a duplicate of the material, and gives it a new name
  99260. * @param name defines the new name for the duplicated material
  99261. * @returns the cloned material
  99262. */
  99263. clone(name: string): StandardMaterial;
  99264. /**
  99265. * Serializes this material in a JSON representation
  99266. * @returns the serialized material object
  99267. */
  99268. serialize(): any;
  99269. /**
  99270. * Creates a standard material from parsed material data
  99271. * @param source defines the JSON representation of the material
  99272. * @param scene defines the hosting scene
  99273. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99274. * @returns a new standard material
  99275. */
  99276. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99277. /**
  99278. * Are diffuse textures enabled in the application.
  99279. */
  99280. static DiffuseTextureEnabled: boolean;
  99281. /**
  99282. * Are ambient textures enabled in the application.
  99283. */
  99284. static AmbientTextureEnabled: boolean;
  99285. /**
  99286. * Are opacity textures enabled in the application.
  99287. */
  99288. static OpacityTextureEnabled: boolean;
  99289. /**
  99290. * Are reflection textures enabled in the application.
  99291. */
  99292. static ReflectionTextureEnabled: boolean;
  99293. /**
  99294. * Are emissive textures enabled in the application.
  99295. */
  99296. static EmissiveTextureEnabled: boolean;
  99297. /**
  99298. * Are specular textures enabled in the application.
  99299. */
  99300. static SpecularTextureEnabled: boolean;
  99301. /**
  99302. * Are bump textures enabled in the application.
  99303. */
  99304. static BumpTextureEnabled: boolean;
  99305. /**
  99306. * Are lightmap textures enabled in the application.
  99307. */
  99308. static LightmapTextureEnabled: boolean;
  99309. /**
  99310. * Are refraction textures enabled in the application.
  99311. */
  99312. static RefractionTextureEnabled: boolean;
  99313. /**
  99314. * Are color grading textures enabled in the application.
  99315. */
  99316. static ColorGradingTextureEnabled: boolean;
  99317. /**
  99318. * Are fresnels enabled in the application.
  99319. */
  99320. static FresnelEnabled: boolean;
  99321. }
  99322. }
  99323. declare module BABYLON {
  99324. /**
  99325. * A class extending Texture allowing drawing on a texture
  99326. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99327. */
  99328. export class DynamicTexture extends Texture {
  99329. private _generateMipMaps;
  99330. private _canvas;
  99331. private _context;
  99332. private _engine;
  99333. /**
  99334. * Creates a DynamicTexture
  99335. * @param name defines the name of the texture
  99336. * @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
  99337. * @param scene defines the scene where you want the texture
  99338. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99339. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99340. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99341. */
  99342. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99343. /**
  99344. * Get the current class name of the texture useful for serialization or dynamic coding.
  99345. * @returns "DynamicTexture"
  99346. */
  99347. getClassName(): string;
  99348. /**
  99349. * Gets the current state of canRescale
  99350. */
  99351. readonly canRescale: boolean;
  99352. private _recreate;
  99353. /**
  99354. * Scales the texture
  99355. * @param ratio the scale factor to apply to both width and height
  99356. */
  99357. scale(ratio: number): void;
  99358. /**
  99359. * Resizes the texture
  99360. * @param width the new width
  99361. * @param height the new height
  99362. */
  99363. scaleTo(width: number, height: number): void;
  99364. /**
  99365. * Gets the context of the canvas used by the texture
  99366. * @returns the canvas context of the dynamic texture
  99367. */
  99368. getContext(): CanvasRenderingContext2D;
  99369. /**
  99370. * Clears the texture
  99371. */
  99372. clear(): void;
  99373. /**
  99374. * Updates the texture
  99375. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99376. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99377. */
  99378. update(invertY?: boolean, premulAlpha?: boolean): void;
  99379. /**
  99380. * Draws text onto the texture
  99381. * @param text defines the text to be drawn
  99382. * @param x defines the placement of the text from the left
  99383. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99384. * @param font defines the font to be used with font-style, font-size, font-name
  99385. * @param color defines the color used for the text
  99386. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99387. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99388. * @param update defines whether texture is immediately update (default is true)
  99389. */
  99390. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99391. /**
  99392. * Clones the texture
  99393. * @returns the clone of the texture.
  99394. */
  99395. clone(): DynamicTexture;
  99396. /**
  99397. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99398. * @returns a serialized dynamic texture object
  99399. */
  99400. serialize(): any;
  99401. /** @hidden */
  99402. _rebuild(): void;
  99403. }
  99404. }
  99405. declare module BABYLON {
  99406. /** @hidden */
  99407. export var imageProcessingPixelShader: {
  99408. name: string;
  99409. shader: string;
  99410. };
  99411. }
  99412. declare module BABYLON {
  99413. /**
  99414. * ImageProcessingPostProcess
  99415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99416. */
  99417. export class ImageProcessingPostProcess extends PostProcess {
  99418. /**
  99419. * Default configuration related to image processing available in the PBR Material.
  99420. */
  99421. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99422. /**
  99423. * Gets the image processing configuration used either in this material.
  99424. */
  99425. /**
  99426. * Sets the Default image processing configuration used either in the this material.
  99427. *
  99428. * If sets to null, the scene one is in use.
  99429. */
  99430. imageProcessingConfiguration: ImageProcessingConfiguration;
  99431. /**
  99432. * Keep track of the image processing observer to allow dispose and replace.
  99433. */
  99434. private _imageProcessingObserver;
  99435. /**
  99436. * Attaches a new image processing configuration to the PBR Material.
  99437. * @param configuration
  99438. */
  99439. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99440. /**
  99441. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99442. */
  99443. /**
  99444. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99445. */
  99446. colorCurves: Nullable<ColorCurves>;
  99447. /**
  99448. * Gets wether the color curves effect is enabled.
  99449. */
  99450. /**
  99451. * Sets wether the color curves effect is enabled.
  99452. */
  99453. colorCurvesEnabled: boolean;
  99454. /**
  99455. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99456. */
  99457. /**
  99458. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99459. */
  99460. colorGradingTexture: Nullable<BaseTexture>;
  99461. /**
  99462. * Gets wether the color grading effect is enabled.
  99463. */
  99464. /**
  99465. * Gets wether the color grading effect is enabled.
  99466. */
  99467. colorGradingEnabled: boolean;
  99468. /**
  99469. * Gets exposure used in the effect.
  99470. */
  99471. /**
  99472. * Sets exposure used in the effect.
  99473. */
  99474. exposure: number;
  99475. /**
  99476. * Gets wether tonemapping is enabled or not.
  99477. */
  99478. /**
  99479. * Sets wether tonemapping is enabled or not
  99480. */
  99481. toneMappingEnabled: boolean;
  99482. /**
  99483. * Gets the type of tone mapping effect.
  99484. */
  99485. /**
  99486. * Sets the type of tone mapping effect.
  99487. */
  99488. toneMappingType: number;
  99489. /**
  99490. * Gets contrast used in the effect.
  99491. */
  99492. /**
  99493. * Sets contrast used in the effect.
  99494. */
  99495. contrast: number;
  99496. /**
  99497. * Gets Vignette stretch size.
  99498. */
  99499. /**
  99500. * Sets Vignette stretch size.
  99501. */
  99502. vignetteStretch: number;
  99503. /**
  99504. * Gets Vignette centre X Offset.
  99505. */
  99506. /**
  99507. * Sets Vignette centre X Offset.
  99508. */
  99509. vignetteCentreX: number;
  99510. /**
  99511. * Gets Vignette centre Y Offset.
  99512. */
  99513. /**
  99514. * Sets Vignette centre Y Offset.
  99515. */
  99516. vignetteCentreY: number;
  99517. /**
  99518. * Gets Vignette weight or intensity of the vignette effect.
  99519. */
  99520. /**
  99521. * Sets Vignette weight or intensity of the vignette effect.
  99522. */
  99523. vignetteWeight: number;
  99524. /**
  99525. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99526. * if vignetteEnabled is set to true.
  99527. */
  99528. /**
  99529. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99530. * if vignetteEnabled is set to true.
  99531. */
  99532. vignetteColor: Color4;
  99533. /**
  99534. * Gets Camera field of view used by the Vignette effect.
  99535. */
  99536. /**
  99537. * Sets Camera field of view used by the Vignette effect.
  99538. */
  99539. vignetteCameraFov: number;
  99540. /**
  99541. * Gets the vignette blend mode allowing different kind of effect.
  99542. */
  99543. /**
  99544. * Sets the vignette blend mode allowing different kind of effect.
  99545. */
  99546. vignetteBlendMode: number;
  99547. /**
  99548. * Gets wether the vignette effect is enabled.
  99549. */
  99550. /**
  99551. * Sets wether the vignette effect is enabled.
  99552. */
  99553. vignetteEnabled: boolean;
  99554. private _fromLinearSpace;
  99555. /**
  99556. * Gets wether the input of the processing is in Gamma or Linear Space.
  99557. */
  99558. /**
  99559. * Sets wether the input of the processing is in Gamma or Linear Space.
  99560. */
  99561. fromLinearSpace: boolean;
  99562. /**
  99563. * Defines cache preventing GC.
  99564. */
  99565. private _defines;
  99566. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99567. /**
  99568. * "ImageProcessingPostProcess"
  99569. * @returns "ImageProcessingPostProcess"
  99570. */
  99571. getClassName(): string;
  99572. protected _updateParameters(): void;
  99573. dispose(camera?: Camera): void;
  99574. }
  99575. }
  99576. declare module BABYLON {
  99577. /**
  99578. * Class containing static functions to help procedurally build meshes
  99579. */
  99580. export class GroundBuilder {
  99581. /**
  99582. * Creates a ground mesh
  99583. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99584. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99586. * @param name defines the name of the mesh
  99587. * @param options defines the options used to create the mesh
  99588. * @param scene defines the hosting scene
  99589. * @returns the ground mesh
  99590. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99591. */
  99592. static CreateGround(name: string, options: {
  99593. width?: number;
  99594. height?: number;
  99595. subdivisions?: number;
  99596. subdivisionsX?: number;
  99597. subdivisionsY?: number;
  99598. updatable?: boolean;
  99599. }, scene: any): Mesh;
  99600. /**
  99601. * Creates a tiled ground mesh
  99602. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99603. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99604. * * 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
  99605. * * 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
  99606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99607. * @param name defines the name of the mesh
  99608. * @param options defines the options used to create the mesh
  99609. * @param scene defines the hosting scene
  99610. * @returns the tiled ground mesh
  99611. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99612. */
  99613. static CreateTiledGround(name: string, options: {
  99614. xmin: number;
  99615. zmin: number;
  99616. xmax: number;
  99617. zmax: number;
  99618. subdivisions?: {
  99619. w: number;
  99620. h: number;
  99621. };
  99622. precision?: {
  99623. w: number;
  99624. h: number;
  99625. };
  99626. updatable?: boolean;
  99627. }, scene?: Nullable<Scene>): Mesh;
  99628. /**
  99629. * Creates a ground mesh from a height map
  99630. * * The parameter `url` sets the URL of the height map image resource.
  99631. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99632. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99633. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99634. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99635. * * 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.
  99636. * * 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).
  99637. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99639. * @param name defines the name of the mesh
  99640. * @param url defines the url to the height map
  99641. * @param options defines the options used to create the mesh
  99642. * @param scene defines the hosting scene
  99643. * @returns the ground mesh
  99644. * @see https://doc.babylonjs.com/babylon101/height_map
  99645. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99646. */
  99647. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99648. width?: number;
  99649. height?: number;
  99650. subdivisions?: number;
  99651. minHeight?: number;
  99652. maxHeight?: number;
  99653. colorFilter?: Color3;
  99654. alphaFilter?: number;
  99655. updatable?: boolean;
  99656. onReady?: (mesh: GroundMesh) => void;
  99657. }, scene?: Nullable<Scene>): GroundMesh;
  99658. }
  99659. }
  99660. declare module BABYLON {
  99661. /**
  99662. * Class containing static functions to help procedurally build meshes
  99663. */
  99664. export class TorusBuilder {
  99665. /**
  99666. * Creates a torus mesh
  99667. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99668. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99669. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99673. * @param name defines the name of the mesh
  99674. * @param options defines the options used to create the mesh
  99675. * @param scene defines the hosting scene
  99676. * @returns the torus mesh
  99677. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99678. */
  99679. static CreateTorus(name: string, options: {
  99680. diameter?: number;
  99681. thickness?: number;
  99682. tessellation?: number;
  99683. updatable?: boolean;
  99684. sideOrientation?: number;
  99685. frontUVs?: Vector4;
  99686. backUVs?: Vector4;
  99687. }, scene: any): Mesh;
  99688. }
  99689. }
  99690. declare module BABYLON {
  99691. /**
  99692. * Class containing static functions to help procedurally build meshes
  99693. */
  99694. export class CylinderBuilder {
  99695. /**
  99696. * Creates a cylinder or a cone mesh
  99697. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99698. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99699. * * 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.
  99700. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99701. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99702. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99703. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99704. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99705. * * 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).
  99706. * * 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
  99707. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99708. * * 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
  99709. * * 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.
  99710. * * If `enclose` is false, a ring surface is one element.
  99711. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99712. * * 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
  99713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99716. * @param name defines the name of the mesh
  99717. * @param options defines the options used to create the mesh
  99718. * @param scene defines the hosting scene
  99719. * @returns the cylinder mesh
  99720. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99721. */
  99722. static CreateCylinder(name: string, options: {
  99723. height?: number;
  99724. diameterTop?: number;
  99725. diameterBottom?: number;
  99726. diameter?: number;
  99727. tessellation?: number;
  99728. subdivisions?: number;
  99729. arc?: number;
  99730. faceColors?: Color4[];
  99731. faceUV?: Vector4[];
  99732. updatable?: boolean;
  99733. hasRings?: boolean;
  99734. enclose?: boolean;
  99735. sideOrientation?: number;
  99736. frontUVs?: Vector4;
  99737. backUVs?: Vector4;
  99738. }, scene: any): Mesh;
  99739. }
  99740. }
  99741. declare module BABYLON {
  99742. /**
  99743. * Options to modify the vr teleportation behavior.
  99744. */
  99745. export interface VRTeleportationOptions {
  99746. /**
  99747. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99748. */
  99749. floorMeshName?: string;
  99750. /**
  99751. * A list of meshes to be used as the teleportation floor. (default: empty)
  99752. */
  99753. floorMeshes?: Mesh[];
  99754. }
  99755. /**
  99756. * Options to modify the vr experience helper's behavior.
  99757. */
  99758. export interface VRExperienceHelperOptions extends WebVROptions {
  99759. /**
  99760. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99761. */
  99762. createDeviceOrientationCamera?: boolean;
  99763. /**
  99764. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99765. */
  99766. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99767. /**
  99768. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99769. */
  99770. laserToggle?: boolean;
  99771. /**
  99772. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99773. */
  99774. floorMeshes?: Mesh[];
  99775. /**
  99776. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99777. */
  99778. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99779. }
  99780. /**
  99781. * Event containing information after VR has been entered
  99782. */
  99783. export class OnAfterEnteringVRObservableEvent {
  99784. /**
  99785. * If entering vr was successful
  99786. */
  99787. success: boolean;
  99788. }
  99789. /**
  99790. * Helps to quickly add VR support to an existing scene.
  99791. * See http://doc.babylonjs.com/how_to/webvr_helper
  99792. */
  99793. export class VRExperienceHelper {
  99794. /** Options to modify the vr experience helper's behavior. */
  99795. webVROptions: VRExperienceHelperOptions;
  99796. private _scene;
  99797. private _position;
  99798. private _btnVR;
  99799. private _btnVRDisplayed;
  99800. private _webVRsupported;
  99801. private _webVRready;
  99802. private _webVRrequesting;
  99803. private _webVRpresenting;
  99804. private _hasEnteredVR;
  99805. private _fullscreenVRpresenting;
  99806. private _canvas;
  99807. private _webVRCamera;
  99808. private _vrDeviceOrientationCamera;
  99809. private _deviceOrientationCamera;
  99810. private _existingCamera;
  99811. private _onKeyDown;
  99812. private _onVrDisplayPresentChange;
  99813. private _onVRDisplayChanged;
  99814. private _onVRRequestPresentStart;
  99815. private _onVRRequestPresentComplete;
  99816. /**
  99817. * Observable raised right before entering VR.
  99818. */
  99819. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99820. /**
  99821. * Observable raised when entering VR has completed.
  99822. */
  99823. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99824. /**
  99825. * Observable raised when exiting VR.
  99826. */
  99827. onExitingVRObservable: Observable<VRExperienceHelper>;
  99828. /**
  99829. * Observable raised when controller mesh is loaded.
  99830. */
  99831. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99832. /** Return this.onEnteringVRObservable
  99833. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99834. */
  99835. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99836. /** Return this.onExitingVRObservable
  99837. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99838. */
  99839. readonly onExitingVR: Observable<VRExperienceHelper>;
  99840. /** Return this.onControllerMeshLoadedObservable
  99841. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99842. */
  99843. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99844. private _rayLength;
  99845. private _useCustomVRButton;
  99846. private _teleportationRequested;
  99847. private _teleportActive;
  99848. private _floorMeshName;
  99849. private _floorMeshesCollection;
  99850. private _rotationAllowed;
  99851. private _teleportBackwardsVector;
  99852. private _teleportationTarget;
  99853. private _isDefaultTeleportationTarget;
  99854. private _postProcessMove;
  99855. private _teleportationFillColor;
  99856. private _teleportationBorderColor;
  99857. private _rotationAngle;
  99858. private _haloCenter;
  99859. private _cameraGazer;
  99860. private _padSensibilityUp;
  99861. private _padSensibilityDown;
  99862. private _leftController;
  99863. private _rightController;
  99864. /**
  99865. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99866. */
  99867. onNewMeshSelected: Observable<AbstractMesh>;
  99868. /**
  99869. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99870. */
  99871. onNewMeshPicked: Observable<PickingInfo>;
  99872. private _circleEase;
  99873. /**
  99874. * Observable raised before camera teleportation
  99875. */
  99876. onBeforeCameraTeleport: Observable<Vector3>;
  99877. /**
  99878. * Observable raised after camera teleportation
  99879. */
  99880. onAfterCameraTeleport: Observable<Vector3>;
  99881. /**
  99882. * Observable raised when current selected mesh gets unselected
  99883. */
  99884. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99885. private _raySelectionPredicate;
  99886. /**
  99887. * To be optionaly changed by user to define custom ray selection
  99888. */
  99889. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99890. /**
  99891. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99892. */
  99893. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99894. /**
  99895. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99896. */
  99897. teleportationEnabled: boolean;
  99898. private _defaultHeight;
  99899. private _teleportationInitialized;
  99900. private _interactionsEnabled;
  99901. private _interactionsRequested;
  99902. private _displayGaze;
  99903. private _displayLaserPointer;
  99904. /**
  99905. * The mesh used to display where the user is going to teleport.
  99906. */
  99907. /**
  99908. * Sets the mesh to be used to display where the user is going to teleport.
  99909. */
  99910. teleportationTarget: Mesh;
  99911. /**
  99912. * 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
  99913. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99914. * See http://doc.babylonjs.com/resources/baking_transformations
  99915. */
  99916. gazeTrackerMesh: Mesh;
  99917. /**
  99918. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99919. */
  99920. updateGazeTrackerScale: boolean;
  99921. /**
  99922. * If the gaze trackers color should be updated when selecting meshes
  99923. */
  99924. updateGazeTrackerColor: boolean;
  99925. /**
  99926. * The gaze tracking mesh corresponding to the left controller
  99927. */
  99928. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99929. /**
  99930. * The gaze tracking mesh corresponding to the right controller
  99931. */
  99932. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99933. /**
  99934. * If the ray of the gaze should be displayed.
  99935. */
  99936. /**
  99937. * Sets if the ray of the gaze should be displayed.
  99938. */
  99939. displayGaze: boolean;
  99940. /**
  99941. * If the ray of the LaserPointer should be displayed.
  99942. */
  99943. /**
  99944. * Sets if the ray of the LaserPointer should be displayed.
  99945. */
  99946. displayLaserPointer: boolean;
  99947. /**
  99948. * The deviceOrientationCamera used as the camera when not in VR.
  99949. */
  99950. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99951. /**
  99952. * Based on the current WebVR support, returns the current VR camera used.
  99953. */
  99954. readonly currentVRCamera: Nullable<Camera>;
  99955. /**
  99956. * The webVRCamera which is used when in VR.
  99957. */
  99958. readonly webVRCamera: WebVRFreeCamera;
  99959. /**
  99960. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99961. */
  99962. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99963. private readonly _teleportationRequestInitiated;
  99964. /**
  99965. * Defines wether or not Pointer lock should be requested when switching to
  99966. * full screen.
  99967. */
  99968. requestPointerLockOnFullScreen: boolean;
  99969. /**
  99970. * Instantiates a VRExperienceHelper.
  99971. * Helps to quickly add VR support to an existing scene.
  99972. * @param scene The scene the VRExperienceHelper belongs to.
  99973. * @param webVROptions Options to modify the vr experience helper's behavior.
  99974. */
  99975. constructor(scene: Scene,
  99976. /** Options to modify the vr experience helper's behavior. */
  99977. webVROptions?: VRExperienceHelperOptions);
  99978. private _onDefaultMeshLoaded;
  99979. private _onResize;
  99980. private _onFullscreenChange;
  99981. /**
  99982. * Gets a value indicating if we are currently in VR mode.
  99983. */
  99984. readonly isInVRMode: boolean;
  99985. private onVrDisplayPresentChange;
  99986. private onVRDisplayChanged;
  99987. private moveButtonToBottomRight;
  99988. private displayVRButton;
  99989. private updateButtonVisibility;
  99990. private _cachedAngularSensibility;
  99991. /**
  99992. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99993. * Otherwise, will use the fullscreen API.
  99994. */
  99995. enterVR(): void;
  99996. /**
  99997. * Attempt to exit VR, or fullscreen.
  99998. */
  99999. exitVR(): void;
  100000. /**
  100001. * The position of the vr experience helper.
  100002. */
  100003. /**
  100004. * Sets the position of the vr experience helper.
  100005. */
  100006. position: Vector3;
  100007. /**
  100008. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  100009. */
  100010. enableInteractions(): void;
  100011. private readonly _noControllerIsActive;
  100012. private beforeRender;
  100013. private _isTeleportationFloor;
  100014. /**
  100015. * Adds a floor mesh to be used for teleportation.
  100016. * @param floorMesh the mesh to be used for teleportation.
  100017. */
  100018. addFloorMesh(floorMesh: Mesh): void;
  100019. /**
  100020. * Removes a floor mesh from being used for teleportation.
  100021. * @param floorMesh the mesh to be removed.
  100022. */
  100023. removeFloorMesh(floorMesh: Mesh): void;
  100024. /**
  100025. * Enables interactions and teleportation using the VR controllers and gaze.
  100026. * @param vrTeleportationOptions options to modify teleportation behavior.
  100027. */
  100028. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  100029. private _onNewGamepadConnected;
  100030. private _tryEnableInteractionOnController;
  100031. private _onNewGamepadDisconnected;
  100032. private _enableInteractionOnController;
  100033. private _checkTeleportWithRay;
  100034. private _checkRotate;
  100035. private _checkTeleportBackwards;
  100036. private _enableTeleportationOnController;
  100037. private _createTeleportationCircles;
  100038. private _displayTeleportationTarget;
  100039. private _hideTeleportationTarget;
  100040. private _rotateCamera;
  100041. private _moveTeleportationSelectorTo;
  100042. private _workingVector;
  100043. private _workingQuaternion;
  100044. private _workingMatrix;
  100045. /**
  100046. * Teleports the users feet to the desired location
  100047. * @param location The location where the user's feet should be placed
  100048. */
  100049. teleportCamera(location: Vector3): void;
  100050. private _convertNormalToDirectionOfRay;
  100051. private _castRayAndSelectObject;
  100052. private _notifySelectedMeshUnselected;
  100053. /**
  100054. * Sets the color of the laser ray from the vr controllers.
  100055. * @param color new color for the ray.
  100056. */
  100057. changeLaserColor(color: Color3): void;
  100058. /**
  100059. * Sets the color of the ray from the vr headsets gaze.
  100060. * @param color new color for the ray.
  100061. */
  100062. changeGazeColor(color: Color3): void;
  100063. /**
  100064. * Exits VR and disposes of the vr experience helper
  100065. */
  100066. dispose(): void;
  100067. /**
  100068. * Gets the name of the VRExperienceHelper class
  100069. * @returns "VRExperienceHelper"
  100070. */
  100071. getClassName(): string;
  100072. }
  100073. }
  100074. declare module BABYLON {
  100075. /**
  100076. * Manages an XRSession
  100077. * @see https://doc.babylonjs.com/how_to/webxr
  100078. */
  100079. export class WebXRSessionManager implements IDisposable {
  100080. private scene;
  100081. /**
  100082. * Fires every time a new xrFrame arrives which can be used to update the camera
  100083. */
  100084. onXRFrameObservable: Observable<any>;
  100085. /**
  100086. * Fires when the xr session is ended either by the device or manually done
  100087. */
  100088. onXRSessionEnded: Observable<any>;
  100089. /** @hidden */
  100090. _xrSession: XRSession;
  100091. /** @hidden */
  100092. _frameOfReference: XRFrameOfReference;
  100093. /** @hidden */
  100094. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  100095. /** @hidden */
  100096. _currentXRFrame: Nullable<XRFrame>;
  100097. private _xrNavigator;
  100098. private _xrDevice;
  100099. private _tmpMatrix;
  100100. /**
  100101. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  100102. * @param scene The scene which the session should be created for
  100103. */
  100104. constructor(scene: Scene);
  100105. /**
  100106. * Initializes the manager
  100107. * After initialization enterXR can be called to start an XR session
  100108. * @returns Promise which resolves after it is initialized
  100109. */
  100110. initializeAsync(): Promise<void>;
  100111. /**
  100112. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  100113. * @param sessionCreationOptions xr options to create the session with
  100114. * @param frameOfReferenceType option to configure how the xr pose is expressed
  100115. * @returns Promise which resolves after it enters XR
  100116. */
  100117. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  100118. /**
  100119. * Stops the xrSession and restores the renderloop
  100120. * @returns Promise which resolves after it exits XR
  100121. */
  100122. exitXRAsync(): Promise<void>;
  100123. /**
  100124. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100125. * @param ray ray to cast into the environment
  100126. * @returns Promise which resolves with a collision point in the environment if it exists
  100127. */
  100128. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100129. /**
  100130. * Checks if a session would be supported for the creation options specified
  100131. * @param options creation options to check if they are supported
  100132. * @returns true if supported
  100133. */
  100134. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100135. /**
  100136. * @hidden
  100137. * Converts the render layer of xrSession to a render target
  100138. * @param session session to create render target for
  100139. * @param scene scene the new render target should be created for
  100140. */
  100141. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  100142. /**
  100143. * Disposes of the session manager
  100144. */
  100145. dispose(): void;
  100146. }
  100147. }
  100148. declare module BABYLON {
  100149. /**
  100150. * WebXR Camera which holds the views for the xrSession
  100151. * @see https://doc.babylonjs.com/how_to/webxr
  100152. */
  100153. export class WebXRCamera extends FreeCamera {
  100154. private static _TmpMatrix;
  100155. /**
  100156. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  100157. * @param name the name of the camera
  100158. * @param scene the scene to add the camera to
  100159. */
  100160. constructor(name: string, scene: Scene);
  100161. private _updateNumberOfRigCameras;
  100162. /** @hidden */
  100163. _updateForDualEyeDebugging(pupilDistance?: number): void;
  100164. /**
  100165. * Updates the cameras position from the current pose information of the XR session
  100166. * @param xrSessionManager the session containing pose information
  100167. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  100168. */
  100169. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  100170. }
  100171. }
  100172. declare module BABYLON {
  100173. /**
  100174. * States of the webXR experience
  100175. */
  100176. export enum WebXRState {
  100177. /**
  100178. * Transitioning to being in XR mode
  100179. */
  100180. ENTERING_XR = 0,
  100181. /**
  100182. * Transitioning to non XR mode
  100183. */
  100184. EXITING_XR = 1,
  100185. /**
  100186. * In XR mode and presenting
  100187. */
  100188. IN_XR = 2,
  100189. /**
  100190. * Not entered XR mode
  100191. */
  100192. NOT_IN_XR = 3
  100193. }
  100194. /**
  100195. * Helper class used to enable XR
  100196. * @see https://doc.babylonjs.com/how_to/webxr
  100197. */
  100198. export class WebXRExperienceHelper implements IDisposable {
  100199. private scene;
  100200. /**
  100201. * 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
  100202. */
  100203. container: AbstractMesh;
  100204. /**
  100205. * Camera used to render xr content
  100206. */
  100207. camera: WebXRCamera;
  100208. /**
  100209. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100210. */
  100211. state: WebXRState;
  100212. private _setState;
  100213. private static _TmpVector;
  100214. /**
  100215. * Fires when the state of the experience helper has changed
  100216. */
  100217. onStateChangedObservable: Observable<WebXRState>;
  100218. /** @hidden */
  100219. _sessionManager: WebXRSessionManager;
  100220. private _nonVRCamera;
  100221. private _originalSceneAutoClear;
  100222. private _supported;
  100223. /**
  100224. * Creates the experience helper
  100225. * @param scene the scene to attach the experience helper to
  100226. * @returns a promise for the experience helper
  100227. */
  100228. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100229. /**
  100230. * Creates a WebXRExperienceHelper
  100231. * @param scene The scene the helper should be created in
  100232. */
  100233. private constructor();
  100234. /**
  100235. * Exits XR mode and returns the scene to its original state
  100236. * @returns promise that resolves after xr mode has exited
  100237. */
  100238. exitXRAsync(): Promise<void>;
  100239. /**
  100240. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100241. * @param sessionCreationOptions options for the XR session
  100242. * @param frameOfReference frame of reference of the XR session
  100243. * @returns promise that resolves after xr mode has entered
  100244. */
  100245. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100246. /**
  100247. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100248. * @param ray ray to cast into the environment
  100249. * @returns Promise which resolves with a collision point in the environment if it exists
  100250. */
  100251. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100252. /**
  100253. * Updates the global position of the camera by moving the camera's container
  100254. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100255. * @param position The desired global position of the camera
  100256. */
  100257. setPositionOfCameraUsingContainer(position: Vector3): void;
  100258. /**
  100259. * Rotates the xr camera by rotating the camera's container around the camera's position
  100260. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100261. * @param rotation the desired quaternion rotation to apply to the camera
  100262. */
  100263. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100264. /**
  100265. * Checks if the creation options are supported by the xr session
  100266. * @param options creation options
  100267. * @returns true if supported
  100268. */
  100269. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100270. /**
  100271. * Disposes of the experience helper
  100272. */
  100273. dispose(): void;
  100274. }
  100275. }
  100276. declare module BABYLON {
  100277. /**
  100278. * Button which can be used to enter a different mode of XR
  100279. */
  100280. export class WebXREnterExitUIButton {
  100281. /** button element */
  100282. element: HTMLElement;
  100283. /** XR initialization options for the button */
  100284. initializationOptions: XRSessionCreationOptions;
  100285. /**
  100286. * Creates a WebXREnterExitUIButton
  100287. * @param element button element
  100288. * @param initializationOptions XR initialization options for the button
  100289. */
  100290. constructor(
  100291. /** button element */
  100292. element: HTMLElement,
  100293. /** XR initialization options for the button */
  100294. initializationOptions: XRSessionCreationOptions);
  100295. /**
  100296. * Overwritable function which can be used to update the button's visuals when the state changes
  100297. * @param activeButton the current active button in the UI
  100298. */
  100299. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100300. }
  100301. /**
  100302. * Options to create the webXR UI
  100303. */
  100304. export class WebXREnterExitUIOptions {
  100305. /**
  100306. * Context to enter xr with
  100307. */
  100308. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100309. /**
  100310. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100311. */
  100312. customButtons?: Array<WebXREnterExitUIButton>;
  100313. }
  100314. /**
  100315. * UI to allow the user to enter/exit XR mode
  100316. */
  100317. export class WebXREnterExitUI implements IDisposable {
  100318. private scene;
  100319. private _overlay;
  100320. private _buttons;
  100321. private _activeButton;
  100322. /**
  100323. * Fired every time the active button is changed.
  100324. *
  100325. * When xr is entered via a button that launches xr that button will be the callback parameter
  100326. *
  100327. * When exiting xr the callback parameter will be null)
  100328. */
  100329. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100330. /**
  100331. * Creates UI to allow the user to enter/exit XR mode
  100332. * @param scene the scene to add the ui to
  100333. * @param helper the xr experience helper to enter/exit xr with
  100334. * @param options options to configure the UI
  100335. * @returns the created ui
  100336. */
  100337. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100338. private constructor();
  100339. private _updateButtons;
  100340. /**
  100341. * Disposes of the object
  100342. */
  100343. dispose(): void;
  100344. }
  100345. }
  100346. declare module BABYLON {
  100347. /**
  100348. * Represents an XR input
  100349. */
  100350. export class WebXRController {
  100351. /**
  100352. * 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
  100353. */
  100354. grip?: AbstractMesh;
  100355. /**
  100356. * Pointer which can be used to select objects or attach a visible laser to
  100357. */
  100358. pointer: AbstractMesh;
  100359. /**
  100360. * Creates the controller
  100361. * @see https://doc.babylonjs.com/how_to/webxr
  100362. * @param scene the scene which the controller should be associated to
  100363. */
  100364. constructor(scene: Scene);
  100365. /**
  100366. * Disposes of the object
  100367. */
  100368. dispose(): void;
  100369. }
  100370. /**
  100371. * XR input used to track XR inputs such as controllers/rays
  100372. */
  100373. export class WebXRInput implements IDisposable {
  100374. private helper;
  100375. /**
  100376. * XR controllers being tracked
  100377. */
  100378. controllers: Array<WebXRController>;
  100379. private _tmpMatrix;
  100380. private _frameObserver;
  100381. /**
  100382. * Initializes the WebXRInput
  100383. * @param helper experience helper which the input should be created for
  100384. */
  100385. constructor(helper: WebXRExperienceHelper);
  100386. /**
  100387. * Disposes of the object
  100388. */
  100389. dispose(): void;
  100390. }
  100391. }
  100392. declare module BABYLON {
  100393. /**
  100394. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100395. */
  100396. export class WebXRManagedOutputCanvas implements IDisposable {
  100397. private _canvas;
  100398. /**
  100399. * xrpresent context of the canvas which can be used to display/mirror xr content
  100400. */
  100401. canvasContext: Nullable<WebGLRenderingContext>;
  100402. /**
  100403. * Initializes the canvas to be added/removed upon entering/exiting xr
  100404. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100405. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100406. */
  100407. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100408. /**
  100409. * Disposes of the object
  100410. */
  100411. dispose(): void;
  100412. private _setManagedOutputCanvas;
  100413. private _addCanvas;
  100414. private _removeCanvas;
  100415. }
  100416. }
  100417. declare module BABYLON {
  100418. /**
  100419. * Contains an array of blocks representing the octree
  100420. */
  100421. export interface IOctreeContainer<T> {
  100422. /**
  100423. * Blocks within the octree
  100424. */
  100425. blocks: Array<OctreeBlock<T>>;
  100426. }
  100427. /**
  100428. * Class used to store a cell in an octree
  100429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100430. */
  100431. export class OctreeBlock<T> {
  100432. /**
  100433. * Gets the content of the current block
  100434. */
  100435. entries: T[];
  100436. /**
  100437. * Gets the list of block children
  100438. */
  100439. blocks: Array<OctreeBlock<T>>;
  100440. private _depth;
  100441. private _maxDepth;
  100442. private _capacity;
  100443. private _minPoint;
  100444. private _maxPoint;
  100445. private _boundingVectors;
  100446. private _creationFunc;
  100447. /**
  100448. * Creates a new block
  100449. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100450. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100451. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100452. * @param depth defines the current depth of this block in the octree
  100453. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100454. * @param creationFunc defines a callback to call when an element is added to the block
  100455. */
  100456. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100457. /**
  100458. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100459. */
  100460. readonly capacity: number;
  100461. /**
  100462. * Gets the minimum vector (in world space) of the block's bounding box
  100463. */
  100464. readonly minPoint: Vector3;
  100465. /**
  100466. * Gets the maximum vector (in world space) of the block's bounding box
  100467. */
  100468. readonly maxPoint: Vector3;
  100469. /**
  100470. * Add a new element to this block
  100471. * @param entry defines the element to add
  100472. */
  100473. addEntry(entry: T): void;
  100474. /**
  100475. * Remove an element from this block
  100476. * @param entry defines the element to remove
  100477. */
  100478. removeEntry(entry: T): void;
  100479. /**
  100480. * Add an array of elements to this block
  100481. * @param entries defines the array of elements to add
  100482. */
  100483. addEntries(entries: T[]): void;
  100484. /**
  100485. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100486. * @param frustumPlanes defines the frustum planes to test
  100487. * @param selection defines the array to store current content if selection is positive
  100488. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100489. */
  100490. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100491. /**
  100492. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100493. * @param sphereCenter defines the bounding sphere center
  100494. * @param sphereRadius defines the bounding sphere radius
  100495. * @param selection defines the array to store current content if selection is positive
  100496. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100497. */
  100498. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100499. /**
  100500. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100501. * @param ray defines the ray to test with
  100502. * @param selection defines the array to store current content if selection is positive
  100503. */
  100504. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100505. /**
  100506. * Subdivide the content into child blocks (this block will then be empty)
  100507. */
  100508. createInnerBlocks(): void;
  100509. /**
  100510. * @hidden
  100511. */
  100512. 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;
  100513. }
  100514. }
  100515. declare module BABYLON {
  100516. /**
  100517. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100518. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100519. */
  100520. export class Octree<T> {
  100521. /** 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.) */
  100522. maxDepth: number;
  100523. /**
  100524. * Blocks within the octree containing objects
  100525. */
  100526. blocks: Array<OctreeBlock<T>>;
  100527. /**
  100528. * Content stored in the octree
  100529. */
  100530. dynamicContent: T[];
  100531. private _maxBlockCapacity;
  100532. private _selectionContent;
  100533. private _creationFunc;
  100534. /**
  100535. * Creates a octree
  100536. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100537. * @param creationFunc function to be used to instatiate the octree
  100538. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100539. * @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.)
  100540. */
  100541. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100542. /** 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.) */
  100543. maxDepth?: number);
  100544. /**
  100545. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100546. * @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);
  100547. * @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);
  100548. * @param entries meshes to be added to the octree blocks
  100549. */
  100550. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100551. /**
  100552. * Adds a mesh to the octree
  100553. * @param entry Mesh to add to the octree
  100554. */
  100555. addMesh(entry: T): void;
  100556. /**
  100557. * Remove an element from the octree
  100558. * @param entry defines the element to remove
  100559. */
  100560. removeMesh(entry: T): void;
  100561. /**
  100562. * Selects an array of meshes within the frustum
  100563. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100564. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100565. * @returns array of meshes within the frustum
  100566. */
  100567. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100568. /**
  100569. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100570. * @param sphereCenter defines the bounding sphere center
  100571. * @param sphereRadius defines the bounding sphere radius
  100572. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100573. * @returns an array of objects that intersect the sphere
  100574. */
  100575. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100576. /**
  100577. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100578. * @param ray defines the ray to test with
  100579. * @returns array of intersected objects
  100580. */
  100581. intersectsRay(ray: Ray): SmartArray<T>;
  100582. /**
  100583. * Adds a mesh into the octree block if it intersects the block
  100584. */
  100585. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100586. /**
  100587. * Adds a submesh into the octree block if it intersects the block
  100588. */
  100589. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100590. }
  100591. }
  100592. declare module BABYLON {
  100593. interface Scene {
  100594. /**
  100595. * @hidden
  100596. * Backing Filed
  100597. */
  100598. _selectionOctree: Octree<AbstractMesh>;
  100599. /**
  100600. * Gets the octree used to boost mesh selection (picking)
  100601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100602. */
  100603. selectionOctree: Octree<AbstractMesh>;
  100604. /**
  100605. * Creates or updates the octree used to boost selection (picking)
  100606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100607. * @param maxCapacity defines the maximum capacity per leaf
  100608. * @param maxDepth defines the maximum depth of the octree
  100609. * @returns an octree of AbstractMesh
  100610. */
  100611. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100612. }
  100613. interface AbstractMesh {
  100614. /**
  100615. * @hidden
  100616. * Backing Field
  100617. */
  100618. _submeshesOctree: Octree<SubMesh>;
  100619. /**
  100620. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100621. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100622. * @param maxCapacity defines the maximum size of each block (64 by default)
  100623. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100624. * @returns the new octree
  100625. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100626. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100627. */
  100628. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100629. }
  100630. /**
  100631. * Defines the octree scene component responsible to manage any octrees
  100632. * in a given scene.
  100633. */
  100634. export class OctreeSceneComponent {
  100635. /**
  100636. * The component name help to identify the component in the list of scene components.
  100637. */
  100638. readonly name: string;
  100639. /**
  100640. * The scene the component belongs to.
  100641. */
  100642. scene: Scene;
  100643. /**
  100644. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100645. */
  100646. readonly checksIsEnabled: boolean;
  100647. /**
  100648. * Creates a new instance of the component for the given scene
  100649. * @param scene Defines the scene to register the component in
  100650. */
  100651. constructor(scene: Scene);
  100652. /**
  100653. * Registers the component in a given scene
  100654. */
  100655. register(): void;
  100656. /**
  100657. * Return the list of active meshes
  100658. * @returns the list of active meshes
  100659. */
  100660. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100661. /**
  100662. * Return the list of active sub meshes
  100663. * @param mesh The mesh to get the candidates sub meshes from
  100664. * @returns the list of active sub meshes
  100665. */
  100666. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100667. private _tempRay;
  100668. /**
  100669. * Return the list of sub meshes intersecting with a given local ray
  100670. * @param mesh defines the mesh to find the submesh for
  100671. * @param localRay defines the ray in local space
  100672. * @returns the list of intersecting sub meshes
  100673. */
  100674. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100675. /**
  100676. * Return the list of sub meshes colliding with a collider
  100677. * @param mesh defines the mesh to find the submesh for
  100678. * @param collider defines the collider to evaluate the collision against
  100679. * @returns the list of colliding sub meshes
  100680. */
  100681. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100682. /**
  100683. * Rebuilds the elements related to this component in case of
  100684. * context lost for instance.
  100685. */
  100686. rebuild(): void;
  100687. /**
  100688. * Disposes the component and the associated ressources.
  100689. */
  100690. dispose(): void;
  100691. }
  100692. }
  100693. declare module BABYLON {
  100694. /**
  100695. * Renders a layer on top of an existing scene
  100696. */
  100697. export class UtilityLayerRenderer implements IDisposable {
  100698. /** the original scene that will be rendered on top of */
  100699. originalScene: Scene;
  100700. private _pointerCaptures;
  100701. private _lastPointerEvents;
  100702. private static _DefaultUtilityLayer;
  100703. private static _DefaultKeepDepthUtilityLayer;
  100704. private _sharedGizmoLight;
  100705. /**
  100706. * @hidden
  100707. * Light which used by gizmos to get light shading
  100708. */
  100709. _getSharedGizmoLight(): HemisphericLight;
  100710. /**
  100711. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100712. */
  100713. pickUtilitySceneFirst: boolean;
  100714. /**
  100715. * 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)
  100716. */
  100717. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100718. /**
  100719. * 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)
  100720. */
  100721. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100722. /**
  100723. * The scene that is rendered on top of the original scene
  100724. */
  100725. utilityLayerScene: Scene;
  100726. /**
  100727. * If the utility layer should automatically be rendered on top of existing scene
  100728. */
  100729. shouldRender: boolean;
  100730. /**
  100731. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100732. */
  100733. onlyCheckPointerDownEvents: boolean;
  100734. /**
  100735. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100736. */
  100737. processAllEvents: boolean;
  100738. /**
  100739. * Observable raised when the pointer move from the utility layer scene to the main scene
  100740. */
  100741. onPointerOutObservable: Observable<number>;
  100742. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100743. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100744. private _afterRenderObserver;
  100745. private _sceneDisposeObserver;
  100746. private _originalPointerObserver;
  100747. /**
  100748. * Instantiates a UtilityLayerRenderer
  100749. * @param originalScene the original scene that will be rendered on top of
  100750. * @param handleEvents boolean indicating if the utility layer should handle events
  100751. */
  100752. constructor(
  100753. /** the original scene that will be rendered on top of */
  100754. originalScene: Scene, handleEvents?: boolean);
  100755. private _notifyObservers;
  100756. /**
  100757. * Renders the utility layers scene on top of the original scene
  100758. */
  100759. render(): void;
  100760. /**
  100761. * Disposes of the renderer
  100762. */
  100763. dispose(): void;
  100764. private _updateCamera;
  100765. }
  100766. }
  100767. declare module BABYLON {
  100768. /**
  100769. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100770. */
  100771. export class Gizmo implements IDisposable {
  100772. /** The utility layer the gizmo will be added to */
  100773. gizmoLayer: UtilityLayerRenderer;
  100774. /**
  100775. * The root mesh of the gizmo
  100776. */
  100777. _rootMesh: Mesh;
  100778. private _attachedMesh;
  100779. /**
  100780. * Ratio for the scale of the gizmo (Default: 1)
  100781. */
  100782. scaleRatio: number;
  100783. /**
  100784. * If a custom mesh has been set (Default: false)
  100785. */
  100786. protected _customMeshSet: boolean;
  100787. /**
  100788. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100789. * * When set, interactions will be enabled
  100790. */
  100791. attachedMesh: Nullable<AbstractMesh>;
  100792. /**
  100793. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100794. * @param mesh The mesh to replace the default mesh of the gizmo
  100795. */
  100796. setCustomMesh(mesh: Mesh): void;
  100797. /**
  100798. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100799. */
  100800. updateGizmoRotationToMatchAttachedMesh: boolean;
  100801. /**
  100802. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100803. */
  100804. updateGizmoPositionToMatchAttachedMesh: boolean;
  100805. /**
  100806. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100807. */
  100808. protected _updateScale: boolean;
  100809. protected _interactionsEnabled: boolean;
  100810. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100811. private _beforeRenderObserver;
  100812. private _tempVector;
  100813. /**
  100814. * Creates a gizmo
  100815. * @param gizmoLayer The utility layer the gizmo will be added to
  100816. */
  100817. constructor(
  100818. /** The utility layer the gizmo will be added to */
  100819. gizmoLayer?: UtilityLayerRenderer);
  100820. /**
  100821. * Updates the gizmo to match the attached mesh's position/rotation
  100822. */
  100823. protected _update(): void;
  100824. /**
  100825. * Disposes of the gizmo
  100826. */
  100827. dispose(): void;
  100828. }
  100829. }
  100830. declare module BABYLON {
  100831. /**
  100832. * Single axis drag gizmo
  100833. */
  100834. export class AxisDragGizmo extends Gizmo {
  100835. /**
  100836. * Drag behavior responsible for the gizmos dragging interactions
  100837. */
  100838. dragBehavior: PointerDragBehavior;
  100839. private _pointerObserver;
  100840. /**
  100841. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100842. */
  100843. snapDistance: number;
  100844. /**
  100845. * Event that fires each time the gizmo snaps to a new location.
  100846. * * snapDistance is the the change in distance
  100847. */
  100848. onSnapObservable: Observable<{
  100849. snapDistance: number;
  100850. }>;
  100851. /** @hidden */
  100852. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100853. /** @hidden */
  100854. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100855. /**
  100856. * Creates an AxisDragGizmo
  100857. * @param gizmoLayer The utility layer the gizmo will be added to
  100858. * @param dragAxis The axis which the gizmo will be able to drag on
  100859. * @param color The color of the gizmo
  100860. */
  100861. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100862. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100863. /**
  100864. * Disposes of the gizmo
  100865. */
  100866. dispose(): void;
  100867. }
  100868. }
  100869. declare module BABYLON.Debug {
  100870. /**
  100871. * The Axes viewer will show 3 axes in a specific point in space
  100872. */
  100873. export class AxesViewer {
  100874. private _xAxis;
  100875. private _yAxis;
  100876. private _zAxis;
  100877. private _scaleLinesFactor;
  100878. private _instanced;
  100879. /**
  100880. * Gets the hosting scene
  100881. */
  100882. scene: Scene;
  100883. /**
  100884. * Gets or sets a number used to scale line length
  100885. */
  100886. scaleLines: number;
  100887. /** Gets the node hierarchy used to render x-axis */
  100888. readonly xAxis: TransformNode;
  100889. /** Gets the node hierarchy used to render y-axis */
  100890. readonly yAxis: TransformNode;
  100891. /** Gets the node hierarchy used to render z-axis */
  100892. readonly zAxis: TransformNode;
  100893. /**
  100894. * Creates a new AxesViewer
  100895. * @param scene defines the hosting scene
  100896. * @param scaleLines defines a number used to scale line length (1 by default)
  100897. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100898. * @param xAxis defines the node hierarchy used to render the x-axis
  100899. * @param yAxis defines the node hierarchy used to render the y-axis
  100900. * @param zAxis defines the node hierarchy used to render the z-axis
  100901. */
  100902. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100903. /**
  100904. * Force the viewer to update
  100905. * @param position defines the position of the viewer
  100906. * @param xaxis defines the x axis of the viewer
  100907. * @param yaxis defines the y axis of the viewer
  100908. * @param zaxis defines the z axis of the viewer
  100909. */
  100910. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100911. /**
  100912. * Creates an instance of this axes viewer.
  100913. * @returns a new axes viewer with instanced meshes
  100914. */
  100915. createInstance(): AxesViewer;
  100916. /** Releases resources */
  100917. dispose(): void;
  100918. private static _SetRenderingGroupId;
  100919. }
  100920. }
  100921. declare module BABYLON.Debug {
  100922. /**
  100923. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100924. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100925. */
  100926. export class BoneAxesViewer extends AxesViewer {
  100927. /**
  100928. * Gets or sets the target mesh where to display the axes viewer
  100929. */
  100930. mesh: Nullable<Mesh>;
  100931. /**
  100932. * Gets or sets the target bone where to display the axes viewer
  100933. */
  100934. bone: Nullable<Bone>;
  100935. /** Gets current position */
  100936. pos: Vector3;
  100937. /** Gets direction of X axis */
  100938. xaxis: Vector3;
  100939. /** Gets direction of Y axis */
  100940. yaxis: Vector3;
  100941. /** Gets direction of Z axis */
  100942. zaxis: Vector3;
  100943. /**
  100944. * Creates a new BoneAxesViewer
  100945. * @param scene defines the hosting scene
  100946. * @param bone defines the target bone
  100947. * @param mesh defines the target mesh
  100948. * @param scaleLines defines a scaling factor for line length (1 by default)
  100949. */
  100950. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100951. /**
  100952. * Force the viewer to update
  100953. */
  100954. update(): void;
  100955. /** Releases resources */
  100956. dispose(): void;
  100957. }
  100958. }
  100959. declare module BABYLON {
  100960. /**
  100961. * Interface used to define scene explorer extensibility option
  100962. */
  100963. export interface IExplorerExtensibilityOption {
  100964. /**
  100965. * Define the option label
  100966. */
  100967. label: string;
  100968. /**
  100969. * Defines the action to execute on click
  100970. */
  100971. action: (entity: any) => void;
  100972. }
  100973. /**
  100974. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100975. */
  100976. export interface IExplorerExtensibilityGroup {
  100977. /**
  100978. * Defines a predicate to test if a given type mut be extended
  100979. */
  100980. predicate: (entity: any) => boolean;
  100981. /**
  100982. * Gets the list of options added to a type
  100983. */
  100984. entries: IExplorerExtensibilityOption[];
  100985. }
  100986. /**
  100987. * Interface used to define the options to use to create the Inspector
  100988. */
  100989. export interface IInspectorOptions {
  100990. /**
  100991. * Display in overlay mode (default: false)
  100992. */
  100993. overlay?: boolean;
  100994. /**
  100995. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100996. */
  100997. globalRoot?: HTMLElement;
  100998. /**
  100999. * Display the Scene explorer
  101000. */
  101001. showExplorer?: boolean;
  101002. /**
  101003. * Display the property inspector
  101004. */
  101005. showInspector?: boolean;
  101006. /**
  101007. * Display in embed mode (both panes on the right)
  101008. */
  101009. embedMode?: boolean;
  101010. /**
  101011. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  101012. */
  101013. handleResize?: boolean;
  101014. /**
  101015. * Allow the panes to popup (default: true)
  101016. */
  101017. enablePopup?: boolean;
  101018. /**
  101019. * Allow the panes to be closed by users (default: true)
  101020. */
  101021. enableClose?: boolean;
  101022. /**
  101023. * Optional list of extensibility entries
  101024. */
  101025. explorerExtensibility?: IExplorerExtensibilityGroup[];
  101026. /**
  101027. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  101028. */
  101029. inspectorURL?: string;
  101030. }
  101031. interface Scene {
  101032. /**
  101033. * @hidden
  101034. * Backing field
  101035. */
  101036. _debugLayer: DebugLayer;
  101037. /**
  101038. * Gets the debug layer (aka Inspector) associated with the scene
  101039. * @see http://doc.babylonjs.com/features/playground_debuglayer
  101040. */
  101041. debugLayer: DebugLayer;
  101042. }
  101043. /**
  101044. * The debug layer (aka Inspector) is the go to tool in order to better understand
  101045. * what is happening in your scene
  101046. * @see http://doc.babylonjs.com/features/playground_debuglayer
  101047. */
  101048. export class DebugLayer {
  101049. /**
  101050. * Define the url to get the inspector script from.
  101051. * By default it uses the babylonjs CDN.
  101052. * @ignoreNaming
  101053. */
  101054. static InspectorURL: string;
  101055. private _scene;
  101056. private BJSINSPECTOR;
  101057. /**
  101058. * Observable triggered when a property is changed through the inspector.
  101059. */
  101060. onPropertyChangedObservable: Observable<{
  101061. object: any;
  101062. property: string;
  101063. value: any;
  101064. initialValue: any;
  101065. }>;
  101066. /**
  101067. * Instantiates a new debug layer.
  101068. * The debug layer (aka Inspector) is the go to tool in order to better understand
  101069. * what is happening in your scene
  101070. * @see http://doc.babylonjs.com/features/playground_debuglayer
  101071. * @param scene Defines the scene to inspect
  101072. */
  101073. constructor(scene: Scene);
  101074. /** Creates the inspector window. */
  101075. private _createInspector;
  101076. /**
  101077. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  101078. * @param entity defines the entity to select
  101079. * @param lineContainerTitle defines the specific block to highlight
  101080. */
  101081. select(entity: any, lineContainerTitle?: string): void;
  101082. /** Get the inspector from bundle or global */
  101083. private _getGlobalInspector;
  101084. /**
  101085. * Get if the inspector is visible or not.
  101086. * @returns true if visible otherwise, false
  101087. */
  101088. isVisible(): boolean;
  101089. /**
  101090. * Hide the inspector and close its window.
  101091. */
  101092. hide(): void;
  101093. /**
  101094. * Launch the debugLayer.
  101095. * @param config Define the configuration of the inspector
  101096. * @return a promise fulfilled when the debug layer is visible
  101097. */
  101098. show(config?: IInspectorOptions): Promise<DebugLayer>;
  101099. }
  101100. }
  101101. declare module BABYLON {
  101102. /**
  101103. * Class containing static functions to help procedurally build meshes
  101104. */
  101105. export class BoxBuilder {
  101106. /**
  101107. * Creates a box mesh
  101108. * * The parameter `size` sets the size (float) of each box side (default 1)
  101109. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  101110. * * 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)
  101111. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  101112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101115. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  101116. * @param name defines the name of the mesh
  101117. * @param options defines the options used to create the mesh
  101118. * @param scene defines the hosting scene
  101119. * @returns the box mesh
  101120. */
  101121. static CreateBox(name: string, options: {
  101122. size?: number;
  101123. width?: number;
  101124. height?: number;
  101125. depth?: number;
  101126. faceUV?: Vector4[];
  101127. faceColors?: Color4[];
  101128. sideOrientation?: number;
  101129. frontUVs?: Vector4;
  101130. backUVs?: Vector4;
  101131. wrap?: boolean;
  101132. topBaseAt?: number;
  101133. bottomBaseAt?: number;
  101134. updatable?: boolean;
  101135. }, scene?: Nullable<Scene>): Mesh;
  101136. }
  101137. }
  101138. declare module BABYLON {
  101139. /**
  101140. * Class containing static functions to help procedurally build meshes
  101141. */
  101142. export class SphereBuilder {
  101143. /**
  101144. * Creates a sphere mesh
  101145. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  101146. * * 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`)
  101147. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  101148. * * 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
  101149. * * 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)
  101150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101153. * @param name defines the name of the mesh
  101154. * @param options defines the options used to create the mesh
  101155. * @param scene defines the hosting scene
  101156. * @returns the sphere mesh
  101157. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  101158. */
  101159. static CreateSphere(name: string, options: {
  101160. segments?: number;
  101161. diameter?: number;
  101162. diameterX?: number;
  101163. diameterY?: number;
  101164. diameterZ?: number;
  101165. arc?: number;
  101166. slice?: number;
  101167. sideOrientation?: number;
  101168. frontUVs?: Vector4;
  101169. backUVs?: Vector4;
  101170. updatable?: boolean;
  101171. }, scene: any): Mesh;
  101172. }
  101173. }
  101174. declare module BABYLON.Debug {
  101175. /**
  101176. * Used to show the physics impostor around the specific mesh
  101177. */
  101178. export class PhysicsViewer {
  101179. /** @hidden */
  101180. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  101181. /** @hidden */
  101182. protected _meshes: Array<Nullable<AbstractMesh>>;
  101183. /** @hidden */
  101184. protected _scene: Nullable<Scene>;
  101185. /** @hidden */
  101186. protected _numMeshes: number;
  101187. /** @hidden */
  101188. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101189. private _renderFunction;
  101190. private _utilityLayer;
  101191. private _debugBoxMesh;
  101192. private _debugSphereMesh;
  101193. private _debugCylinderMesh;
  101194. private _debugMaterial;
  101195. private _debugMeshMeshes;
  101196. /**
  101197. * Creates a new PhysicsViewer
  101198. * @param scene defines the hosting scene
  101199. */
  101200. constructor(scene: Scene);
  101201. /** @hidden */
  101202. protected _updateDebugMeshes(): void;
  101203. /**
  101204. * Renders a specified physic impostor
  101205. * @param impostor defines the impostor to render
  101206. * @param targetMesh defines the mesh represented by the impostor
  101207. * @returns the new debug mesh used to render the impostor
  101208. */
  101209. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101210. /**
  101211. * Hides a specified physic impostor
  101212. * @param impostor defines the impostor to hide
  101213. */
  101214. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101215. private _getDebugMaterial;
  101216. private _getDebugBoxMesh;
  101217. private _getDebugSphereMesh;
  101218. private _getDebugCylinderMesh;
  101219. private _getDebugMeshMesh;
  101220. private _getDebugMesh;
  101221. /** Releases all resources */
  101222. dispose(): void;
  101223. }
  101224. }
  101225. declare module BABYLON {
  101226. /**
  101227. * Class containing static functions to help procedurally build meshes
  101228. */
  101229. export class LinesBuilder {
  101230. /**
  101231. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101232. * * 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
  101233. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101234. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101235. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101236. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101237. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101238. * * 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
  101239. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101242. * @param name defines the name of the new line system
  101243. * @param options defines the options used to create the line system
  101244. * @param scene defines the hosting scene
  101245. * @returns a new line system mesh
  101246. */
  101247. static CreateLineSystem(name: string, options: {
  101248. lines: Vector3[][];
  101249. updatable?: boolean;
  101250. instance?: Nullable<LinesMesh>;
  101251. colors?: Nullable<Color4[][]>;
  101252. useVertexAlpha?: boolean;
  101253. }, scene: Nullable<Scene>): LinesMesh;
  101254. /**
  101255. * Creates a line mesh
  101256. * 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
  101257. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101258. * * The parameter `points` is an array successive Vector3
  101259. * * 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
  101260. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101261. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101262. * * When updating an instance, remember that only point positions can change, not the number of points
  101263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101265. * @param name defines the name of the new line system
  101266. * @param options defines the options used to create the line system
  101267. * @param scene defines the hosting scene
  101268. * @returns a new line mesh
  101269. */
  101270. static CreateLines(name: string, options: {
  101271. points: Vector3[];
  101272. updatable?: boolean;
  101273. instance?: Nullable<LinesMesh>;
  101274. colors?: Color4[];
  101275. useVertexAlpha?: boolean;
  101276. }, scene?: Nullable<Scene>): LinesMesh;
  101277. /**
  101278. * Creates a dashed line mesh
  101279. * * 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
  101280. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101281. * * The parameter `points` is an array successive Vector3
  101282. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101283. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101284. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101285. * * 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
  101286. * * When updating an instance, remember that only point positions can change, not the number of points
  101287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101288. * @param name defines the name of the mesh
  101289. * @param options defines the options used to create the mesh
  101290. * @param scene defines the hosting scene
  101291. * @returns the dashed line mesh
  101292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101293. */
  101294. static CreateDashedLines(name: string, options: {
  101295. points: Vector3[];
  101296. dashSize?: number;
  101297. gapSize?: number;
  101298. dashNb?: number;
  101299. updatable?: boolean;
  101300. instance?: LinesMesh;
  101301. }, scene?: Nullable<Scene>): LinesMesh;
  101302. }
  101303. }
  101304. declare module BABYLON {
  101305. /**
  101306. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101307. * in order to better appreciate the issue one might have.
  101308. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101309. */
  101310. export class RayHelper {
  101311. /**
  101312. * Defines the ray we are currently tryin to visualize.
  101313. */
  101314. ray: Nullable<Ray>;
  101315. private _renderPoints;
  101316. private _renderLine;
  101317. private _renderFunction;
  101318. private _scene;
  101319. private _updateToMeshFunction;
  101320. private _attachedToMesh;
  101321. private _meshSpaceDirection;
  101322. private _meshSpaceOrigin;
  101323. /**
  101324. * Helper function to create a colored helper in a scene in one line.
  101325. * @param ray Defines the ray we are currently tryin to visualize
  101326. * @param scene Defines the scene the ray is used in
  101327. * @param color Defines the color we want to see the ray in
  101328. * @returns The newly created ray helper.
  101329. */
  101330. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101331. /**
  101332. * Instantiate a new ray helper.
  101333. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101334. * in order to better appreciate the issue one might have.
  101335. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101336. * @param ray Defines the ray we are currently tryin to visualize
  101337. */
  101338. constructor(ray: Ray);
  101339. /**
  101340. * Shows the ray we are willing to debug.
  101341. * @param scene Defines the scene the ray needs to be rendered in
  101342. * @param color Defines the color the ray needs to be rendered in
  101343. */
  101344. show(scene: Scene, color?: Color3): void;
  101345. /**
  101346. * Hides the ray we are debugging.
  101347. */
  101348. hide(): void;
  101349. private _render;
  101350. /**
  101351. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101352. * @param mesh Defines the mesh we want the helper attached to
  101353. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101354. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101355. * @param length Defines the length of the ray
  101356. */
  101357. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101358. /**
  101359. * Detach the ray helper from the mesh it has previously been attached to.
  101360. */
  101361. detachFromMesh(): void;
  101362. private _updateToMesh;
  101363. /**
  101364. * Dispose the helper and release its associated resources.
  101365. */
  101366. dispose(): void;
  101367. }
  101368. }
  101369. declare module BABYLON.Debug {
  101370. /**
  101371. * Class used to render a debug view of a given skeleton
  101372. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101373. */
  101374. export class SkeletonViewer {
  101375. /** defines the skeleton to render */
  101376. skeleton: Skeleton;
  101377. /** defines the mesh attached to the skeleton */
  101378. mesh: AbstractMesh;
  101379. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101380. autoUpdateBonesMatrices: boolean;
  101381. /** defines the rendering group id to use with the viewer */
  101382. renderingGroupId: number;
  101383. /** Gets or sets the color used to render the skeleton */
  101384. color: Color3;
  101385. private _scene;
  101386. private _debugLines;
  101387. private _debugMesh;
  101388. private _isEnabled;
  101389. private _renderFunction;
  101390. private _utilityLayer;
  101391. /**
  101392. * Returns the mesh used to render the bones
  101393. */
  101394. readonly debugMesh: Nullable<LinesMesh>;
  101395. /**
  101396. * Creates a new SkeletonViewer
  101397. * @param skeleton defines the skeleton to render
  101398. * @param mesh defines the mesh attached to the skeleton
  101399. * @param scene defines the hosting scene
  101400. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101401. * @param renderingGroupId defines the rendering group id to use with the viewer
  101402. */
  101403. constructor(
  101404. /** defines the skeleton to render */
  101405. skeleton: Skeleton,
  101406. /** defines the mesh attached to the skeleton */
  101407. mesh: AbstractMesh, scene: Scene,
  101408. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101409. autoUpdateBonesMatrices?: boolean,
  101410. /** defines the rendering group id to use with the viewer */
  101411. renderingGroupId?: number);
  101412. /** Gets or sets a boolean indicating if the viewer is enabled */
  101413. isEnabled: boolean;
  101414. private _getBonePosition;
  101415. private _getLinesForBonesWithLength;
  101416. private _getLinesForBonesNoLength;
  101417. /** Update the viewer to sync with current skeleton state */
  101418. update(): void;
  101419. /** Release associated resources */
  101420. dispose(): void;
  101421. }
  101422. }
  101423. declare module BABYLON {
  101424. /**
  101425. * Options to create the null engine
  101426. */
  101427. export class NullEngineOptions {
  101428. /**
  101429. * Render width (Default: 512)
  101430. */
  101431. renderWidth: number;
  101432. /**
  101433. * Render height (Default: 256)
  101434. */
  101435. renderHeight: number;
  101436. /**
  101437. * Texture size (Default: 512)
  101438. */
  101439. textureSize: number;
  101440. /**
  101441. * If delta time between frames should be constant
  101442. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101443. */
  101444. deterministicLockstep: boolean;
  101445. /**
  101446. * Maximum about of steps between frames (Default: 4)
  101447. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101448. */
  101449. lockstepMaxSteps: number;
  101450. }
  101451. /**
  101452. * The null engine class provides support for headless version of babylon.js.
  101453. * This can be used in server side scenario or for testing purposes
  101454. */
  101455. export class NullEngine extends Engine {
  101456. private _options;
  101457. /**
  101458. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101459. */
  101460. isDeterministicLockStep(): boolean;
  101461. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101462. getLockstepMaxSteps(): number;
  101463. /**
  101464. * Sets hardware scaling, used to save performance if needed
  101465. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101466. */
  101467. getHardwareScalingLevel(): number;
  101468. constructor(options?: NullEngineOptions);
  101469. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101470. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101471. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101472. getRenderWidth(useScreen?: boolean): number;
  101473. getRenderHeight(useScreen?: boolean): number;
  101474. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101475. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101476. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101477. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101478. bindSamplers(effect: Effect): void;
  101479. enableEffect(effect: Effect): void;
  101480. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101481. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101482. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101483. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101484. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101485. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101486. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101487. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101488. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101489. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101490. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101491. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101492. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101493. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101494. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101495. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101496. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101497. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101498. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101499. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101500. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101501. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101502. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101503. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101504. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101505. bindBuffers(vertexBuffers: {
  101506. [key: string]: VertexBuffer;
  101507. }, indexBuffer: DataBuffer, effect: Effect): void;
  101508. wipeCaches(bruteForce?: boolean): void;
  101509. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101510. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101511. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101512. /** @hidden */
  101513. _createTexture(): WebGLTexture;
  101514. /** @hidden */
  101515. _releaseTexture(texture: InternalTexture): void;
  101516. 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;
  101517. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101518. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101519. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101520. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101521. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101522. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101523. areAllEffectsReady(): boolean;
  101524. /**
  101525. * @hidden
  101526. * Get the current error code of the webGL context
  101527. * @returns the error code
  101528. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101529. */
  101530. getError(): number;
  101531. /** @hidden */
  101532. _getUnpackAlignement(): number;
  101533. /** @hidden */
  101534. _unpackFlipY(value: boolean): void;
  101535. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101536. /**
  101537. * Updates a dynamic vertex buffer.
  101538. * @param vertexBuffer the vertex buffer to update
  101539. * @param data the data used to update the vertex buffer
  101540. * @param byteOffset the byte offset of the data (optional)
  101541. * @param byteLength the byte length of the data (optional)
  101542. */
  101543. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101544. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101545. /** @hidden */
  101546. _bindTexture(channel: number, texture: InternalTexture): void;
  101547. /** @hidden */
  101548. _releaseBuffer(buffer: DataBuffer): boolean;
  101549. releaseEffects(): void;
  101550. displayLoadingUI(): void;
  101551. hideLoadingUI(): void;
  101552. /** @hidden */
  101553. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101554. /** @hidden */
  101555. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101556. /** @hidden */
  101557. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101558. /** @hidden */
  101559. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101560. }
  101561. }
  101562. declare module BABYLON {
  101563. /** @hidden */
  101564. export class _OcclusionDataStorage {
  101565. /** @hidden */
  101566. occlusionInternalRetryCounter: number;
  101567. /** @hidden */
  101568. isOcclusionQueryInProgress: boolean;
  101569. /** @hidden */
  101570. isOccluded: boolean;
  101571. /** @hidden */
  101572. occlusionRetryCount: number;
  101573. /** @hidden */
  101574. occlusionType: number;
  101575. /** @hidden */
  101576. occlusionQueryAlgorithmType: number;
  101577. }
  101578. interface Engine {
  101579. /**
  101580. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101581. * @return the new query
  101582. */
  101583. createQuery(): WebGLQuery;
  101584. /**
  101585. * Delete and release a webGL query
  101586. * @param query defines the query to delete
  101587. * @return the current engine
  101588. */
  101589. deleteQuery(query: WebGLQuery): Engine;
  101590. /**
  101591. * Check if a given query has resolved and got its value
  101592. * @param query defines the query to check
  101593. * @returns true if the query got its value
  101594. */
  101595. isQueryResultAvailable(query: WebGLQuery): boolean;
  101596. /**
  101597. * Gets the value of a given query
  101598. * @param query defines the query to check
  101599. * @returns the value of the query
  101600. */
  101601. getQueryResult(query: WebGLQuery): number;
  101602. /**
  101603. * Initiates an occlusion query
  101604. * @param algorithmType defines the algorithm to use
  101605. * @param query defines the query to use
  101606. * @returns the current engine
  101607. * @see http://doc.babylonjs.com/features/occlusionquery
  101608. */
  101609. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101610. /**
  101611. * Ends an occlusion query
  101612. * @see http://doc.babylonjs.com/features/occlusionquery
  101613. * @param algorithmType defines the algorithm to use
  101614. * @returns the current engine
  101615. */
  101616. endOcclusionQuery(algorithmType: number): Engine;
  101617. /**
  101618. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101619. * Please note that only one query can be issued at a time
  101620. * @returns a time token used to track the time span
  101621. */
  101622. startTimeQuery(): Nullable<_TimeToken>;
  101623. /**
  101624. * Ends a time query
  101625. * @param token defines the token used to measure the time span
  101626. * @returns the time spent (in ns)
  101627. */
  101628. endTimeQuery(token: _TimeToken): int;
  101629. /** @hidden */
  101630. _currentNonTimestampToken: Nullable<_TimeToken>;
  101631. /** @hidden */
  101632. _createTimeQuery(): WebGLQuery;
  101633. /** @hidden */
  101634. _deleteTimeQuery(query: WebGLQuery): void;
  101635. /** @hidden */
  101636. _getGlAlgorithmType(algorithmType: number): number;
  101637. /** @hidden */
  101638. _getTimeQueryResult(query: WebGLQuery): any;
  101639. /** @hidden */
  101640. _getTimeQueryAvailability(query: WebGLQuery): any;
  101641. }
  101642. interface AbstractMesh {
  101643. /**
  101644. * Backing filed
  101645. * @hidden
  101646. */
  101647. __occlusionDataStorage: _OcclusionDataStorage;
  101648. /**
  101649. * Access property
  101650. * @hidden
  101651. */
  101652. _occlusionDataStorage: _OcclusionDataStorage;
  101653. /**
  101654. * 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.
  101655. * The default value is -1 which means don't break the query and wait till the result
  101656. * @see http://doc.babylonjs.com/features/occlusionquery
  101657. */
  101658. occlusionRetryCount: number;
  101659. /**
  101660. * 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:
  101661. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101662. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101663. * * 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.
  101664. * @see http://doc.babylonjs.com/features/occlusionquery
  101665. */
  101666. occlusionType: number;
  101667. /**
  101668. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101669. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101670. * * 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.
  101671. * @see http://doc.babylonjs.com/features/occlusionquery
  101672. */
  101673. occlusionQueryAlgorithmType: number;
  101674. /**
  101675. * 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
  101676. * @see http://doc.babylonjs.com/features/occlusionquery
  101677. */
  101678. isOccluded: boolean;
  101679. /**
  101680. * Flag to check the progress status of the query
  101681. * @see http://doc.babylonjs.com/features/occlusionquery
  101682. */
  101683. isOcclusionQueryInProgress: boolean;
  101684. }
  101685. }
  101686. declare module BABYLON {
  101687. /** @hidden */
  101688. export var _forceTransformFeedbackToBundle: boolean;
  101689. interface Engine {
  101690. /**
  101691. * Creates a webGL transform feedback object
  101692. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101693. * @returns the webGL transform feedback object
  101694. */
  101695. createTransformFeedback(): WebGLTransformFeedback;
  101696. /**
  101697. * Delete a webGL transform feedback object
  101698. * @param value defines the webGL transform feedback object to delete
  101699. */
  101700. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101701. /**
  101702. * Bind a webGL transform feedback object to the webgl context
  101703. * @param value defines the webGL transform feedback object to bind
  101704. */
  101705. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101706. /**
  101707. * Begins a transform feedback operation
  101708. * @param usePoints defines if points or triangles must be used
  101709. */
  101710. beginTransformFeedback(usePoints: boolean): void;
  101711. /**
  101712. * Ends a transform feedback operation
  101713. */
  101714. endTransformFeedback(): void;
  101715. /**
  101716. * Specify the varyings to use with transform feedback
  101717. * @param program defines the associated webGL program
  101718. * @param value defines the list of strings representing the varying names
  101719. */
  101720. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101721. /**
  101722. * Bind a webGL buffer for a transform feedback operation
  101723. * @param value defines the webGL buffer to bind
  101724. */
  101725. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  101726. }
  101727. }
  101728. declare module BABYLON {
  101729. /**
  101730. * Creation options of the multi render target texture.
  101731. */
  101732. export interface IMultiRenderTargetOptions {
  101733. /**
  101734. * Define if the texture needs to create mip maps after render.
  101735. */
  101736. generateMipMaps?: boolean;
  101737. /**
  101738. * Define the types of all the draw buffers we want to create
  101739. */
  101740. types?: number[];
  101741. /**
  101742. * Define the sampling modes of all the draw buffers we want to create
  101743. */
  101744. samplingModes?: number[];
  101745. /**
  101746. * Define if a depth buffer is required
  101747. */
  101748. generateDepthBuffer?: boolean;
  101749. /**
  101750. * Define if a stencil buffer is required
  101751. */
  101752. generateStencilBuffer?: boolean;
  101753. /**
  101754. * Define if a depth texture is required instead of a depth buffer
  101755. */
  101756. generateDepthTexture?: boolean;
  101757. /**
  101758. * Define the number of desired draw buffers
  101759. */
  101760. textureCount?: number;
  101761. /**
  101762. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101763. */
  101764. doNotChangeAspectRatio?: boolean;
  101765. /**
  101766. * Define the default type of the buffers we are creating
  101767. */
  101768. defaultType?: number;
  101769. }
  101770. /**
  101771. * A multi render target, like a render target provides the ability to render to a texture.
  101772. * Unlike the render target, it can render to several draw buffers in one draw.
  101773. * This is specially interesting in deferred rendering or for any effects requiring more than
  101774. * just one color from a single pass.
  101775. */
  101776. export class MultiRenderTarget extends RenderTargetTexture {
  101777. private _internalTextures;
  101778. private _textures;
  101779. private _multiRenderTargetOptions;
  101780. /**
  101781. * Get if draw buffers are currently supported by the used hardware and browser.
  101782. */
  101783. readonly isSupported: boolean;
  101784. /**
  101785. * Get the list of textures generated by the multi render target.
  101786. */
  101787. readonly textures: Texture[];
  101788. /**
  101789. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101790. */
  101791. readonly depthTexture: Texture;
  101792. /**
  101793. * Set the wrapping mode on U of all the textures we are rendering to.
  101794. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101795. */
  101796. wrapU: number;
  101797. /**
  101798. * Set the wrapping mode on V of all the textures we are rendering to.
  101799. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101800. */
  101801. wrapV: number;
  101802. /**
  101803. * Instantiate a new multi render target texture.
  101804. * A multi render target, like a render target provides the ability to render to a texture.
  101805. * Unlike the render target, it can render to several draw buffers in one draw.
  101806. * This is specially interesting in deferred rendering or for any effects requiring more than
  101807. * just one color from a single pass.
  101808. * @param name Define the name of the texture
  101809. * @param size Define the size of the buffers to render to
  101810. * @param count Define the number of target we are rendering into
  101811. * @param scene Define the scene the texture belongs to
  101812. * @param options Define the options used to create the multi render target
  101813. */
  101814. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101815. /** @hidden */
  101816. _rebuild(): void;
  101817. private _createInternalTextures;
  101818. private _createTextures;
  101819. /**
  101820. * Define the number of samples used if MSAA is enabled.
  101821. */
  101822. samples: number;
  101823. /**
  101824. * Resize all the textures in the multi render target.
  101825. * Be carrefull as it will recreate all the data in the new texture.
  101826. * @param size Define the new size
  101827. */
  101828. resize(size: any): void;
  101829. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101830. /**
  101831. * Dispose the render targets and their associated resources
  101832. */
  101833. dispose(): void;
  101834. /**
  101835. * Release all the underlying texture used as draw buffers.
  101836. */
  101837. releaseInternalTextures(): void;
  101838. }
  101839. }
  101840. declare module BABYLON {
  101841. interface Engine {
  101842. /**
  101843. * Unbind a list of render target textures from the webGL context
  101844. * This is used only when drawBuffer extension or webGL2 are active
  101845. * @param textures defines the render target textures to unbind
  101846. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101847. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101848. */
  101849. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101850. /**
  101851. * Create a multi render target texture
  101852. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101853. * @param size defines the size of the texture
  101854. * @param options defines the creation options
  101855. * @returns the cube texture as an InternalTexture
  101856. */
  101857. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101858. /**
  101859. * Update the sample count for a given multiple render target texture
  101860. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101861. * @param textures defines the textures to update
  101862. * @param samples defines the sample count to set
  101863. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101864. */
  101865. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101866. }
  101867. }
  101868. declare module BABYLON {
  101869. /**
  101870. * Gather the list of clipboard event types as constants.
  101871. */
  101872. export class ClipboardEventTypes {
  101873. /**
  101874. * The clipboard event is fired when a copy command is active (pressed).
  101875. */
  101876. static readonly COPY: number;
  101877. /**
  101878. * The clipboard event is fired when a cut command is active (pressed).
  101879. */
  101880. static readonly CUT: number;
  101881. /**
  101882. * The clipboard event is fired when a paste command is active (pressed).
  101883. */
  101884. static readonly PASTE: number;
  101885. }
  101886. /**
  101887. * This class is used to store clipboard related info for the onClipboardObservable event.
  101888. */
  101889. export class ClipboardInfo {
  101890. /**
  101891. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101892. */
  101893. type: number;
  101894. /**
  101895. * Defines the related dom event
  101896. */
  101897. event: ClipboardEvent;
  101898. /**
  101899. *Creates an instance of ClipboardInfo.
  101900. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101901. * @param event Defines the related dom event
  101902. */
  101903. constructor(
  101904. /**
  101905. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101906. */
  101907. type: number,
  101908. /**
  101909. * Defines the related dom event
  101910. */
  101911. event: ClipboardEvent);
  101912. /**
  101913. * Get the clipboard event's type from the keycode.
  101914. * @param keyCode Defines the keyCode for the current keyboard event.
  101915. * @return {number}
  101916. */
  101917. static GetTypeFromCharacter(keyCode: number): number;
  101918. }
  101919. }
  101920. declare module BABYLON {
  101921. /**
  101922. * Class used to represent data loading progression
  101923. */
  101924. export class SceneLoaderProgressEvent {
  101925. /** defines if data length to load can be evaluated */
  101926. readonly lengthComputable: boolean;
  101927. /** defines the loaded data length */
  101928. readonly loaded: number;
  101929. /** defines the data length to load */
  101930. readonly total: number;
  101931. /**
  101932. * Create a new progress event
  101933. * @param lengthComputable defines if data length to load can be evaluated
  101934. * @param loaded defines the loaded data length
  101935. * @param total defines the data length to load
  101936. */
  101937. constructor(
  101938. /** defines if data length to load can be evaluated */
  101939. lengthComputable: boolean,
  101940. /** defines the loaded data length */
  101941. loaded: number,
  101942. /** defines the data length to load */
  101943. total: number);
  101944. /**
  101945. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101946. * @param event defines the source event
  101947. * @returns a new SceneLoaderProgressEvent
  101948. */
  101949. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101950. }
  101951. /**
  101952. * Interface used by SceneLoader plugins to define supported file extensions
  101953. */
  101954. export interface ISceneLoaderPluginExtensions {
  101955. /**
  101956. * Defines the list of supported extensions
  101957. */
  101958. [extension: string]: {
  101959. isBinary: boolean;
  101960. };
  101961. }
  101962. /**
  101963. * Interface used by SceneLoader plugin factory
  101964. */
  101965. export interface ISceneLoaderPluginFactory {
  101966. /**
  101967. * Defines the name of the factory
  101968. */
  101969. name: string;
  101970. /**
  101971. * Function called to create a new plugin
  101972. * @return the new plugin
  101973. */
  101974. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101975. /**
  101976. * Boolean indicating if the plugin can direct load specific data
  101977. */
  101978. canDirectLoad?: (data: string) => boolean;
  101979. }
  101980. /**
  101981. * Interface used to define a SceneLoader plugin
  101982. */
  101983. export interface ISceneLoaderPlugin {
  101984. /**
  101985. * The friendly name of this plugin.
  101986. */
  101987. name: string;
  101988. /**
  101989. * The file extensions supported by this plugin.
  101990. */
  101991. extensions: string | ISceneLoaderPluginExtensions;
  101992. /**
  101993. * Import meshes into a scene.
  101994. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101995. * @param scene The scene to import into
  101996. * @param data The data to import
  101997. * @param rootUrl The root url for scene and resources
  101998. * @param meshes The meshes array to import into
  101999. * @param particleSystems The particle systems array to import into
  102000. * @param skeletons The skeletons array to import into
  102001. * @param onError The callback when import fails
  102002. * @returns True if successful or false otherwise
  102003. */
  102004. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  102005. /**
  102006. * Load into a scene.
  102007. * @param scene The scene to load into
  102008. * @param data The data to import
  102009. * @param rootUrl The root url for scene and resources
  102010. * @param onError The callback when import fails
  102011. * @returns true if successful or false otherwise
  102012. */
  102013. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  102014. /**
  102015. * The callback that returns true if the data can be directly loaded.
  102016. */
  102017. canDirectLoad?: (data: string) => boolean;
  102018. /**
  102019. * The callback that allows custom handling of the root url based on the response url.
  102020. */
  102021. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  102022. /**
  102023. * Load into an asset container.
  102024. * @param scene The scene to load into
  102025. * @param data The data to import
  102026. * @param rootUrl The root url for scene and resources
  102027. * @param onError The callback when import fails
  102028. * @returns The loaded asset container
  102029. */
  102030. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  102031. }
  102032. /**
  102033. * Interface used to define an async SceneLoader plugin
  102034. */
  102035. export interface ISceneLoaderPluginAsync {
  102036. /**
  102037. * The friendly name of this plugin.
  102038. */
  102039. name: string;
  102040. /**
  102041. * The file extensions supported by this plugin.
  102042. */
  102043. extensions: string | ISceneLoaderPluginExtensions;
  102044. /**
  102045. * Import meshes into a scene.
  102046. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102047. * @param scene The scene to import into
  102048. * @param data The data to import
  102049. * @param rootUrl The root url for scene and resources
  102050. * @param onProgress The callback when the load progresses
  102051. * @param fileName Defines the name of the file to load
  102052. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  102053. */
  102054. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  102055. meshes: AbstractMesh[];
  102056. particleSystems: IParticleSystem[];
  102057. skeletons: Skeleton[];
  102058. animationGroups: AnimationGroup[];
  102059. }>;
  102060. /**
  102061. * Load into a scene.
  102062. * @param scene The scene to load into
  102063. * @param data The data to import
  102064. * @param rootUrl The root url for scene and resources
  102065. * @param onProgress The callback when the load progresses
  102066. * @param fileName Defines the name of the file to load
  102067. * @returns Nothing
  102068. */
  102069. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  102070. /**
  102071. * The callback that returns true if the data can be directly loaded.
  102072. */
  102073. canDirectLoad?: (data: string) => boolean;
  102074. /**
  102075. * The callback that allows custom handling of the root url based on the response url.
  102076. */
  102077. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  102078. /**
  102079. * Load into an asset container.
  102080. * @param scene The scene to load into
  102081. * @param data The data to import
  102082. * @param rootUrl The root url for scene and resources
  102083. * @param onProgress The callback when the load progresses
  102084. * @param fileName Defines the name of the file to load
  102085. * @returns The loaded asset container
  102086. */
  102087. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  102088. }
  102089. /**
  102090. * Class used to load scene from various file formats using registered plugins
  102091. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  102092. */
  102093. export class SceneLoader {
  102094. /**
  102095. * No logging while loading
  102096. */
  102097. static readonly NO_LOGGING: number;
  102098. /**
  102099. * Minimal logging while loading
  102100. */
  102101. static readonly MINIMAL_LOGGING: number;
  102102. /**
  102103. * Summary logging while loading
  102104. */
  102105. static readonly SUMMARY_LOGGING: number;
  102106. /**
  102107. * Detailled logging while loading
  102108. */
  102109. static readonly DETAILED_LOGGING: number;
  102110. /**
  102111. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102112. */
  102113. static ForceFullSceneLoadingForIncremental: boolean;
  102114. /**
  102115. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102116. */
  102117. static ShowLoadingScreen: boolean;
  102118. /**
  102119. * Defines the current logging level (while loading the scene)
  102120. * @ignorenaming
  102121. */
  102122. static loggingLevel: number;
  102123. /**
  102124. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102125. */
  102126. static CleanBoneMatrixWeights: boolean;
  102127. /**
  102128. * Event raised when a plugin is used to load a scene
  102129. */
  102130. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  102131. private static _registeredPlugins;
  102132. private static _getDefaultPlugin;
  102133. private static _getPluginForExtension;
  102134. private static _getPluginForDirectLoad;
  102135. private static _getPluginForFilename;
  102136. private static _getDirectLoad;
  102137. private static _loadData;
  102138. private static _getFileInfo;
  102139. /**
  102140. * Gets a plugin that can load the given extension
  102141. * @param extension defines the extension to load
  102142. * @returns a plugin or null if none works
  102143. */
  102144. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  102145. /**
  102146. * Gets a boolean indicating that the given extension can be loaded
  102147. * @param extension defines the extension to load
  102148. * @returns true if the extension is supported
  102149. */
  102150. static IsPluginForExtensionAvailable(extension: string): boolean;
  102151. /**
  102152. * Adds a new plugin to the list of registered plugins
  102153. * @param plugin defines the plugin to add
  102154. */
  102155. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  102156. /**
  102157. * Import meshes into a scene
  102158. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102159. * @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)
  102160. * @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)
  102161. * @param scene the instance of BABYLON.Scene to append to
  102162. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  102163. * @param onProgress a callback with a progress event for each file being loaded
  102164. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102165. * @param pluginExtension the extension used to determine the plugin
  102166. * @returns The loaded plugin
  102167. */
  102168. 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>;
  102169. /**
  102170. * Import meshes into a scene
  102171. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102172. * @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)
  102173. * @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)
  102174. * @param scene the instance of BABYLON.Scene to append to
  102175. * @param onProgress a callback with a progress event for each file being loaded
  102176. * @param pluginExtension the extension used to determine the plugin
  102177. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  102178. */
  102179. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  102180. meshes: AbstractMesh[];
  102181. particleSystems: IParticleSystem[];
  102182. skeletons: Skeleton[];
  102183. animationGroups: AnimationGroup[];
  102184. }>;
  102185. /**
  102186. * Load a scene
  102187. * @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)
  102188. * @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)
  102189. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102190. * @param onSuccess a callback with the scene when import succeeds
  102191. * @param onProgress a callback with a progress event for each file being loaded
  102192. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102193. * @param pluginExtension the extension used to determine the plugin
  102194. * @returns The loaded plugin
  102195. */
  102196. 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>;
  102197. /**
  102198. * Load a scene
  102199. * @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)
  102200. * @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)
  102201. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102202. * @param onProgress a callback with a progress event for each file being loaded
  102203. * @param pluginExtension the extension used to determine the plugin
  102204. * @returns The loaded scene
  102205. */
  102206. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102207. /**
  102208. * Append a scene
  102209. * @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)
  102210. * @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)
  102211. * @param scene is the instance of BABYLON.Scene to append to
  102212. * @param onSuccess a callback with the scene when import succeeds
  102213. * @param onProgress a callback with a progress event for each file being loaded
  102214. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102215. * @param pluginExtension the extension used to determine the plugin
  102216. * @returns The loaded plugin
  102217. */
  102218. 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>;
  102219. /**
  102220. * Append a scene
  102221. * @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)
  102222. * @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)
  102223. * @param scene is the instance of BABYLON.Scene to append to
  102224. * @param onProgress a callback with a progress event for each file being loaded
  102225. * @param pluginExtension the extension used to determine the plugin
  102226. * @returns The given scene
  102227. */
  102228. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102229. /**
  102230. * Load a scene into an asset container
  102231. * @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)
  102232. * @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)
  102233. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102234. * @param onSuccess a callback with the scene when import succeeds
  102235. * @param onProgress a callback with a progress event for each file being loaded
  102236. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102237. * @param pluginExtension the extension used to determine the plugin
  102238. * @returns The loaded plugin
  102239. */
  102240. 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>;
  102241. /**
  102242. * Load a scene into an asset container
  102243. * @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)
  102244. * @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)
  102245. * @param scene is the instance of Scene to append to
  102246. * @param onProgress a callback with a progress event for each file being loaded
  102247. * @param pluginExtension the extension used to determine the plugin
  102248. * @returns The loaded asset container
  102249. */
  102250. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102251. }
  102252. }
  102253. declare module BABYLON {
  102254. /**
  102255. * Google Daydream controller
  102256. */
  102257. export class DaydreamController extends WebVRController {
  102258. /**
  102259. * Base Url for the controller model.
  102260. */
  102261. static MODEL_BASE_URL: string;
  102262. /**
  102263. * File name for the controller model.
  102264. */
  102265. static MODEL_FILENAME: string;
  102266. /**
  102267. * Gamepad Id prefix used to identify Daydream Controller.
  102268. */
  102269. static readonly GAMEPAD_ID_PREFIX: string;
  102270. /**
  102271. * Creates a new DaydreamController from a gamepad
  102272. * @param vrGamepad the gamepad that the controller should be created from
  102273. */
  102274. constructor(vrGamepad: any);
  102275. /**
  102276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102277. * @param scene scene in which to add meshes
  102278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102279. */
  102280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102281. /**
  102282. * Called once for each button that changed state since the last frame
  102283. * @param buttonIdx Which button index changed
  102284. * @param state New state of the button
  102285. * @param changes Which properties on the state changed since last frame
  102286. */
  102287. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102288. }
  102289. }
  102290. declare module BABYLON {
  102291. /**
  102292. * Gear VR Controller
  102293. */
  102294. export class GearVRController extends WebVRController {
  102295. /**
  102296. * Base Url for the controller model.
  102297. */
  102298. static MODEL_BASE_URL: string;
  102299. /**
  102300. * File name for the controller model.
  102301. */
  102302. static MODEL_FILENAME: string;
  102303. /**
  102304. * Gamepad Id prefix used to identify this controller.
  102305. */
  102306. static readonly GAMEPAD_ID_PREFIX: string;
  102307. private readonly _buttonIndexToObservableNameMap;
  102308. /**
  102309. * Creates a new GearVRController from a gamepad
  102310. * @param vrGamepad the gamepad that the controller should be created from
  102311. */
  102312. constructor(vrGamepad: any);
  102313. /**
  102314. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102315. * @param scene scene in which to add meshes
  102316. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102317. */
  102318. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102319. /**
  102320. * Called once for each button that changed state since the last frame
  102321. * @param buttonIdx Which button index changed
  102322. * @param state New state of the button
  102323. * @param changes Which properties on the state changed since last frame
  102324. */
  102325. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102326. }
  102327. }
  102328. declare module BABYLON {
  102329. /**
  102330. * Generic Controller
  102331. */
  102332. export class GenericController extends WebVRController {
  102333. /**
  102334. * Base Url for the controller model.
  102335. */
  102336. static readonly MODEL_BASE_URL: string;
  102337. /**
  102338. * File name for the controller model.
  102339. */
  102340. static readonly MODEL_FILENAME: string;
  102341. /**
  102342. * Creates a new GenericController from a gamepad
  102343. * @param vrGamepad the gamepad that the controller should be created from
  102344. */
  102345. constructor(vrGamepad: any);
  102346. /**
  102347. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102348. * @param scene scene in which to add meshes
  102349. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102350. */
  102351. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102352. /**
  102353. * Called once for each button that changed state since the last frame
  102354. * @param buttonIdx Which button index changed
  102355. * @param state New state of the button
  102356. * @param changes Which properties on the state changed since last frame
  102357. */
  102358. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102359. }
  102360. }
  102361. declare module BABYLON {
  102362. /**
  102363. * Oculus Touch Controller
  102364. */
  102365. export class OculusTouchController extends WebVRController {
  102366. /**
  102367. * Base Url for the controller model.
  102368. */
  102369. static MODEL_BASE_URL: string;
  102370. /**
  102371. * File name for the left controller model.
  102372. */
  102373. static MODEL_LEFT_FILENAME: string;
  102374. /**
  102375. * File name for the right controller model.
  102376. */
  102377. static MODEL_RIGHT_FILENAME: string;
  102378. /**
  102379. * Fired when the secondary trigger on this controller is modified
  102380. */
  102381. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102382. /**
  102383. * Fired when the thumb rest on this controller is modified
  102384. */
  102385. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102386. /**
  102387. * Creates a new OculusTouchController from a gamepad
  102388. * @param vrGamepad the gamepad that the controller should be created from
  102389. */
  102390. constructor(vrGamepad: any);
  102391. /**
  102392. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102393. * @param scene scene in which to add meshes
  102394. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102395. */
  102396. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102397. /**
  102398. * Fired when the A button on this controller is modified
  102399. */
  102400. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102401. /**
  102402. * Fired when the B button on this controller is modified
  102403. */
  102404. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102405. /**
  102406. * Fired when the X button on this controller is modified
  102407. */
  102408. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102409. /**
  102410. * Fired when the Y button on this controller is modified
  102411. */
  102412. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102413. /**
  102414. * Called once for each button that changed state since the last frame
  102415. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102416. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102417. * 2) secondary trigger (same)
  102418. * 3) A (right) X (left), touch, pressed = value
  102419. * 4) B / Y
  102420. * 5) thumb rest
  102421. * @param buttonIdx Which button index changed
  102422. * @param state New state of the button
  102423. * @param changes Which properties on the state changed since last frame
  102424. */
  102425. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102426. }
  102427. }
  102428. declare module BABYLON {
  102429. /**
  102430. * Vive Controller
  102431. */
  102432. export class ViveController extends WebVRController {
  102433. /**
  102434. * Base Url for the controller model.
  102435. */
  102436. static MODEL_BASE_URL: string;
  102437. /**
  102438. * File name for the controller model.
  102439. */
  102440. static MODEL_FILENAME: string;
  102441. /**
  102442. * Creates a new ViveController from a gamepad
  102443. * @param vrGamepad the gamepad that the controller should be created from
  102444. */
  102445. constructor(vrGamepad: any);
  102446. /**
  102447. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102448. * @param scene scene in which to add meshes
  102449. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102450. */
  102451. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102452. /**
  102453. * Fired when the left button on this controller is modified
  102454. */
  102455. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102456. /**
  102457. * Fired when the right button on this controller is modified
  102458. */
  102459. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102460. /**
  102461. * Fired when the menu button on this controller is modified
  102462. */
  102463. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102464. /**
  102465. * Called once for each button that changed state since the last frame
  102466. * Vive mapping:
  102467. * 0: touchpad
  102468. * 1: trigger
  102469. * 2: left AND right buttons
  102470. * 3: menu button
  102471. * @param buttonIdx Which button index changed
  102472. * @param state New state of the button
  102473. * @param changes Which properties on the state changed since last frame
  102474. */
  102475. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102476. }
  102477. }
  102478. declare module BABYLON {
  102479. /**
  102480. * Defines the WindowsMotionController object that the state of the windows motion controller
  102481. */
  102482. export class WindowsMotionController extends WebVRController {
  102483. /**
  102484. * The base url used to load the left and right controller models
  102485. */
  102486. static MODEL_BASE_URL: string;
  102487. /**
  102488. * The name of the left controller model file
  102489. */
  102490. static MODEL_LEFT_FILENAME: string;
  102491. /**
  102492. * The name of the right controller model file
  102493. */
  102494. static MODEL_RIGHT_FILENAME: string;
  102495. /**
  102496. * The controller name prefix for this controller type
  102497. */
  102498. static readonly GAMEPAD_ID_PREFIX: string;
  102499. /**
  102500. * The controller id pattern for this controller type
  102501. */
  102502. private static readonly GAMEPAD_ID_PATTERN;
  102503. private _loadedMeshInfo;
  102504. private readonly _mapping;
  102505. /**
  102506. * Fired when the trackpad on this controller is clicked
  102507. */
  102508. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102509. /**
  102510. * Fired when the trackpad on this controller is modified
  102511. */
  102512. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102513. /**
  102514. * The current x and y values of this controller's trackpad
  102515. */
  102516. trackpad: StickValues;
  102517. /**
  102518. * Creates a new WindowsMotionController from a gamepad
  102519. * @param vrGamepad the gamepad that the controller should be created from
  102520. */
  102521. constructor(vrGamepad: any);
  102522. /**
  102523. * Fired when the trigger on this controller is modified
  102524. */
  102525. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102526. /**
  102527. * Fired when the menu button on this controller is modified
  102528. */
  102529. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102530. /**
  102531. * Fired when the grip button on this controller is modified
  102532. */
  102533. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102534. /**
  102535. * Fired when the thumbstick button on this controller is modified
  102536. */
  102537. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102538. /**
  102539. * Fired when the touchpad button on this controller is modified
  102540. */
  102541. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102542. /**
  102543. * Fired when the touchpad values on this controller are modified
  102544. */
  102545. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102546. private _updateTrackpad;
  102547. /**
  102548. * Called once per frame by the engine.
  102549. */
  102550. update(): void;
  102551. /**
  102552. * Called once for each button that changed state since the last frame
  102553. * @param buttonIdx Which button index changed
  102554. * @param state New state of the button
  102555. * @param changes Which properties on the state changed since last frame
  102556. */
  102557. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102558. /**
  102559. * Moves the buttons on the controller mesh based on their current state
  102560. * @param buttonName the name of the button to move
  102561. * @param buttonValue the value of the button which determines the buttons new position
  102562. */
  102563. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102564. /**
  102565. * Moves the axis on the controller mesh based on its current state
  102566. * @param axis the index of the axis
  102567. * @param axisValue the value of the axis which determines the meshes new position
  102568. * @hidden
  102569. */
  102570. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102571. /**
  102572. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102573. * @param scene scene in which to add meshes
  102574. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102575. */
  102576. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102577. /**
  102578. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102579. * can be transformed by button presses and axes values, based on this._mapping.
  102580. *
  102581. * @param scene scene in which the meshes exist
  102582. * @param meshes list of meshes that make up the controller model to process
  102583. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102584. */
  102585. private processModel;
  102586. private createMeshInfo;
  102587. /**
  102588. * Gets the ray of the controller in the direction the controller is pointing
  102589. * @param length the length the resulting ray should be
  102590. * @returns a ray in the direction the controller is pointing
  102591. */
  102592. getForwardRay(length?: number): Ray;
  102593. /**
  102594. * Disposes of the controller
  102595. */
  102596. dispose(): void;
  102597. }
  102598. }
  102599. declare module BABYLON {
  102600. /**
  102601. * Single axis scale gizmo
  102602. */
  102603. export class AxisScaleGizmo extends Gizmo {
  102604. private _coloredMaterial;
  102605. /**
  102606. * Drag behavior responsible for the gizmos dragging interactions
  102607. */
  102608. dragBehavior: PointerDragBehavior;
  102609. private _pointerObserver;
  102610. /**
  102611. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102612. */
  102613. snapDistance: number;
  102614. /**
  102615. * Event that fires each time the gizmo snaps to a new location.
  102616. * * snapDistance is the the change in distance
  102617. */
  102618. onSnapObservable: Observable<{
  102619. snapDistance: number;
  102620. }>;
  102621. /**
  102622. * If the scaling operation should be done on all axis (default: false)
  102623. */
  102624. uniformScaling: boolean;
  102625. /**
  102626. * Creates an AxisScaleGizmo
  102627. * @param gizmoLayer The utility layer the gizmo will be added to
  102628. * @param dragAxis The axis which the gizmo will be able to scale on
  102629. * @param color The color of the gizmo
  102630. */
  102631. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102632. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102633. /**
  102634. * Disposes of the gizmo
  102635. */
  102636. dispose(): void;
  102637. /**
  102638. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102639. * @param mesh The mesh to replace the default mesh of the gizmo
  102640. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102641. */
  102642. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102643. }
  102644. }
  102645. declare module BABYLON {
  102646. /**
  102647. * Bounding box gizmo
  102648. */
  102649. export class BoundingBoxGizmo extends Gizmo {
  102650. private _lineBoundingBox;
  102651. private _rotateSpheresParent;
  102652. private _scaleBoxesParent;
  102653. private _boundingDimensions;
  102654. private _renderObserver;
  102655. private _pointerObserver;
  102656. private _scaleDragSpeed;
  102657. private _tmpQuaternion;
  102658. private _tmpVector;
  102659. private _tmpRotationMatrix;
  102660. /**
  102661. * 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)
  102662. */
  102663. ignoreChildren: boolean;
  102664. /**
  102665. * 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)
  102666. */
  102667. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102668. /**
  102669. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102670. */
  102671. rotationSphereSize: number;
  102672. /**
  102673. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102674. */
  102675. scaleBoxSize: number;
  102676. /**
  102677. * 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)
  102678. */
  102679. fixedDragMeshScreenSize: boolean;
  102680. /**
  102681. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102682. */
  102683. fixedDragMeshScreenSizeDistanceFactor: number;
  102684. /**
  102685. * Fired when a rotation sphere or scale box is dragged
  102686. */
  102687. onDragStartObservable: Observable<{}>;
  102688. /**
  102689. * Fired when a scale box is dragged
  102690. */
  102691. onScaleBoxDragObservable: Observable<{}>;
  102692. /**
  102693. * Fired when a scale box drag is ended
  102694. */
  102695. onScaleBoxDragEndObservable: Observable<{}>;
  102696. /**
  102697. * Fired when a rotation sphere is dragged
  102698. */
  102699. onRotationSphereDragObservable: Observable<{}>;
  102700. /**
  102701. * Fired when a rotation sphere drag is ended
  102702. */
  102703. onRotationSphereDragEndObservable: Observable<{}>;
  102704. /**
  102705. * 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)
  102706. */
  102707. scalePivot: Nullable<Vector3>;
  102708. /**
  102709. * Mesh used as a pivot to rotate the attached mesh
  102710. */
  102711. private _anchorMesh;
  102712. private _existingMeshScale;
  102713. private _dragMesh;
  102714. private pointerDragBehavior;
  102715. private coloredMaterial;
  102716. private hoverColoredMaterial;
  102717. /**
  102718. * Sets the color of the bounding box gizmo
  102719. * @param color the color to set
  102720. */
  102721. setColor(color: Color3): void;
  102722. /**
  102723. * Creates an BoundingBoxGizmo
  102724. * @param gizmoLayer The utility layer the gizmo will be added to
  102725. * @param color The color of the gizmo
  102726. */
  102727. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102728. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102729. private _selectNode;
  102730. /**
  102731. * Updates the bounding box information for the Gizmo
  102732. */
  102733. updateBoundingBox(): void;
  102734. private _updateRotationSpheres;
  102735. private _updateScaleBoxes;
  102736. /**
  102737. * Enables rotation on the specified axis and disables rotation on the others
  102738. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102739. */
  102740. setEnabledRotationAxis(axis: string): void;
  102741. /**
  102742. * Enables/disables scaling
  102743. * @param enable if scaling should be enabled
  102744. */
  102745. setEnabledScaling(enable: boolean): void;
  102746. private _updateDummy;
  102747. /**
  102748. * Enables a pointer drag behavior on the bounding box of the gizmo
  102749. */
  102750. enableDragBehavior(): void;
  102751. /**
  102752. * Disposes of the gizmo
  102753. */
  102754. dispose(): void;
  102755. /**
  102756. * 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)
  102757. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102758. * @returns the bounding box mesh with the passed in mesh as a child
  102759. */
  102760. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102761. /**
  102762. * CustomMeshes are not supported by this gizmo
  102763. * @param mesh The mesh to replace the default mesh of the gizmo
  102764. */
  102765. setCustomMesh(mesh: Mesh): void;
  102766. }
  102767. }
  102768. declare module BABYLON {
  102769. /**
  102770. * Single plane rotation gizmo
  102771. */
  102772. export class PlaneRotationGizmo extends Gizmo {
  102773. /**
  102774. * Drag behavior responsible for the gizmos dragging interactions
  102775. */
  102776. dragBehavior: PointerDragBehavior;
  102777. private _pointerObserver;
  102778. /**
  102779. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102780. */
  102781. snapDistance: number;
  102782. /**
  102783. * Event that fires each time the gizmo snaps to a new location.
  102784. * * snapDistance is the the change in distance
  102785. */
  102786. onSnapObservable: Observable<{
  102787. snapDistance: number;
  102788. }>;
  102789. /**
  102790. * Creates a PlaneRotationGizmo
  102791. * @param gizmoLayer The utility layer the gizmo will be added to
  102792. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102793. * @param color The color of the gizmo
  102794. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102795. */
  102796. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102797. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102798. /**
  102799. * Disposes of the gizmo
  102800. */
  102801. dispose(): void;
  102802. }
  102803. }
  102804. declare module BABYLON {
  102805. /**
  102806. * Gizmo that enables rotating a mesh along 3 axis
  102807. */
  102808. export class RotationGizmo extends Gizmo {
  102809. /**
  102810. * Internal gizmo used for interactions on the x axis
  102811. */
  102812. xGizmo: PlaneRotationGizmo;
  102813. /**
  102814. * Internal gizmo used for interactions on the y axis
  102815. */
  102816. yGizmo: PlaneRotationGizmo;
  102817. /**
  102818. * Internal gizmo used for interactions on the z axis
  102819. */
  102820. zGizmo: PlaneRotationGizmo;
  102821. /** Fires an event when any of it's sub gizmos are dragged */
  102822. onDragStartObservable: Observable<{}>;
  102823. /** Fires an event when any of it's sub gizmos are released from dragging */
  102824. onDragEndObservable: Observable<{}>;
  102825. attachedMesh: Nullable<AbstractMesh>;
  102826. /**
  102827. * Creates a RotationGizmo
  102828. * @param gizmoLayer The utility layer the gizmo will be added to
  102829. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102830. */
  102831. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102832. updateGizmoRotationToMatchAttachedMesh: boolean;
  102833. /**
  102834. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102835. */
  102836. snapDistance: number;
  102837. /**
  102838. * Ratio for the scale of the gizmo (Default: 1)
  102839. */
  102840. scaleRatio: number;
  102841. /**
  102842. * Disposes of the gizmo
  102843. */
  102844. dispose(): void;
  102845. /**
  102846. * CustomMeshes are not supported by this gizmo
  102847. * @param mesh The mesh to replace the default mesh of the gizmo
  102848. */
  102849. setCustomMesh(mesh: Mesh): void;
  102850. }
  102851. }
  102852. declare module BABYLON {
  102853. /**
  102854. * Gizmo that enables dragging a mesh along 3 axis
  102855. */
  102856. export class PositionGizmo extends Gizmo {
  102857. /**
  102858. * Internal gizmo used for interactions on the x axis
  102859. */
  102860. xGizmo: AxisDragGizmo;
  102861. /**
  102862. * Internal gizmo used for interactions on the y axis
  102863. */
  102864. yGizmo: AxisDragGizmo;
  102865. /**
  102866. * Internal gizmo used for interactions on the z axis
  102867. */
  102868. zGizmo: AxisDragGizmo;
  102869. /** Fires an event when any of it's sub gizmos are dragged */
  102870. onDragStartObservable: Observable<{}>;
  102871. /** Fires an event when any of it's sub gizmos are released from dragging */
  102872. onDragEndObservable: Observable<{}>;
  102873. attachedMesh: Nullable<AbstractMesh>;
  102874. /**
  102875. * Creates a PositionGizmo
  102876. * @param gizmoLayer The utility layer the gizmo will be added to
  102877. */
  102878. constructor(gizmoLayer?: UtilityLayerRenderer);
  102879. updateGizmoRotationToMatchAttachedMesh: boolean;
  102880. /**
  102881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102882. */
  102883. snapDistance: number;
  102884. /**
  102885. * Ratio for the scale of the gizmo (Default: 1)
  102886. */
  102887. scaleRatio: number;
  102888. /**
  102889. * Disposes of the gizmo
  102890. */
  102891. dispose(): void;
  102892. /**
  102893. * CustomMeshes are not supported by this gizmo
  102894. * @param mesh The mesh to replace the default mesh of the gizmo
  102895. */
  102896. setCustomMesh(mesh: Mesh): void;
  102897. }
  102898. }
  102899. declare module BABYLON {
  102900. /**
  102901. * Class containing static functions to help procedurally build meshes
  102902. */
  102903. export class PolyhedronBuilder {
  102904. /**
  102905. * Creates a polyhedron mesh
  102906. * * 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
  102907. * * The parameter `size` (positive float, default 1) sets the polygon size
  102908. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102909. * * 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`
  102910. * * 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
  102911. * * 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)`)
  102912. * * 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
  102913. * * 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
  102914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102917. * @param name defines the name of the mesh
  102918. * @param options defines the options used to create the mesh
  102919. * @param scene defines the hosting scene
  102920. * @returns the polyhedron mesh
  102921. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102922. */
  102923. static CreatePolyhedron(name: string, options: {
  102924. type?: number;
  102925. size?: number;
  102926. sizeX?: number;
  102927. sizeY?: number;
  102928. sizeZ?: number;
  102929. custom?: any;
  102930. faceUV?: Vector4[];
  102931. faceColors?: Color4[];
  102932. flat?: boolean;
  102933. updatable?: boolean;
  102934. sideOrientation?: number;
  102935. frontUVs?: Vector4;
  102936. backUVs?: Vector4;
  102937. }, scene?: Nullable<Scene>): Mesh;
  102938. }
  102939. }
  102940. declare module BABYLON {
  102941. /**
  102942. * Gizmo that enables scaling a mesh along 3 axis
  102943. */
  102944. export class ScaleGizmo extends Gizmo {
  102945. /**
  102946. * Internal gizmo used for interactions on the x axis
  102947. */
  102948. xGizmo: AxisScaleGizmo;
  102949. /**
  102950. * Internal gizmo used for interactions on the y axis
  102951. */
  102952. yGizmo: AxisScaleGizmo;
  102953. /**
  102954. * Internal gizmo used for interactions on the z axis
  102955. */
  102956. zGizmo: AxisScaleGizmo;
  102957. /**
  102958. * Internal gizmo used to scale all axis equally
  102959. */
  102960. uniformScaleGizmo: AxisScaleGizmo;
  102961. /** Fires an event when any of it's sub gizmos are dragged */
  102962. onDragStartObservable: Observable<{}>;
  102963. /** Fires an event when any of it's sub gizmos are released from dragging */
  102964. onDragEndObservable: Observable<{}>;
  102965. attachedMesh: Nullable<AbstractMesh>;
  102966. /**
  102967. * Creates a ScaleGizmo
  102968. * @param gizmoLayer The utility layer the gizmo will be added to
  102969. */
  102970. constructor(gizmoLayer?: UtilityLayerRenderer);
  102971. updateGizmoRotationToMatchAttachedMesh: boolean;
  102972. /**
  102973. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102974. */
  102975. snapDistance: number;
  102976. /**
  102977. * Ratio for the scale of the gizmo (Default: 1)
  102978. */
  102979. scaleRatio: number;
  102980. /**
  102981. * Disposes of the gizmo
  102982. */
  102983. dispose(): void;
  102984. }
  102985. }
  102986. declare module BABYLON {
  102987. /**
  102988. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102989. */
  102990. export class GizmoManager implements IDisposable {
  102991. private scene;
  102992. /**
  102993. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102994. */
  102995. gizmos: {
  102996. positionGizmo: Nullable<PositionGizmo>;
  102997. rotationGizmo: Nullable<RotationGizmo>;
  102998. scaleGizmo: Nullable<ScaleGizmo>;
  102999. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  103000. };
  103001. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  103002. clearGizmoOnEmptyPointerEvent: boolean;
  103003. /** Fires an event when the manager is attached to a mesh */
  103004. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  103005. private _gizmosEnabled;
  103006. private _pointerObserver;
  103007. private _attachedMesh;
  103008. private _boundingBoxColor;
  103009. private _defaultUtilityLayer;
  103010. private _defaultKeepDepthUtilityLayer;
  103011. /**
  103012. * When bounding box gizmo is enabled, this can be used to track drag/end events
  103013. */
  103014. boundingBoxDragBehavior: SixDofDragBehavior;
  103015. /**
  103016. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  103017. */
  103018. attachableMeshes: Nullable<Array<AbstractMesh>>;
  103019. /**
  103020. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  103021. */
  103022. usePointerToAttachGizmos: boolean;
  103023. /**
  103024. * Instatiates a gizmo manager
  103025. * @param scene the scene to overlay the gizmos on top of
  103026. */
  103027. constructor(scene: Scene);
  103028. /**
  103029. * Attaches a set of gizmos to the specified mesh
  103030. * @param mesh The mesh the gizmo's should be attached to
  103031. */
  103032. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  103033. /**
  103034. * If the position gizmo is enabled
  103035. */
  103036. positionGizmoEnabled: boolean;
  103037. /**
  103038. * If the rotation gizmo is enabled
  103039. */
  103040. rotationGizmoEnabled: boolean;
  103041. /**
  103042. * If the scale gizmo is enabled
  103043. */
  103044. scaleGizmoEnabled: boolean;
  103045. /**
  103046. * If the boundingBox gizmo is enabled
  103047. */
  103048. boundingBoxGizmoEnabled: boolean;
  103049. /**
  103050. * Disposes of the gizmo manager
  103051. */
  103052. dispose(): void;
  103053. }
  103054. }
  103055. declare module BABYLON {
  103056. /**
  103057. * A directional light is defined by a direction (what a surprise!).
  103058. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103059. * 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.
  103060. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103061. */
  103062. export class DirectionalLight extends ShadowLight {
  103063. private _shadowFrustumSize;
  103064. /**
  103065. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103066. */
  103067. /**
  103068. * Specifies a fix frustum size for the shadow generation.
  103069. */
  103070. shadowFrustumSize: number;
  103071. private _shadowOrthoScale;
  103072. /**
  103073. * Gets the shadow projection scale against the optimal computed one.
  103074. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103075. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103076. */
  103077. /**
  103078. * Sets the shadow projection scale against the optimal computed one.
  103079. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103080. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103081. */
  103082. shadowOrthoScale: number;
  103083. /**
  103084. * Automatically compute the projection matrix to best fit (including all the casters)
  103085. * on each frame.
  103086. */
  103087. autoUpdateExtends: boolean;
  103088. private _orthoLeft;
  103089. private _orthoRight;
  103090. private _orthoTop;
  103091. private _orthoBottom;
  103092. /**
  103093. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  103094. * The directional light is emitted from everywhere in the given direction.
  103095. * It can cast shadows.
  103096. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103097. * @param name The friendly name of the light
  103098. * @param direction The direction of the light
  103099. * @param scene The scene the light belongs to
  103100. */
  103101. constructor(name: string, direction: Vector3, scene: Scene);
  103102. /**
  103103. * Returns the string "DirectionalLight".
  103104. * @return The class name
  103105. */
  103106. getClassName(): string;
  103107. /**
  103108. * Returns the integer 1.
  103109. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103110. */
  103111. getTypeID(): number;
  103112. /**
  103113. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  103114. * Returns the DirectionalLight Shadow projection matrix.
  103115. */
  103116. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103117. /**
  103118. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  103119. * Returns the DirectionalLight Shadow projection matrix.
  103120. */
  103121. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  103122. /**
  103123. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  103124. * Returns the DirectionalLight Shadow projection matrix.
  103125. */
  103126. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103127. protected _buildUniformLayout(): void;
  103128. /**
  103129. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  103130. * @param effect The effect to update
  103131. * @param lightIndex The index of the light in the effect to update
  103132. * @returns The directional light
  103133. */
  103134. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  103135. /**
  103136. * Gets the minZ used for shadow according to both the scene and the light.
  103137. *
  103138. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103139. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103140. * @param activeCamera The camera we are returning the min for
  103141. * @returns the depth min z
  103142. */
  103143. getDepthMinZ(activeCamera: Camera): number;
  103144. /**
  103145. * Gets the maxZ used for shadow according to both the scene and the light.
  103146. *
  103147. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103148. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103149. * @param activeCamera The camera we are returning the max for
  103150. * @returns the depth max z
  103151. */
  103152. getDepthMaxZ(activeCamera: Camera): number;
  103153. /**
  103154. * Prepares the list of defines specific to the light type.
  103155. * @param defines the list of defines
  103156. * @param lightIndex defines the index of the light for the effect
  103157. */
  103158. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103159. }
  103160. }
  103161. declare module BABYLON {
  103162. /**
  103163. * Class containing static functions to help procedurally build meshes
  103164. */
  103165. export class HemisphereBuilder {
  103166. /**
  103167. * Creates a hemisphere mesh
  103168. * @param name defines the name of the mesh
  103169. * @param options defines the options used to create the mesh
  103170. * @param scene defines the hosting scene
  103171. * @returns the hemisphere mesh
  103172. */
  103173. static CreateHemisphere(name: string, options: {
  103174. segments?: number;
  103175. diameter?: number;
  103176. sideOrientation?: number;
  103177. }, scene: any): Mesh;
  103178. }
  103179. }
  103180. declare module BABYLON {
  103181. /**
  103182. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103183. * These values define a cone of light starting from the position, emitting toward the direction.
  103184. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103185. * and the exponent defines the speed of the decay of the light with distance (reach).
  103186. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103187. */
  103188. export class SpotLight extends ShadowLight {
  103189. private _angle;
  103190. private _innerAngle;
  103191. private _cosHalfAngle;
  103192. private _lightAngleScale;
  103193. private _lightAngleOffset;
  103194. /**
  103195. * Gets the cone angle of the spot light in Radians.
  103196. */
  103197. /**
  103198. * Sets the cone angle of the spot light in Radians.
  103199. */
  103200. angle: number;
  103201. /**
  103202. * Only used in gltf falloff mode, this defines the angle where
  103203. * the directional falloff will start before cutting at angle which could be seen
  103204. * as outer angle.
  103205. */
  103206. /**
  103207. * Only used in gltf falloff mode, this defines the angle where
  103208. * the directional falloff will start before cutting at angle which could be seen
  103209. * as outer angle.
  103210. */
  103211. innerAngle: number;
  103212. private _shadowAngleScale;
  103213. /**
  103214. * Allows scaling the angle of the light for shadow generation only.
  103215. */
  103216. /**
  103217. * Allows scaling the angle of the light for shadow generation only.
  103218. */
  103219. shadowAngleScale: number;
  103220. /**
  103221. * The light decay speed with the distance from the emission spot.
  103222. */
  103223. exponent: number;
  103224. private _projectionTextureMatrix;
  103225. /**
  103226. * Allows reading the projecton texture
  103227. */
  103228. readonly projectionTextureMatrix: Matrix;
  103229. protected _projectionTextureLightNear: number;
  103230. /**
  103231. * Gets the near clip of the Spotlight for texture projection.
  103232. */
  103233. /**
  103234. * Sets the near clip of the Spotlight for texture projection.
  103235. */
  103236. projectionTextureLightNear: number;
  103237. protected _projectionTextureLightFar: number;
  103238. /**
  103239. * Gets the far clip of the Spotlight for texture projection.
  103240. */
  103241. /**
  103242. * Sets the far clip of the Spotlight for texture projection.
  103243. */
  103244. projectionTextureLightFar: number;
  103245. protected _projectionTextureUpDirection: Vector3;
  103246. /**
  103247. * Gets the Up vector of the Spotlight for texture projection.
  103248. */
  103249. /**
  103250. * Sets the Up vector of the Spotlight for texture projection.
  103251. */
  103252. projectionTextureUpDirection: Vector3;
  103253. private _projectionTexture;
  103254. /**
  103255. * Gets the projection texture of the light.
  103256. */
  103257. /**
  103258. * Sets the projection texture of the light.
  103259. */
  103260. projectionTexture: Nullable<BaseTexture>;
  103261. private _projectionTextureViewLightDirty;
  103262. private _projectionTextureProjectionLightDirty;
  103263. private _projectionTextureDirty;
  103264. private _projectionTextureViewTargetVector;
  103265. private _projectionTextureViewLightMatrix;
  103266. private _projectionTextureProjectionLightMatrix;
  103267. private _projectionTextureScalingMatrix;
  103268. /**
  103269. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103270. * It can cast shadows.
  103271. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103272. * @param name The light friendly name
  103273. * @param position The position of the spot light in the scene
  103274. * @param direction The direction of the light in the scene
  103275. * @param angle The cone angle of the light in Radians
  103276. * @param exponent The light decay speed with the distance from the emission spot
  103277. * @param scene The scene the lights belongs to
  103278. */
  103279. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103280. /**
  103281. * Returns the string "SpotLight".
  103282. * @returns the class name
  103283. */
  103284. getClassName(): string;
  103285. /**
  103286. * Returns the integer 2.
  103287. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103288. */
  103289. getTypeID(): number;
  103290. /**
  103291. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103292. */
  103293. protected _setDirection(value: Vector3): void;
  103294. /**
  103295. * Overrides the position setter to recompute the projection texture view light Matrix.
  103296. */
  103297. protected _setPosition(value: Vector3): void;
  103298. /**
  103299. * 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.
  103300. * Returns the SpotLight.
  103301. */
  103302. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103303. protected _computeProjectionTextureViewLightMatrix(): void;
  103304. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103305. /**
  103306. * Main function for light texture projection matrix computing.
  103307. */
  103308. protected _computeProjectionTextureMatrix(): void;
  103309. protected _buildUniformLayout(): void;
  103310. private _computeAngleValues;
  103311. /**
  103312. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103313. * @param effect The effect to update
  103314. * @param lightIndex The index of the light in the effect to update
  103315. * @returns The spot light
  103316. */
  103317. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103318. /**
  103319. * Disposes the light and the associated resources.
  103320. */
  103321. dispose(): void;
  103322. /**
  103323. * Prepares the list of defines specific to the light type.
  103324. * @param defines the list of defines
  103325. * @param lightIndex defines the index of the light for the effect
  103326. */
  103327. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103328. }
  103329. }
  103330. declare module BABYLON {
  103331. /**
  103332. * Gizmo that enables viewing a light
  103333. */
  103334. export class LightGizmo extends Gizmo {
  103335. private _lightMesh;
  103336. private _material;
  103337. private cachedPosition;
  103338. private cachedForward;
  103339. /**
  103340. * Creates a LightGizmo
  103341. * @param gizmoLayer The utility layer the gizmo will be added to
  103342. */
  103343. constructor(gizmoLayer?: UtilityLayerRenderer);
  103344. private _light;
  103345. /**
  103346. * The light that the gizmo is attached to
  103347. */
  103348. light: Nullable<Light>;
  103349. /**
  103350. * @hidden
  103351. * Updates the gizmo to match the attached mesh's position/rotation
  103352. */
  103353. protected _update(): void;
  103354. private static _Scale;
  103355. /**
  103356. * Creates the lines for a light mesh
  103357. */
  103358. private static _createLightLines;
  103359. /**
  103360. * Disposes of the light gizmo
  103361. */
  103362. dispose(): void;
  103363. private static _CreateHemisphericLightMesh;
  103364. private static _CreatePointLightMesh;
  103365. private static _CreateSpotLightMesh;
  103366. private static _CreateDirectionalLightMesh;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /** @hidden */
  103371. export var backgroundFragmentDeclaration: {
  103372. name: string;
  103373. shader: string;
  103374. };
  103375. }
  103376. declare module BABYLON {
  103377. /** @hidden */
  103378. export var backgroundUboDeclaration: {
  103379. name: string;
  103380. shader: string;
  103381. };
  103382. }
  103383. declare module BABYLON {
  103384. /** @hidden */
  103385. export var backgroundPixelShader: {
  103386. name: string;
  103387. shader: string;
  103388. };
  103389. }
  103390. declare module BABYLON {
  103391. /** @hidden */
  103392. export var backgroundVertexDeclaration: {
  103393. name: string;
  103394. shader: string;
  103395. };
  103396. }
  103397. declare module BABYLON {
  103398. /** @hidden */
  103399. export var backgroundVertexShader: {
  103400. name: string;
  103401. shader: string;
  103402. };
  103403. }
  103404. declare module BABYLON {
  103405. /**
  103406. * Background material used to create an efficient environement around your scene.
  103407. */
  103408. export class BackgroundMaterial extends PushMaterial {
  103409. /**
  103410. * Standard reflectance value at parallel view angle.
  103411. */
  103412. static StandardReflectance0: number;
  103413. /**
  103414. * Standard reflectance value at grazing angle.
  103415. */
  103416. static StandardReflectance90: number;
  103417. protected _primaryColor: Color3;
  103418. /**
  103419. * Key light Color (multiply against the environement texture)
  103420. */
  103421. primaryColor: Color3;
  103422. protected __perceptualColor: Nullable<Color3>;
  103423. /**
  103424. * Experimental Internal Use Only.
  103425. *
  103426. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103427. * This acts as a helper to set the primary color to a more "human friendly" value.
  103428. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103429. * output color as close as possible from the chosen value.
  103430. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103431. * part of lighting setup.)
  103432. */
  103433. _perceptualColor: Nullable<Color3>;
  103434. protected _primaryColorShadowLevel: float;
  103435. /**
  103436. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103437. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103438. */
  103439. primaryColorShadowLevel: float;
  103440. protected _primaryColorHighlightLevel: float;
  103441. /**
  103442. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103443. * The primary color is used at the level chosen to define what the white area would look.
  103444. */
  103445. primaryColorHighlightLevel: float;
  103446. protected _reflectionTexture: Nullable<BaseTexture>;
  103447. /**
  103448. * Reflection Texture used in the material.
  103449. * Should be author in a specific way for the best result (refer to the documentation).
  103450. */
  103451. reflectionTexture: Nullable<BaseTexture>;
  103452. protected _reflectionBlur: float;
  103453. /**
  103454. * Reflection Texture level of blur.
  103455. *
  103456. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103457. * texture twice.
  103458. */
  103459. reflectionBlur: float;
  103460. protected _diffuseTexture: Nullable<BaseTexture>;
  103461. /**
  103462. * Diffuse Texture used in the material.
  103463. * Should be author in a specific way for the best result (refer to the documentation).
  103464. */
  103465. diffuseTexture: Nullable<BaseTexture>;
  103466. protected _shadowLights: Nullable<IShadowLight[]>;
  103467. /**
  103468. * Specify the list of lights casting shadow on the material.
  103469. * All scene shadow lights will be included if null.
  103470. */
  103471. shadowLights: Nullable<IShadowLight[]>;
  103472. protected _shadowLevel: float;
  103473. /**
  103474. * Helps adjusting the shadow to a softer level if required.
  103475. * 0 means black shadows and 1 means no shadows.
  103476. */
  103477. shadowLevel: float;
  103478. protected _sceneCenter: Vector3;
  103479. /**
  103480. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103481. * It is usually zero but might be interesting to modify according to your setup.
  103482. */
  103483. sceneCenter: Vector3;
  103484. protected _opacityFresnel: boolean;
  103485. /**
  103486. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103487. * This helps ensuring a nice transition when the camera goes under the ground.
  103488. */
  103489. opacityFresnel: boolean;
  103490. protected _reflectionFresnel: boolean;
  103491. /**
  103492. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103493. * This helps adding a mirror texture on the ground.
  103494. */
  103495. reflectionFresnel: boolean;
  103496. protected _reflectionFalloffDistance: number;
  103497. /**
  103498. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103499. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103500. */
  103501. reflectionFalloffDistance: number;
  103502. protected _reflectionAmount: number;
  103503. /**
  103504. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103505. */
  103506. reflectionAmount: number;
  103507. protected _reflectionReflectance0: number;
  103508. /**
  103509. * This specifies the weight of the reflection at grazing angle.
  103510. */
  103511. reflectionReflectance0: number;
  103512. protected _reflectionReflectance90: number;
  103513. /**
  103514. * This specifies the weight of the reflection at a perpendicular point of view.
  103515. */
  103516. reflectionReflectance90: number;
  103517. /**
  103518. * Sets the reflection reflectance fresnel values according to the default standard
  103519. * empirically know to work well :-)
  103520. */
  103521. reflectionStandardFresnelWeight: number;
  103522. protected _useRGBColor: boolean;
  103523. /**
  103524. * Helps to directly use the maps channels instead of their level.
  103525. */
  103526. useRGBColor: boolean;
  103527. protected _enableNoise: boolean;
  103528. /**
  103529. * This helps reducing the banding effect that could occur on the background.
  103530. */
  103531. enableNoise: boolean;
  103532. /**
  103533. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103534. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103535. * Recommended to be keep at 1.0 except for special cases.
  103536. */
  103537. fovMultiplier: number;
  103538. private _fovMultiplier;
  103539. /**
  103540. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103541. */
  103542. useEquirectangularFOV: boolean;
  103543. private _maxSimultaneousLights;
  103544. /**
  103545. * Number of Simultaneous lights allowed on the material.
  103546. */
  103547. maxSimultaneousLights: int;
  103548. /**
  103549. * Default configuration related to image processing available in the Background Material.
  103550. */
  103551. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103552. /**
  103553. * Keep track of the image processing observer to allow dispose and replace.
  103554. */
  103555. private _imageProcessingObserver;
  103556. /**
  103557. * Attaches a new image processing configuration to the PBR Material.
  103558. * @param configuration (if null the scene configuration will be use)
  103559. */
  103560. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103561. /**
  103562. * Gets the image processing configuration used either in this material.
  103563. */
  103564. /**
  103565. * Sets the Default image processing configuration used either in the this material.
  103566. *
  103567. * If sets to null, the scene one is in use.
  103568. */
  103569. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103570. /**
  103571. * Gets wether the color curves effect is enabled.
  103572. */
  103573. /**
  103574. * Sets wether the color curves effect is enabled.
  103575. */
  103576. cameraColorCurvesEnabled: boolean;
  103577. /**
  103578. * Gets wether the color grading effect is enabled.
  103579. */
  103580. /**
  103581. * Gets wether the color grading effect is enabled.
  103582. */
  103583. cameraColorGradingEnabled: boolean;
  103584. /**
  103585. * Gets wether tonemapping is enabled or not.
  103586. */
  103587. /**
  103588. * Sets wether tonemapping is enabled or not
  103589. */
  103590. cameraToneMappingEnabled: boolean;
  103591. /**
  103592. * The camera exposure used on this material.
  103593. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103594. * This corresponds to a photographic exposure.
  103595. */
  103596. /**
  103597. * The camera exposure used on this material.
  103598. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103599. * This corresponds to a photographic exposure.
  103600. */
  103601. cameraExposure: float;
  103602. /**
  103603. * Gets The camera contrast used on this material.
  103604. */
  103605. /**
  103606. * Sets The camera contrast used on this material.
  103607. */
  103608. cameraContrast: float;
  103609. /**
  103610. * Gets the Color Grading 2D Lookup Texture.
  103611. */
  103612. /**
  103613. * Sets the Color Grading 2D Lookup Texture.
  103614. */
  103615. cameraColorGradingTexture: Nullable<BaseTexture>;
  103616. /**
  103617. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103618. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103619. * 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;
  103620. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103621. */
  103622. /**
  103623. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103624. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103625. * 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;
  103626. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103627. */
  103628. cameraColorCurves: Nullable<ColorCurves>;
  103629. /**
  103630. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103631. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103632. */
  103633. switchToBGR: boolean;
  103634. private _renderTargets;
  103635. private _reflectionControls;
  103636. private _white;
  103637. private _primaryShadowColor;
  103638. private _primaryHighlightColor;
  103639. /**
  103640. * Instantiates a Background Material in the given scene
  103641. * @param name The friendly name of the material
  103642. * @param scene The scene to add the material to
  103643. */
  103644. constructor(name: string, scene: Scene);
  103645. /**
  103646. * Gets a boolean indicating that current material needs to register RTT
  103647. */
  103648. readonly hasRenderTargetTextures: boolean;
  103649. /**
  103650. * The entire material has been created in order to prevent overdraw.
  103651. * @returns false
  103652. */
  103653. needAlphaTesting(): boolean;
  103654. /**
  103655. * The entire material has been created in order to prevent overdraw.
  103656. * @returns true if blending is enable
  103657. */
  103658. needAlphaBlending(): boolean;
  103659. /**
  103660. * Checks wether the material is ready to be rendered for a given mesh.
  103661. * @param mesh The mesh to render
  103662. * @param subMesh The submesh to check against
  103663. * @param useInstances Specify wether or not the material is used with instances
  103664. * @returns true if all the dependencies are ready (Textures, Effects...)
  103665. */
  103666. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103667. /**
  103668. * Compute the primary color according to the chosen perceptual color.
  103669. */
  103670. private _computePrimaryColorFromPerceptualColor;
  103671. /**
  103672. * Compute the highlights and shadow colors according to their chosen levels.
  103673. */
  103674. private _computePrimaryColors;
  103675. /**
  103676. * Build the uniform buffer used in the material.
  103677. */
  103678. buildUniformLayout(): void;
  103679. /**
  103680. * Unbind the material.
  103681. */
  103682. unbind(): void;
  103683. /**
  103684. * Bind only the world matrix to the material.
  103685. * @param world The world matrix to bind.
  103686. */
  103687. bindOnlyWorldMatrix(world: Matrix): void;
  103688. /**
  103689. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103690. * @param world The world matrix to bind.
  103691. * @param subMesh The submesh to bind for.
  103692. */
  103693. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103694. /**
  103695. * Dispose the material.
  103696. * @param forceDisposeEffect Force disposal of the associated effect.
  103697. * @param forceDisposeTextures Force disposal of the associated textures.
  103698. */
  103699. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103700. /**
  103701. * Clones the material.
  103702. * @param name The cloned name.
  103703. * @returns The cloned material.
  103704. */
  103705. clone(name: string): BackgroundMaterial;
  103706. /**
  103707. * Serializes the current material to its JSON representation.
  103708. * @returns The JSON representation.
  103709. */
  103710. serialize(): any;
  103711. /**
  103712. * Gets the class name of the material
  103713. * @returns "BackgroundMaterial"
  103714. */
  103715. getClassName(): string;
  103716. /**
  103717. * Parse a JSON input to create back a background material.
  103718. * @param source The JSON data to parse
  103719. * @param scene The scene to create the parsed material in
  103720. * @param rootUrl The root url of the assets the material depends upon
  103721. * @returns the instantiated BackgroundMaterial.
  103722. */
  103723. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103724. }
  103725. }
  103726. declare module BABYLON {
  103727. /**
  103728. * Represents the different options available during the creation of
  103729. * a Environment helper.
  103730. *
  103731. * This can control the default ground, skybox and image processing setup of your scene.
  103732. */
  103733. export interface IEnvironmentHelperOptions {
  103734. /**
  103735. * Specifies wether or not to create a ground.
  103736. * True by default.
  103737. */
  103738. createGround: boolean;
  103739. /**
  103740. * Specifies the ground size.
  103741. * 15 by default.
  103742. */
  103743. groundSize: number;
  103744. /**
  103745. * The texture used on the ground for the main color.
  103746. * Comes from the BabylonJS CDN by default.
  103747. *
  103748. * Remarks: Can be either a texture or a url.
  103749. */
  103750. groundTexture: string | BaseTexture;
  103751. /**
  103752. * The color mixed in the ground texture by default.
  103753. * BabylonJS clearColor by default.
  103754. */
  103755. groundColor: Color3;
  103756. /**
  103757. * Specifies the ground opacity.
  103758. * 1 by default.
  103759. */
  103760. groundOpacity: number;
  103761. /**
  103762. * Enables the ground to receive shadows.
  103763. * True by default.
  103764. */
  103765. enableGroundShadow: boolean;
  103766. /**
  103767. * Helps preventing the shadow to be fully black on the ground.
  103768. * 0.5 by default.
  103769. */
  103770. groundShadowLevel: number;
  103771. /**
  103772. * Creates a mirror texture attach to the ground.
  103773. * false by default.
  103774. */
  103775. enableGroundMirror: boolean;
  103776. /**
  103777. * Specifies the ground mirror size ratio.
  103778. * 0.3 by default as the default kernel is 64.
  103779. */
  103780. groundMirrorSizeRatio: number;
  103781. /**
  103782. * Specifies the ground mirror blur kernel size.
  103783. * 64 by default.
  103784. */
  103785. groundMirrorBlurKernel: number;
  103786. /**
  103787. * Specifies the ground mirror visibility amount.
  103788. * 1 by default
  103789. */
  103790. groundMirrorAmount: number;
  103791. /**
  103792. * Specifies the ground mirror reflectance weight.
  103793. * This uses the standard weight of the background material to setup the fresnel effect
  103794. * of the mirror.
  103795. * 1 by default.
  103796. */
  103797. groundMirrorFresnelWeight: number;
  103798. /**
  103799. * Specifies the ground mirror Falloff distance.
  103800. * This can helps reducing the size of the reflection.
  103801. * 0 by Default.
  103802. */
  103803. groundMirrorFallOffDistance: number;
  103804. /**
  103805. * Specifies the ground mirror texture type.
  103806. * Unsigned Int by Default.
  103807. */
  103808. groundMirrorTextureType: number;
  103809. /**
  103810. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103811. * the shown objects.
  103812. */
  103813. groundYBias: number;
  103814. /**
  103815. * Specifies wether or not to create a skybox.
  103816. * True by default.
  103817. */
  103818. createSkybox: boolean;
  103819. /**
  103820. * Specifies the skybox size.
  103821. * 20 by default.
  103822. */
  103823. skyboxSize: number;
  103824. /**
  103825. * The texture used on the skybox for the main color.
  103826. * Comes from the BabylonJS CDN by default.
  103827. *
  103828. * Remarks: Can be either a texture or a url.
  103829. */
  103830. skyboxTexture: string | BaseTexture;
  103831. /**
  103832. * The color mixed in the skybox texture by default.
  103833. * BabylonJS clearColor by default.
  103834. */
  103835. skyboxColor: Color3;
  103836. /**
  103837. * The background rotation around the Y axis of the scene.
  103838. * This helps aligning the key lights of your scene with the background.
  103839. * 0 by default.
  103840. */
  103841. backgroundYRotation: number;
  103842. /**
  103843. * Compute automatically the size of the elements to best fit with the scene.
  103844. */
  103845. sizeAuto: boolean;
  103846. /**
  103847. * Default position of the rootMesh if autoSize is not true.
  103848. */
  103849. rootPosition: Vector3;
  103850. /**
  103851. * Sets up the image processing in the scene.
  103852. * true by default.
  103853. */
  103854. setupImageProcessing: boolean;
  103855. /**
  103856. * The texture used as your environment texture in the scene.
  103857. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103858. *
  103859. * Remarks: Can be either a texture or a url.
  103860. */
  103861. environmentTexture: string | BaseTexture;
  103862. /**
  103863. * The value of the exposure to apply to the scene.
  103864. * 0.6 by default if setupImageProcessing is true.
  103865. */
  103866. cameraExposure: number;
  103867. /**
  103868. * The value of the contrast to apply to the scene.
  103869. * 1.6 by default if setupImageProcessing is true.
  103870. */
  103871. cameraContrast: number;
  103872. /**
  103873. * Specifies wether or not tonemapping should be enabled in the scene.
  103874. * true by default if setupImageProcessing is true.
  103875. */
  103876. toneMappingEnabled: boolean;
  103877. }
  103878. /**
  103879. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103880. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103881. * It also helps with the default setup of your imageProcessing configuration.
  103882. */
  103883. export class EnvironmentHelper {
  103884. /**
  103885. * Default ground texture URL.
  103886. */
  103887. private static _groundTextureCDNUrl;
  103888. /**
  103889. * Default skybox texture URL.
  103890. */
  103891. private static _skyboxTextureCDNUrl;
  103892. /**
  103893. * Default environment texture URL.
  103894. */
  103895. private static _environmentTextureCDNUrl;
  103896. /**
  103897. * Creates the default options for the helper.
  103898. */
  103899. private static _getDefaultOptions;
  103900. private _rootMesh;
  103901. /**
  103902. * Gets the root mesh created by the helper.
  103903. */
  103904. readonly rootMesh: Mesh;
  103905. private _skybox;
  103906. /**
  103907. * Gets the skybox created by the helper.
  103908. */
  103909. readonly skybox: Nullable<Mesh>;
  103910. private _skyboxTexture;
  103911. /**
  103912. * Gets the skybox texture created by the helper.
  103913. */
  103914. readonly skyboxTexture: Nullable<BaseTexture>;
  103915. private _skyboxMaterial;
  103916. /**
  103917. * Gets the skybox material created by the helper.
  103918. */
  103919. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103920. private _ground;
  103921. /**
  103922. * Gets the ground mesh created by the helper.
  103923. */
  103924. readonly ground: Nullable<Mesh>;
  103925. private _groundTexture;
  103926. /**
  103927. * Gets the ground texture created by the helper.
  103928. */
  103929. readonly groundTexture: Nullable<BaseTexture>;
  103930. private _groundMirror;
  103931. /**
  103932. * Gets the ground mirror created by the helper.
  103933. */
  103934. readonly groundMirror: Nullable<MirrorTexture>;
  103935. /**
  103936. * Gets the ground mirror render list to helps pushing the meshes
  103937. * you wish in the ground reflection.
  103938. */
  103939. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103940. private _groundMaterial;
  103941. /**
  103942. * Gets the ground material created by the helper.
  103943. */
  103944. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103945. /**
  103946. * Stores the creation options.
  103947. */
  103948. private readonly _scene;
  103949. private _options;
  103950. /**
  103951. * This observable will be notified with any error during the creation of the environment,
  103952. * mainly texture creation errors.
  103953. */
  103954. onErrorObservable: Observable<{
  103955. message?: string;
  103956. exception?: any;
  103957. }>;
  103958. /**
  103959. * constructor
  103960. * @param options Defines the options we want to customize the helper
  103961. * @param scene The scene to add the material to
  103962. */
  103963. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103964. /**
  103965. * Updates the background according to the new options
  103966. * @param options
  103967. */
  103968. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103969. /**
  103970. * Sets the primary color of all the available elements.
  103971. * @param color the main color to affect to the ground and the background
  103972. */
  103973. setMainColor(color: Color3): void;
  103974. /**
  103975. * Setup the image processing according to the specified options.
  103976. */
  103977. private _setupImageProcessing;
  103978. /**
  103979. * Setup the environment texture according to the specified options.
  103980. */
  103981. private _setupEnvironmentTexture;
  103982. /**
  103983. * Setup the background according to the specified options.
  103984. */
  103985. private _setupBackground;
  103986. /**
  103987. * Get the scene sizes according to the setup.
  103988. */
  103989. private _getSceneSize;
  103990. /**
  103991. * Setup the ground according to the specified options.
  103992. */
  103993. private _setupGround;
  103994. /**
  103995. * Setup the ground material according to the specified options.
  103996. */
  103997. private _setupGroundMaterial;
  103998. /**
  103999. * Setup the ground diffuse texture according to the specified options.
  104000. */
  104001. private _setupGroundDiffuseTexture;
  104002. /**
  104003. * Setup the ground mirror texture according to the specified options.
  104004. */
  104005. private _setupGroundMirrorTexture;
  104006. /**
  104007. * Setup the ground to receive the mirror texture.
  104008. */
  104009. private _setupMirrorInGroundMaterial;
  104010. /**
  104011. * Setup the skybox according to the specified options.
  104012. */
  104013. private _setupSkybox;
  104014. /**
  104015. * Setup the skybox material according to the specified options.
  104016. */
  104017. private _setupSkyboxMaterial;
  104018. /**
  104019. * Setup the skybox reflection texture according to the specified options.
  104020. */
  104021. private _setupSkyboxReflectionTexture;
  104022. private _errorHandler;
  104023. /**
  104024. * Dispose all the elements created by the Helper.
  104025. */
  104026. dispose(): void;
  104027. }
  104028. }
  104029. declare module BABYLON {
  104030. /**
  104031. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  104032. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  104033. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  104034. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  104035. */
  104036. export class PhotoDome extends TransformNode {
  104037. private _useDirectMapping;
  104038. /**
  104039. * The texture being displayed on the sphere
  104040. */
  104041. protected _photoTexture: Texture;
  104042. /**
  104043. * Gets or sets the texture being displayed on the sphere
  104044. */
  104045. photoTexture: Texture;
  104046. /**
  104047. * Observable raised when an error occured while loading the 360 image
  104048. */
  104049. onLoadErrorObservable: Observable<string>;
  104050. /**
  104051. * The skybox material
  104052. */
  104053. protected _material: BackgroundMaterial;
  104054. /**
  104055. * The surface used for the skybox
  104056. */
  104057. protected _mesh: Mesh;
  104058. /**
  104059. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  104060. * Also see the options.resolution property.
  104061. */
  104062. fovMultiplier: number;
  104063. /**
  104064. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  104065. * @param name Element's name, child elements will append suffixes for their own names.
  104066. * @param urlsOfPhoto defines the url of the photo to display
  104067. * @param options defines an object containing optional or exposed sub element properties
  104068. * @param onError defines a callback called when an error occured while loading the texture
  104069. */
  104070. constructor(name: string, urlOfPhoto: string, options: {
  104071. resolution?: number;
  104072. size?: number;
  104073. useDirectMapping?: boolean;
  104074. faceForward?: boolean;
  104075. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  104076. /**
  104077. * Releases resources associated with this node.
  104078. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104079. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104080. */
  104081. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104082. }
  104083. }
  104084. declare module BABYLON {
  104085. /** @hidden */
  104086. export var rgbdDecodePixelShader: {
  104087. name: string;
  104088. shader: string;
  104089. };
  104090. }
  104091. declare module BABYLON {
  104092. /**
  104093. * Class used to host texture specific utilities
  104094. */
  104095. export class BRDFTextureTools {
  104096. /**
  104097. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  104098. * @param texture the texture to expand.
  104099. */
  104100. private static _ExpandDefaultBRDFTexture;
  104101. /**
  104102. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  104103. * @param scene defines the hosting scene
  104104. * @returns the environment BRDF texture
  104105. */
  104106. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  104107. private static _environmentBRDFBase64Texture;
  104108. }
  104109. }
  104110. declare module BABYLON {
  104111. /**
  104112. * @hidden
  104113. */
  104114. export interface IMaterialClearCoatDefines {
  104115. CLEARCOAT: boolean;
  104116. CLEARCOAT_DEFAULTIOR: boolean;
  104117. CLEARCOAT_TEXTURE: boolean;
  104118. CLEARCOAT_TEXTUREDIRECTUV: number;
  104119. CLEARCOAT_BUMP: boolean;
  104120. CLEARCOAT_BUMPDIRECTUV: number;
  104121. CLEARCOAT_TINT: boolean;
  104122. CLEARCOAT_TINT_TEXTURE: boolean;
  104123. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104124. /** @hidden */
  104125. _areTexturesDirty: boolean;
  104126. }
  104127. /**
  104128. * Define the code related to the clear coat parameters of the pbr material.
  104129. */
  104130. export class PBRClearCoatConfiguration {
  104131. /**
  104132. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104133. * The default fits with a polyurethane material.
  104134. */
  104135. private static readonly _DefaultIndiceOfRefraction;
  104136. private _isEnabled;
  104137. /**
  104138. * Defines if the clear coat is enabled in the material.
  104139. */
  104140. isEnabled: boolean;
  104141. /**
  104142. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  104143. */
  104144. intensity: number;
  104145. /**
  104146. * Defines the clear coat layer roughness.
  104147. */
  104148. roughness: number;
  104149. private _indiceOfRefraction;
  104150. /**
  104151. * Defines the indice of refraction of the clear coat.
  104152. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104153. * The default fits with a polyurethane material.
  104154. * Changing the default value is more performance intensive.
  104155. */
  104156. indiceOfRefraction: number;
  104157. private _texture;
  104158. /**
  104159. * Stores the clear coat values in a texture.
  104160. */
  104161. texture: Nullable<BaseTexture>;
  104162. private _bumpTexture;
  104163. /**
  104164. * Define the clear coat specific bump texture.
  104165. */
  104166. bumpTexture: Nullable<BaseTexture>;
  104167. private _isTintEnabled;
  104168. /**
  104169. * Defines if the clear coat tint is enabled in the material.
  104170. */
  104171. isTintEnabled: boolean;
  104172. /**
  104173. * Defines the clear coat tint of the material.
  104174. * This is only use if tint is enabled
  104175. */
  104176. tintColor: Color3;
  104177. /**
  104178. * Defines the distance at which the tint color should be found in the
  104179. * clear coat media.
  104180. * This is only use if tint is enabled
  104181. */
  104182. tintColorAtDistance: number;
  104183. /**
  104184. * Defines the clear coat layer thickness.
  104185. * This is only use if tint is enabled
  104186. */
  104187. tintThickness: number;
  104188. private _tintTexture;
  104189. /**
  104190. * Stores the clear tint values in a texture.
  104191. * rgb is tint
  104192. * a is a thickness factor
  104193. */
  104194. tintTexture: Nullable<BaseTexture>;
  104195. /** @hidden */
  104196. private _internalMarkAllSubMeshesAsTexturesDirty;
  104197. /** @hidden */
  104198. _markAllSubMeshesAsTexturesDirty(): void;
  104199. /**
  104200. * Instantiate a new istance of clear coat configuration.
  104201. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104202. */
  104203. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104204. /**
  104205. * Gets wehter the submesh is ready to be used or not.
  104206. * @param defines the list of "defines" to update.
  104207. * @param scene defines the scene the material belongs to.
  104208. * @param engine defines the engine the material belongs to.
  104209. * @param disableBumpMap defines wether the material disables bump or not.
  104210. * @returns - boolean indicating that the submesh is ready or not.
  104211. */
  104212. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104213. /**
  104214. * Checks to see if a texture is used in the material.
  104215. * @param defines the list of "defines" to update.
  104216. * @param scene defines the scene to the material belongs to.
  104217. */
  104218. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104219. /**
  104220. * Binds the material data.
  104221. * @param uniformBuffer defines the Uniform buffer to fill in.
  104222. * @param scene defines the scene the material belongs to.
  104223. * @param engine defines the engine the material belongs to.
  104224. * @param disableBumpMap defines wether the material disables bump or not.
  104225. * @param isFrozen defines wether the material is frozen or not.
  104226. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104227. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104228. */
  104229. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104230. /**
  104231. * Checks to see if a texture is used in the material.
  104232. * @param texture - Base texture to use.
  104233. * @returns - Boolean specifying if a texture is used in the material.
  104234. */
  104235. hasTexture(texture: BaseTexture): boolean;
  104236. /**
  104237. * Returns an array of the actively used textures.
  104238. * @param activeTextures Array of BaseTextures
  104239. */
  104240. getActiveTextures(activeTextures: BaseTexture[]): void;
  104241. /**
  104242. * Returns the animatable textures.
  104243. * @param animatables Array of animatable textures.
  104244. */
  104245. getAnimatables(animatables: IAnimatable[]): void;
  104246. /**
  104247. * Disposes the resources of the material.
  104248. * @param forceDisposeTextures - Forces the disposal of all textures.
  104249. */
  104250. dispose(forceDisposeTextures?: boolean): void;
  104251. /**
  104252. * Get the current class name of the texture useful for serialization or dynamic coding.
  104253. * @returns "PBRClearCoatConfiguration"
  104254. */
  104255. getClassName(): string;
  104256. /**
  104257. * Add fallbacks to the effect fallbacks list.
  104258. * @param defines defines the Base texture to use.
  104259. * @param fallbacks defines the current fallback list.
  104260. * @param currentRank defines the current fallback rank.
  104261. * @returns the new fallback rank.
  104262. */
  104263. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104264. /**
  104265. * Add the required uniforms to the current list.
  104266. * @param uniforms defines the current uniform list.
  104267. */
  104268. static AddUniforms(uniforms: string[]): void;
  104269. /**
  104270. * Add the required samplers to the current list.
  104271. * @param samplers defines the current sampler list.
  104272. */
  104273. static AddSamplers(samplers: string[]): void;
  104274. /**
  104275. * Add the required uniforms to the current buffer.
  104276. * @param uniformBuffer defines the current uniform buffer.
  104277. */
  104278. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104279. /**
  104280. * Makes a duplicate of the current configuration into another one.
  104281. * @param clearCoatConfiguration define the config where to copy the info
  104282. */
  104283. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104284. /**
  104285. * Serializes this clear coat configuration.
  104286. * @returns - An object with the serialized config.
  104287. */
  104288. serialize(): any;
  104289. /**
  104290. * Parses a Clear Coat Configuration from a serialized object.
  104291. * @param source - Serialized object.
  104292. */
  104293. parse(source: any): void;
  104294. }
  104295. }
  104296. declare module BABYLON {
  104297. /**
  104298. * @hidden
  104299. */
  104300. export interface IMaterialAnisotropicDefines {
  104301. ANISOTROPIC: boolean;
  104302. ANISOTROPIC_TEXTURE: boolean;
  104303. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104304. MAINUV1: boolean;
  104305. _areTexturesDirty: boolean;
  104306. _needUVs: boolean;
  104307. }
  104308. /**
  104309. * Define the code related to the anisotropic parameters of the pbr material.
  104310. */
  104311. export class PBRAnisotropicConfiguration {
  104312. private _isEnabled;
  104313. /**
  104314. * Defines if the anisotropy is enabled in the material.
  104315. */
  104316. isEnabled: boolean;
  104317. /**
  104318. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104319. */
  104320. intensity: number;
  104321. /**
  104322. * Defines if the effect is along the tangents, bitangents or in between.
  104323. * By default, the effect is "strectching" the highlights along the tangents.
  104324. */
  104325. direction: Vector2;
  104326. private _texture;
  104327. /**
  104328. * Stores the anisotropy values in a texture.
  104329. * rg is direction (like normal from -1 to 1)
  104330. * b is a intensity
  104331. */
  104332. texture: Nullable<BaseTexture>;
  104333. /** @hidden */
  104334. private _internalMarkAllSubMeshesAsTexturesDirty;
  104335. /** @hidden */
  104336. _markAllSubMeshesAsTexturesDirty(): void;
  104337. /**
  104338. * Instantiate a new istance of anisotropy configuration.
  104339. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104340. */
  104341. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104342. /**
  104343. * Specifies that the submesh is ready to be used.
  104344. * @param defines the list of "defines" to update.
  104345. * @param scene defines the scene the material belongs to.
  104346. * @returns - boolean indicating that the submesh is ready or not.
  104347. */
  104348. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104349. /**
  104350. * Checks to see if a texture is used in the material.
  104351. * @param defines the list of "defines" to update.
  104352. * @param mesh the mesh we are preparing the defines for.
  104353. * @param scene defines the scene the material belongs to.
  104354. */
  104355. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104356. /**
  104357. * Binds the material data.
  104358. * @param uniformBuffer defines the Uniform buffer to fill in.
  104359. * @param scene defines the scene the material belongs to.
  104360. * @param isFrozen defines wether the material is frozen or not.
  104361. */
  104362. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104363. /**
  104364. * Checks to see if a texture is used in the material.
  104365. * @param texture - Base texture to use.
  104366. * @returns - Boolean specifying if a texture is used in the material.
  104367. */
  104368. hasTexture(texture: BaseTexture): boolean;
  104369. /**
  104370. * Returns an array of the actively used textures.
  104371. * @param activeTextures Array of BaseTextures
  104372. */
  104373. getActiveTextures(activeTextures: BaseTexture[]): void;
  104374. /**
  104375. * Returns the animatable textures.
  104376. * @param animatables Array of animatable textures.
  104377. */
  104378. getAnimatables(animatables: IAnimatable[]): void;
  104379. /**
  104380. * Disposes the resources of the material.
  104381. * @param forceDisposeTextures - Forces the disposal of all textures.
  104382. */
  104383. dispose(forceDisposeTextures?: boolean): void;
  104384. /**
  104385. * Get the current class name of the texture useful for serialization or dynamic coding.
  104386. * @returns "PBRAnisotropicConfiguration"
  104387. */
  104388. getClassName(): string;
  104389. /**
  104390. * Add fallbacks to the effect fallbacks list.
  104391. * @param defines defines the Base texture to use.
  104392. * @param fallbacks defines the current fallback list.
  104393. * @param currentRank defines the current fallback rank.
  104394. * @returns the new fallback rank.
  104395. */
  104396. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104397. /**
  104398. * Add the required uniforms to the current list.
  104399. * @param uniforms defines the current uniform list.
  104400. */
  104401. static AddUniforms(uniforms: string[]): void;
  104402. /**
  104403. * Add the required uniforms to the current buffer.
  104404. * @param uniformBuffer defines the current uniform buffer.
  104405. */
  104406. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104407. /**
  104408. * Add the required samplers to the current list.
  104409. * @param samplers defines the current sampler list.
  104410. */
  104411. static AddSamplers(samplers: string[]): void;
  104412. /**
  104413. * Makes a duplicate of the current configuration into another one.
  104414. * @param anisotropicConfiguration define the config where to copy the info
  104415. */
  104416. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104417. /**
  104418. * Serializes this anisotropy configuration.
  104419. * @returns - An object with the serialized config.
  104420. */
  104421. serialize(): any;
  104422. /**
  104423. * Parses a anisotropy Configuration from a serialized object.
  104424. * @param source - Serialized object.
  104425. */
  104426. parse(source: any): void;
  104427. }
  104428. }
  104429. declare module BABYLON {
  104430. /**
  104431. * @hidden
  104432. */
  104433. export interface IMaterialBRDFDefines {
  104434. BRDF_V_HEIGHT_CORRELATED: boolean;
  104435. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104436. SPHERICAL_HARMONICS: boolean;
  104437. /** @hidden */
  104438. _areMiscDirty: boolean;
  104439. }
  104440. /**
  104441. * Define the code related to the BRDF parameters of the pbr material.
  104442. */
  104443. export class PBRBRDFConfiguration {
  104444. /**
  104445. * Default value used for the energy conservation.
  104446. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104447. */
  104448. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104449. /**
  104450. * Default value used for the Smith Visibility Height Correlated mode.
  104451. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104452. */
  104453. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104454. /**
  104455. * Default value used for the IBL diffuse part.
  104456. * This can help switching back to the polynomials mode globally which is a tiny bit
  104457. * less GPU intensive at the drawback of a lower quality.
  104458. */
  104459. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104460. private _useEnergyConservation;
  104461. /**
  104462. * Defines if the material uses energy conservation.
  104463. */
  104464. useEnergyConservation: boolean;
  104465. private _useSmithVisibilityHeightCorrelated;
  104466. /**
  104467. * LEGACY Mode set to false
  104468. * Defines if the material uses height smith correlated visibility term.
  104469. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104470. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104471. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104472. * Not relying on height correlated will also disable energy conservation.
  104473. */
  104474. useSmithVisibilityHeightCorrelated: boolean;
  104475. private _useSphericalHarmonics;
  104476. /**
  104477. * LEGACY Mode set to false
  104478. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104479. * diffuse part of the IBL.
  104480. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104481. * to the ground truth.
  104482. */
  104483. useSphericalHarmonics: boolean;
  104484. /** @hidden */
  104485. private _internalMarkAllSubMeshesAsMiscDirty;
  104486. /** @hidden */
  104487. _markAllSubMeshesAsMiscDirty(): void;
  104488. /**
  104489. * Instantiate a new istance of clear coat configuration.
  104490. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104491. */
  104492. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104493. /**
  104494. * Checks to see if a texture is used in the material.
  104495. * @param defines the list of "defines" to update.
  104496. */
  104497. prepareDefines(defines: IMaterialBRDFDefines): void;
  104498. /**
  104499. * Get the current class name of the texture useful for serialization or dynamic coding.
  104500. * @returns "PBRClearCoatConfiguration"
  104501. */
  104502. getClassName(): string;
  104503. /**
  104504. * Makes a duplicate of the current configuration into another one.
  104505. * @param brdfConfiguration define the config where to copy the info
  104506. */
  104507. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104508. /**
  104509. * Serializes this BRDF configuration.
  104510. * @returns - An object with the serialized config.
  104511. */
  104512. serialize(): any;
  104513. /**
  104514. * Parses a BRDF Configuration from a serialized object.
  104515. * @param source - Serialized object.
  104516. */
  104517. parse(source: any): void;
  104518. }
  104519. }
  104520. declare module BABYLON {
  104521. /**
  104522. * @hidden
  104523. */
  104524. export interface IMaterialSheenDefines {
  104525. SHEEN: boolean;
  104526. SHEEN_TEXTURE: boolean;
  104527. SHEEN_TEXTUREDIRECTUV: number;
  104528. SHEEN_LINKWITHALBEDO: boolean;
  104529. /** @hidden */
  104530. _areTexturesDirty: boolean;
  104531. }
  104532. /**
  104533. * Define the code related to the Sheen parameters of the pbr material.
  104534. */
  104535. export class PBRSheenConfiguration {
  104536. private _isEnabled;
  104537. /**
  104538. * Defines if the material uses sheen.
  104539. */
  104540. isEnabled: boolean;
  104541. private _linkSheenWithAlbedo;
  104542. /**
  104543. * Defines if the sheen is linked to the sheen color.
  104544. */
  104545. linkSheenWithAlbedo: boolean;
  104546. /**
  104547. * Defines the sheen intensity.
  104548. */
  104549. intensity: number;
  104550. /**
  104551. * Defines the sheen color.
  104552. */
  104553. color: Color3;
  104554. private _texture;
  104555. /**
  104556. * Stores the sheen tint values in a texture.
  104557. * rgb is tint
  104558. * a is a intensity
  104559. */
  104560. texture: Nullable<BaseTexture>;
  104561. /** @hidden */
  104562. private _internalMarkAllSubMeshesAsTexturesDirty;
  104563. /** @hidden */
  104564. _markAllSubMeshesAsTexturesDirty(): void;
  104565. /**
  104566. * Instantiate a new istance of clear coat configuration.
  104567. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104568. */
  104569. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104570. /**
  104571. * Specifies that the submesh is ready to be used.
  104572. * @param defines the list of "defines" to update.
  104573. * @param scene defines the scene the material belongs to.
  104574. * @returns - boolean indicating that the submesh is ready or not.
  104575. */
  104576. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104577. /**
  104578. * Checks to see if a texture is used in the material.
  104579. * @param defines the list of "defines" to update.
  104580. * @param scene defines the scene the material belongs to.
  104581. */
  104582. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104583. /**
  104584. * Binds the material data.
  104585. * @param uniformBuffer defines the Uniform buffer to fill in.
  104586. * @param scene defines the scene the material belongs to.
  104587. * @param isFrozen defines wether the material is frozen or not.
  104588. */
  104589. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104590. /**
  104591. * Checks to see if a texture is used in the material.
  104592. * @param texture - Base texture to use.
  104593. * @returns - Boolean specifying if a texture is used in the material.
  104594. */
  104595. hasTexture(texture: BaseTexture): boolean;
  104596. /**
  104597. * Returns an array of the actively used textures.
  104598. * @param activeTextures Array of BaseTextures
  104599. */
  104600. getActiveTextures(activeTextures: BaseTexture[]): void;
  104601. /**
  104602. * Returns the animatable textures.
  104603. * @param animatables Array of animatable textures.
  104604. */
  104605. getAnimatables(animatables: IAnimatable[]): void;
  104606. /**
  104607. * Disposes the resources of the material.
  104608. * @param forceDisposeTextures - Forces the disposal of all textures.
  104609. */
  104610. dispose(forceDisposeTextures?: boolean): void;
  104611. /**
  104612. * Get the current class name of the texture useful for serialization or dynamic coding.
  104613. * @returns "PBRSheenConfiguration"
  104614. */
  104615. getClassName(): string;
  104616. /**
  104617. * Add fallbacks to the effect fallbacks list.
  104618. * @param defines defines the Base texture to use.
  104619. * @param fallbacks defines the current fallback list.
  104620. * @param currentRank defines the current fallback rank.
  104621. * @returns the new fallback rank.
  104622. */
  104623. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104624. /**
  104625. * Add the required uniforms to the current list.
  104626. * @param uniforms defines the current uniform list.
  104627. */
  104628. static AddUniforms(uniforms: string[]): void;
  104629. /**
  104630. * Add the required uniforms to the current buffer.
  104631. * @param uniformBuffer defines the current uniform buffer.
  104632. */
  104633. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104634. /**
  104635. * Add the required samplers to the current list.
  104636. * @param samplers defines the current sampler list.
  104637. */
  104638. static AddSamplers(samplers: string[]): void;
  104639. /**
  104640. * Makes a duplicate of the current configuration into another one.
  104641. * @param sheenConfiguration define the config where to copy the info
  104642. */
  104643. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104644. /**
  104645. * Serializes this BRDF configuration.
  104646. * @returns - An object with the serialized config.
  104647. */
  104648. serialize(): any;
  104649. /**
  104650. * Parses a Sheen Configuration from a serialized object.
  104651. * @param source - Serialized object.
  104652. */
  104653. parse(source: any): void;
  104654. }
  104655. }
  104656. declare module BABYLON {
  104657. /**
  104658. * @hidden
  104659. */
  104660. export interface IMaterialSubSurfaceDefines {
  104661. SUBSURFACE: boolean;
  104662. SS_REFRACTION: boolean;
  104663. SS_TRANSLUCENCY: boolean;
  104664. SS_SCATERRING: boolean;
  104665. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104666. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104667. SS_REFRACTIONMAP_3D: boolean;
  104668. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104669. SS_LODINREFRACTIONALPHA: boolean;
  104670. SS_GAMMAREFRACTION: boolean;
  104671. SS_RGBDREFRACTION: boolean;
  104672. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104673. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104674. /** @hidden */
  104675. _areTexturesDirty: boolean;
  104676. }
  104677. /**
  104678. * Define the code related to the sub surface parameters of the pbr material.
  104679. */
  104680. export class PBRSubSurfaceConfiguration {
  104681. private _isRefractionEnabled;
  104682. /**
  104683. * Defines if the refraction is enabled in the material.
  104684. */
  104685. isRefractionEnabled: boolean;
  104686. private _isTranslucencyEnabled;
  104687. /**
  104688. * Defines if the translucency is enabled in the material.
  104689. */
  104690. isTranslucencyEnabled: boolean;
  104691. private _isScatteringEnabled;
  104692. /**
  104693. * Defines the refraction intensity of the material.
  104694. * The refraction when enabled replaces the Diffuse part of the material.
  104695. * The intensity helps transitionning between diffuse and refraction.
  104696. */
  104697. refractionIntensity: number;
  104698. /**
  104699. * Defines the translucency intensity of the material.
  104700. * When translucency has been enabled, this defines how much of the "translucency"
  104701. * is addded to the diffuse part of the material.
  104702. */
  104703. translucencyIntensity: number;
  104704. /**
  104705. * Defines the scattering intensity of the material.
  104706. * When scattering has been enabled, this defines how much of the "scattered light"
  104707. * is addded to the diffuse part of the material.
  104708. */
  104709. scatteringIntensity: number;
  104710. private _thicknessTexture;
  104711. /**
  104712. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104713. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104714. * 0 would mean minimumThickness
  104715. * 1 would mean maximumThickness
  104716. * The other channels might be use as a mask to vary the different effects intensity.
  104717. */
  104718. thicknessTexture: Nullable<BaseTexture>;
  104719. private _refractionTexture;
  104720. /**
  104721. * Defines the texture to use for refraction.
  104722. */
  104723. refractionTexture: Nullable<BaseTexture>;
  104724. private _indexOfRefraction;
  104725. /**
  104726. * Defines the indice of refraction used in the material.
  104727. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104728. */
  104729. indexOfRefraction: number;
  104730. private _invertRefractionY;
  104731. /**
  104732. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104733. */
  104734. invertRefractionY: boolean;
  104735. private _linkRefractionWithTransparency;
  104736. /**
  104737. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104738. * Materials half opaque for instance using refraction could benefit from this control.
  104739. */
  104740. linkRefractionWithTransparency: boolean;
  104741. /**
  104742. * Defines the minimum thickness stored in the thickness map.
  104743. * If no thickness map is defined, this value will be used to simulate thickness.
  104744. */
  104745. minimumThickness: number;
  104746. /**
  104747. * Defines the maximum thickness stored in the thickness map.
  104748. */
  104749. maximumThickness: number;
  104750. /**
  104751. * Defines the volume tint of the material.
  104752. * This is used for both translucency and scattering.
  104753. */
  104754. tintColor: Color3;
  104755. /**
  104756. * Defines the distance at which the tint color should be found in the media.
  104757. * This is used for refraction only.
  104758. */
  104759. tintColorAtDistance: number;
  104760. /**
  104761. * Defines how far each channel transmit through the media.
  104762. * It is defined as a color to simplify it selection.
  104763. */
  104764. diffusionDistance: Color3;
  104765. private _useMaskFromThicknessTexture;
  104766. /**
  104767. * Stores the intensity of the different subsurface effects in the thickness texture.
  104768. * * the green channel is the translucency intensity.
  104769. * * the blue channel is the scattering intensity.
  104770. * * the alpha channel is the refraction intensity.
  104771. */
  104772. useMaskFromThicknessTexture: boolean;
  104773. /** @hidden */
  104774. private _internalMarkAllSubMeshesAsTexturesDirty;
  104775. /** @hidden */
  104776. _markAllSubMeshesAsTexturesDirty(): void;
  104777. /**
  104778. * Instantiate a new istance of sub surface configuration.
  104779. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104780. */
  104781. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104782. /**
  104783. * Gets wehter the submesh is ready to be used or not.
  104784. * @param defines the list of "defines" to update.
  104785. * @param scene defines the scene the material belongs to.
  104786. * @returns - boolean indicating that the submesh is ready or not.
  104787. */
  104788. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104789. /**
  104790. * Checks to see if a texture is used in the material.
  104791. * @param defines the list of "defines" to update.
  104792. * @param scene defines the scene to the material belongs to.
  104793. */
  104794. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104795. /**
  104796. * Binds the material data.
  104797. * @param uniformBuffer defines the Uniform buffer to fill in.
  104798. * @param scene defines the scene the material belongs to.
  104799. * @param engine defines the engine the material belongs to.
  104800. * @param isFrozen defines wether the material is frozen or not.
  104801. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104802. */
  104803. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104804. /**
  104805. * Unbinds the material from the mesh.
  104806. * @param activeEffect defines the effect that should be unbound from.
  104807. * @returns true if unbound, otherwise false
  104808. */
  104809. unbind(activeEffect: Effect): boolean;
  104810. /**
  104811. * Returns the texture used for refraction or null if none is used.
  104812. * @param scene defines the scene the material belongs to.
  104813. * @returns - Refraction texture if present. If no refraction texture and refraction
  104814. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104815. */
  104816. private _getRefractionTexture;
  104817. /**
  104818. * Returns true if alpha blending should be disabled.
  104819. */
  104820. readonly disableAlphaBlending: boolean;
  104821. /**
  104822. * Fills the list of render target textures.
  104823. * @param renderTargets the list of render targets to update
  104824. */
  104825. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104826. /**
  104827. * Checks to see if a texture is used in the material.
  104828. * @param texture - Base texture to use.
  104829. * @returns - Boolean specifying if a texture is used in the material.
  104830. */
  104831. hasTexture(texture: BaseTexture): boolean;
  104832. /**
  104833. * Gets a boolean indicating that current material needs to register RTT
  104834. * @returns true if this uses a render target otherwise false.
  104835. */
  104836. hasRenderTargetTextures(): boolean;
  104837. /**
  104838. * Returns an array of the actively used textures.
  104839. * @param activeTextures Array of BaseTextures
  104840. */
  104841. getActiveTextures(activeTextures: BaseTexture[]): void;
  104842. /**
  104843. * Returns the animatable textures.
  104844. * @param animatables Array of animatable textures.
  104845. */
  104846. getAnimatables(animatables: IAnimatable[]): void;
  104847. /**
  104848. * Disposes the resources of the material.
  104849. * @param forceDisposeTextures - Forces the disposal of all textures.
  104850. */
  104851. dispose(forceDisposeTextures?: boolean): void;
  104852. /**
  104853. * Get the current class name of the texture useful for serialization or dynamic coding.
  104854. * @returns "PBRSubSurfaceConfiguration"
  104855. */
  104856. getClassName(): string;
  104857. /**
  104858. * Add fallbacks to the effect fallbacks list.
  104859. * @param defines defines the Base texture to use.
  104860. * @param fallbacks defines the current fallback list.
  104861. * @param currentRank defines the current fallback rank.
  104862. * @returns the new fallback rank.
  104863. */
  104864. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104865. /**
  104866. * Add the required uniforms to the current list.
  104867. * @param uniforms defines the current uniform list.
  104868. */
  104869. static AddUniforms(uniforms: string[]): void;
  104870. /**
  104871. * Add the required samplers to the current list.
  104872. * @param samplers defines the current sampler list.
  104873. */
  104874. static AddSamplers(samplers: string[]): void;
  104875. /**
  104876. * Add the required uniforms to the current buffer.
  104877. * @param uniformBuffer defines the current uniform buffer.
  104878. */
  104879. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104880. /**
  104881. * Makes a duplicate of the current configuration into another one.
  104882. * @param configuration define the config where to copy the info
  104883. */
  104884. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104885. /**
  104886. * Serializes this Sub Surface configuration.
  104887. * @returns - An object with the serialized config.
  104888. */
  104889. serialize(): any;
  104890. /**
  104891. * Parses a Sub Surface Configuration from a serialized object.
  104892. * @param source - Serialized object.
  104893. */
  104894. parse(source: any): void;
  104895. }
  104896. }
  104897. declare module BABYLON {
  104898. /** @hidden */
  104899. export var pbrFragmentDeclaration: {
  104900. name: string;
  104901. shader: string;
  104902. };
  104903. }
  104904. declare module BABYLON {
  104905. /** @hidden */
  104906. export var pbrUboDeclaration: {
  104907. name: string;
  104908. shader: string;
  104909. };
  104910. }
  104911. declare module BABYLON {
  104912. /** @hidden */
  104913. export var pbrFragmentExtraDeclaration: {
  104914. name: string;
  104915. shader: string;
  104916. };
  104917. }
  104918. declare module BABYLON {
  104919. /** @hidden */
  104920. export var pbrFragmentSamplersDeclaration: {
  104921. name: string;
  104922. shader: string;
  104923. };
  104924. }
  104925. declare module BABYLON {
  104926. /** @hidden */
  104927. export var pbrHelperFunctions: {
  104928. name: string;
  104929. shader: string;
  104930. };
  104931. }
  104932. declare module BABYLON {
  104933. /** @hidden */
  104934. export var harmonicsFunctions: {
  104935. name: string;
  104936. shader: string;
  104937. };
  104938. }
  104939. declare module BABYLON {
  104940. /** @hidden */
  104941. export var pbrDirectLightingSetupFunctions: {
  104942. name: string;
  104943. shader: string;
  104944. };
  104945. }
  104946. declare module BABYLON {
  104947. /** @hidden */
  104948. export var pbrDirectLightingFalloffFunctions: {
  104949. name: string;
  104950. shader: string;
  104951. };
  104952. }
  104953. declare module BABYLON {
  104954. /** @hidden */
  104955. export var pbrBRDFFunctions: {
  104956. name: string;
  104957. shader: string;
  104958. };
  104959. }
  104960. declare module BABYLON {
  104961. /** @hidden */
  104962. export var pbrDirectLightingFunctions: {
  104963. name: string;
  104964. shader: string;
  104965. };
  104966. }
  104967. declare module BABYLON {
  104968. /** @hidden */
  104969. export var pbrIBLFunctions: {
  104970. name: string;
  104971. shader: string;
  104972. };
  104973. }
  104974. declare module BABYLON {
  104975. /** @hidden */
  104976. export var pbrDebug: {
  104977. name: string;
  104978. shader: string;
  104979. };
  104980. }
  104981. declare module BABYLON {
  104982. /** @hidden */
  104983. export var pbrPixelShader: {
  104984. name: string;
  104985. shader: string;
  104986. };
  104987. }
  104988. declare module BABYLON {
  104989. /** @hidden */
  104990. export var pbrVertexDeclaration: {
  104991. name: string;
  104992. shader: string;
  104993. };
  104994. }
  104995. declare module BABYLON {
  104996. /** @hidden */
  104997. export var pbrVertexShader: {
  104998. name: string;
  104999. shader: string;
  105000. };
  105001. }
  105002. declare module BABYLON {
  105003. /**
  105004. * Manages the defines for the PBR Material.
  105005. * @hidden
  105006. */
  105007. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  105008. PBR: boolean;
  105009. MAINUV1: boolean;
  105010. MAINUV2: boolean;
  105011. UV1: boolean;
  105012. UV2: boolean;
  105013. ALBEDO: boolean;
  105014. ALBEDODIRECTUV: number;
  105015. VERTEXCOLOR: boolean;
  105016. AMBIENT: boolean;
  105017. AMBIENTDIRECTUV: number;
  105018. AMBIENTINGRAYSCALE: boolean;
  105019. OPACITY: boolean;
  105020. VERTEXALPHA: boolean;
  105021. OPACITYDIRECTUV: number;
  105022. OPACITYRGB: boolean;
  105023. ALPHATEST: boolean;
  105024. DEPTHPREPASS: boolean;
  105025. ALPHABLEND: boolean;
  105026. ALPHAFROMALBEDO: boolean;
  105027. ALPHATESTVALUE: string;
  105028. SPECULAROVERALPHA: boolean;
  105029. RADIANCEOVERALPHA: boolean;
  105030. ALPHAFRESNEL: boolean;
  105031. LINEARALPHAFRESNEL: boolean;
  105032. PREMULTIPLYALPHA: boolean;
  105033. EMISSIVE: boolean;
  105034. EMISSIVEDIRECTUV: number;
  105035. REFLECTIVITY: boolean;
  105036. REFLECTIVITYDIRECTUV: number;
  105037. SPECULARTERM: boolean;
  105038. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  105039. MICROSURFACEAUTOMATIC: boolean;
  105040. LODBASEDMICROSFURACE: boolean;
  105041. MICROSURFACEMAP: boolean;
  105042. MICROSURFACEMAPDIRECTUV: number;
  105043. METALLICWORKFLOW: boolean;
  105044. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  105045. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  105046. METALLNESSSTOREINMETALMAPBLUE: boolean;
  105047. AOSTOREINMETALMAPRED: boolean;
  105048. ENVIRONMENTBRDF: boolean;
  105049. ENVIRONMENTBRDF_RGBD: boolean;
  105050. NORMAL: boolean;
  105051. TANGENT: boolean;
  105052. BUMP: boolean;
  105053. BUMPDIRECTUV: number;
  105054. OBJECTSPACE_NORMALMAP: boolean;
  105055. PARALLAX: boolean;
  105056. PARALLAXOCCLUSION: boolean;
  105057. NORMALXYSCALE: boolean;
  105058. LIGHTMAP: boolean;
  105059. LIGHTMAPDIRECTUV: number;
  105060. USELIGHTMAPASSHADOWMAP: boolean;
  105061. GAMMALIGHTMAP: boolean;
  105062. REFLECTION: boolean;
  105063. REFLECTIONMAP_3D: boolean;
  105064. REFLECTIONMAP_SPHERICAL: boolean;
  105065. REFLECTIONMAP_PLANAR: boolean;
  105066. REFLECTIONMAP_CUBIC: boolean;
  105067. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105068. REFLECTIONMAP_PROJECTION: boolean;
  105069. REFLECTIONMAP_SKYBOX: boolean;
  105070. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105071. REFLECTIONMAP_EXPLICIT: boolean;
  105072. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105073. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105074. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105075. INVERTCUBICMAP: boolean;
  105076. USESPHERICALFROMREFLECTIONMAP: boolean;
  105077. SPHERICAL_HARMONICS: boolean;
  105078. USESPHERICALINVERTEX: boolean;
  105079. REFLECTIONMAP_OPPOSITEZ: boolean;
  105080. LODINREFLECTIONALPHA: boolean;
  105081. GAMMAREFLECTION: boolean;
  105082. RGBDREFLECTION: boolean;
  105083. RADIANCEOCCLUSION: boolean;
  105084. HORIZONOCCLUSION: boolean;
  105085. INSTANCES: boolean;
  105086. NUM_BONE_INFLUENCERS: number;
  105087. BonesPerMesh: number;
  105088. BONETEXTURE: boolean;
  105089. NONUNIFORMSCALING: boolean;
  105090. MORPHTARGETS: boolean;
  105091. MORPHTARGETS_NORMAL: boolean;
  105092. MORPHTARGETS_TANGENT: boolean;
  105093. NUM_MORPH_INFLUENCERS: number;
  105094. IMAGEPROCESSING: boolean;
  105095. VIGNETTE: boolean;
  105096. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105097. VIGNETTEBLENDMODEOPAQUE: boolean;
  105098. TONEMAPPING: boolean;
  105099. TONEMAPPING_ACES: boolean;
  105100. CONTRAST: boolean;
  105101. COLORCURVES: boolean;
  105102. COLORGRADING: boolean;
  105103. COLORGRADING3D: boolean;
  105104. SAMPLER3DGREENDEPTH: boolean;
  105105. SAMPLER3DBGRMAP: boolean;
  105106. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105107. EXPOSURE: boolean;
  105108. MULTIVIEW: boolean;
  105109. USEPHYSICALLIGHTFALLOFF: boolean;
  105110. USEGLTFLIGHTFALLOFF: boolean;
  105111. TWOSIDEDLIGHTING: boolean;
  105112. SHADOWFLOAT: boolean;
  105113. CLIPPLANE: boolean;
  105114. CLIPPLANE2: boolean;
  105115. CLIPPLANE3: boolean;
  105116. CLIPPLANE4: boolean;
  105117. POINTSIZE: boolean;
  105118. FOG: boolean;
  105119. LOGARITHMICDEPTH: boolean;
  105120. FORCENORMALFORWARD: boolean;
  105121. SPECULARAA: boolean;
  105122. CLEARCOAT: boolean;
  105123. CLEARCOAT_DEFAULTIOR: boolean;
  105124. CLEARCOAT_TEXTURE: boolean;
  105125. CLEARCOAT_TEXTUREDIRECTUV: number;
  105126. CLEARCOAT_BUMP: boolean;
  105127. CLEARCOAT_BUMPDIRECTUV: number;
  105128. CLEARCOAT_TINT: boolean;
  105129. CLEARCOAT_TINT_TEXTURE: boolean;
  105130. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105131. ANISOTROPIC: boolean;
  105132. ANISOTROPIC_TEXTURE: boolean;
  105133. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105134. BRDF_V_HEIGHT_CORRELATED: boolean;
  105135. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105136. SHEEN: boolean;
  105137. SHEEN_TEXTURE: boolean;
  105138. SHEEN_TEXTUREDIRECTUV: number;
  105139. SHEEN_LINKWITHALBEDO: boolean;
  105140. SUBSURFACE: boolean;
  105141. SS_REFRACTION: boolean;
  105142. SS_TRANSLUCENCY: boolean;
  105143. SS_SCATERRING: boolean;
  105144. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105145. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105146. SS_REFRACTIONMAP_3D: boolean;
  105147. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105148. SS_LODINREFRACTIONALPHA: boolean;
  105149. SS_GAMMAREFRACTION: boolean;
  105150. SS_RGBDREFRACTION: boolean;
  105151. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105152. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105153. UNLIT: boolean;
  105154. DEBUGMODE: number;
  105155. /**
  105156. * Initializes the PBR Material defines.
  105157. */
  105158. constructor();
  105159. /**
  105160. * Resets the PBR Material defines.
  105161. */
  105162. reset(): void;
  105163. }
  105164. /**
  105165. * The Physically based material base class of BJS.
  105166. *
  105167. * This offers the main features of a standard PBR material.
  105168. * For more information, please refer to the documentation :
  105169. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105170. */
  105171. export abstract class PBRBaseMaterial extends PushMaterial {
  105172. /**
  105173. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105174. */
  105175. static readonly PBRMATERIAL_OPAQUE: number;
  105176. /**
  105177. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105178. */
  105179. static readonly PBRMATERIAL_ALPHATEST: number;
  105180. /**
  105181. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105182. */
  105183. static readonly PBRMATERIAL_ALPHABLEND: number;
  105184. /**
  105185. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105186. * They are also discarded below the alpha cutoff threshold to improve performances.
  105187. */
  105188. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105189. /**
  105190. * Defines the default value of how much AO map is occluding the analytical lights
  105191. * (point spot...).
  105192. */
  105193. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105194. /**
  105195. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105196. */
  105197. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105198. /**
  105199. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105200. * to enhance interoperability with other engines.
  105201. */
  105202. static readonly LIGHTFALLOFF_GLTF: number;
  105203. /**
  105204. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105205. * to enhance interoperability with other materials.
  105206. */
  105207. static readonly LIGHTFALLOFF_STANDARD: number;
  105208. /**
  105209. * Intensity of the direct lights e.g. the four lights available in your scene.
  105210. * This impacts both the direct diffuse and specular highlights.
  105211. */
  105212. protected _directIntensity: number;
  105213. /**
  105214. * Intensity of the emissive part of the material.
  105215. * This helps controlling the emissive effect without modifying the emissive color.
  105216. */
  105217. protected _emissiveIntensity: number;
  105218. /**
  105219. * Intensity of the environment e.g. how much the environment will light the object
  105220. * either through harmonics for rough material or through the refelction for shiny ones.
  105221. */
  105222. protected _environmentIntensity: number;
  105223. /**
  105224. * This is a special control allowing the reduction of the specular highlights coming from the
  105225. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105226. */
  105227. protected _specularIntensity: number;
  105228. /**
  105229. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105230. */
  105231. private _lightingInfos;
  105232. /**
  105233. * Debug Control allowing disabling the bump map on this material.
  105234. */
  105235. protected _disableBumpMap: boolean;
  105236. /**
  105237. * AKA Diffuse Texture in standard nomenclature.
  105238. */
  105239. protected _albedoTexture: Nullable<BaseTexture>;
  105240. /**
  105241. * AKA Occlusion Texture in other nomenclature.
  105242. */
  105243. protected _ambientTexture: Nullable<BaseTexture>;
  105244. /**
  105245. * AKA Occlusion Texture Intensity in other nomenclature.
  105246. */
  105247. protected _ambientTextureStrength: number;
  105248. /**
  105249. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105250. * 1 means it completely occludes it
  105251. * 0 mean it has no impact
  105252. */
  105253. protected _ambientTextureImpactOnAnalyticalLights: number;
  105254. /**
  105255. * Stores the alpha values in a texture.
  105256. */
  105257. protected _opacityTexture: Nullable<BaseTexture>;
  105258. /**
  105259. * Stores the reflection values in a texture.
  105260. */
  105261. protected _reflectionTexture: Nullable<BaseTexture>;
  105262. /**
  105263. * Stores the emissive values in a texture.
  105264. */
  105265. protected _emissiveTexture: Nullable<BaseTexture>;
  105266. /**
  105267. * AKA Specular texture in other nomenclature.
  105268. */
  105269. protected _reflectivityTexture: Nullable<BaseTexture>;
  105270. /**
  105271. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105272. */
  105273. protected _metallicTexture: Nullable<BaseTexture>;
  105274. /**
  105275. * Specifies the metallic scalar of the metallic/roughness workflow.
  105276. * Can also be used to scale the metalness values of the metallic texture.
  105277. */
  105278. protected _metallic: Nullable<number>;
  105279. /**
  105280. * Specifies the roughness scalar of the metallic/roughness workflow.
  105281. * Can also be used to scale the roughness values of the metallic texture.
  105282. */
  105283. protected _roughness: Nullable<number>;
  105284. /**
  105285. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105286. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105287. */
  105288. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105289. /**
  105290. * Stores surface normal data used to displace a mesh in a texture.
  105291. */
  105292. protected _bumpTexture: Nullable<BaseTexture>;
  105293. /**
  105294. * Stores the pre-calculated light information of a mesh in a texture.
  105295. */
  105296. protected _lightmapTexture: Nullable<BaseTexture>;
  105297. /**
  105298. * The color of a material in ambient lighting.
  105299. */
  105300. protected _ambientColor: Color3;
  105301. /**
  105302. * AKA Diffuse Color in other nomenclature.
  105303. */
  105304. protected _albedoColor: Color3;
  105305. /**
  105306. * AKA Specular Color in other nomenclature.
  105307. */
  105308. protected _reflectivityColor: Color3;
  105309. /**
  105310. * The color applied when light is reflected from a material.
  105311. */
  105312. protected _reflectionColor: Color3;
  105313. /**
  105314. * The color applied when light is emitted from a material.
  105315. */
  105316. protected _emissiveColor: Color3;
  105317. /**
  105318. * AKA Glossiness in other nomenclature.
  105319. */
  105320. protected _microSurface: number;
  105321. /**
  105322. * Specifies that the material will use the light map as a show map.
  105323. */
  105324. protected _useLightmapAsShadowmap: boolean;
  105325. /**
  105326. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105327. * makes the reflect vector face the model (under horizon).
  105328. */
  105329. protected _useHorizonOcclusion: boolean;
  105330. /**
  105331. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105332. * too much the area relying on ambient texture to define their ambient occlusion.
  105333. */
  105334. protected _useRadianceOcclusion: boolean;
  105335. /**
  105336. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105337. */
  105338. protected _useAlphaFromAlbedoTexture: boolean;
  105339. /**
  105340. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105341. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105342. */
  105343. protected _useSpecularOverAlpha: boolean;
  105344. /**
  105345. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105346. */
  105347. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105348. /**
  105349. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105350. */
  105351. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105352. /**
  105353. * Specifies if the metallic texture contains the roughness information in its green channel.
  105354. */
  105355. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105356. /**
  105357. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105358. */
  105359. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105360. /**
  105361. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105362. */
  105363. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105364. /**
  105365. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105366. */
  105367. protected _useAmbientInGrayScale: boolean;
  105368. /**
  105369. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105370. * The material will try to infer what glossiness each pixel should be.
  105371. */
  105372. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105373. /**
  105374. * Defines the falloff type used in this material.
  105375. * It by default is Physical.
  105376. */
  105377. protected _lightFalloff: number;
  105378. /**
  105379. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105380. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105381. */
  105382. protected _useRadianceOverAlpha: boolean;
  105383. /**
  105384. * Allows using an object space normal map (instead of tangent space).
  105385. */
  105386. protected _useObjectSpaceNormalMap: boolean;
  105387. /**
  105388. * Allows using the bump map in parallax mode.
  105389. */
  105390. protected _useParallax: boolean;
  105391. /**
  105392. * Allows using the bump map in parallax occlusion mode.
  105393. */
  105394. protected _useParallaxOcclusion: boolean;
  105395. /**
  105396. * Controls the scale bias of the parallax mode.
  105397. */
  105398. protected _parallaxScaleBias: number;
  105399. /**
  105400. * If sets to true, disables all the lights affecting the material.
  105401. */
  105402. protected _disableLighting: boolean;
  105403. /**
  105404. * Number of Simultaneous lights allowed on the material.
  105405. */
  105406. protected _maxSimultaneousLights: number;
  105407. /**
  105408. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105409. */
  105410. protected _invertNormalMapX: boolean;
  105411. /**
  105412. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105413. */
  105414. protected _invertNormalMapY: boolean;
  105415. /**
  105416. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105417. */
  105418. protected _twoSidedLighting: boolean;
  105419. /**
  105420. * Defines the alpha limits in alpha test mode.
  105421. */
  105422. protected _alphaCutOff: number;
  105423. /**
  105424. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105425. */
  105426. protected _forceAlphaTest: boolean;
  105427. /**
  105428. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105429. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105430. */
  105431. protected _useAlphaFresnel: boolean;
  105432. /**
  105433. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105434. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105435. */
  105436. protected _useLinearAlphaFresnel: boolean;
  105437. /**
  105438. * The transparency mode of the material.
  105439. */
  105440. protected _transparencyMode: Nullable<number>;
  105441. /**
  105442. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105443. * from cos thetav and roughness:
  105444. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105445. */
  105446. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105447. /**
  105448. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105449. */
  105450. protected _forceIrradianceInFragment: boolean;
  105451. /**
  105452. * Force normal to face away from face.
  105453. */
  105454. protected _forceNormalForward: boolean;
  105455. /**
  105456. * Enables specular anti aliasing in the PBR shader.
  105457. * It will both interacts on the Geometry for analytical and IBL lighting.
  105458. * It also prefilter the roughness map based on the bump values.
  105459. */
  105460. protected _enableSpecularAntiAliasing: boolean;
  105461. /**
  105462. * Default configuration related to image processing available in the PBR Material.
  105463. */
  105464. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105465. /**
  105466. * Keep track of the image processing observer to allow dispose and replace.
  105467. */
  105468. private _imageProcessingObserver;
  105469. /**
  105470. * Attaches a new image processing configuration to the PBR Material.
  105471. * @param configuration
  105472. */
  105473. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105474. /**
  105475. * Stores the available render targets.
  105476. */
  105477. private _renderTargets;
  105478. /**
  105479. * Sets the global ambient color for the material used in lighting calculations.
  105480. */
  105481. private _globalAmbientColor;
  105482. /**
  105483. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105484. */
  105485. private _useLogarithmicDepth;
  105486. /**
  105487. * If set to true, no lighting calculations will be applied.
  105488. */
  105489. private _unlit;
  105490. private _debugMode;
  105491. /**
  105492. * @hidden
  105493. * This is reserved for the inspector.
  105494. * Defines the material debug mode.
  105495. * It helps seeing only some components of the material while troubleshooting.
  105496. */
  105497. debugMode: number;
  105498. /**
  105499. * @hidden
  105500. * This is reserved for the inspector.
  105501. * Specify from where on screen the debug mode should start.
  105502. * The value goes from -1 (full screen) to 1 (not visible)
  105503. * It helps with side by side comparison against the final render
  105504. * This defaults to -1
  105505. */
  105506. private debugLimit;
  105507. /**
  105508. * @hidden
  105509. * This is reserved for the inspector.
  105510. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105511. * You can use the factor to better multiply the final value.
  105512. */
  105513. private debugFactor;
  105514. /**
  105515. * Defines the clear coat layer parameters for the material.
  105516. */
  105517. readonly clearCoat: PBRClearCoatConfiguration;
  105518. /**
  105519. * Defines the anisotropic parameters for the material.
  105520. */
  105521. readonly anisotropy: PBRAnisotropicConfiguration;
  105522. /**
  105523. * Defines the BRDF parameters for the material.
  105524. */
  105525. readonly brdf: PBRBRDFConfiguration;
  105526. /**
  105527. * Defines the Sheen parameters for the material.
  105528. */
  105529. readonly sheen: PBRSheenConfiguration;
  105530. /**
  105531. * Defines the SubSurface parameters for the material.
  105532. */
  105533. readonly subSurface: PBRSubSurfaceConfiguration;
  105534. /**
  105535. * Custom callback helping to override the default shader used in the material.
  105536. */
  105537. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105538. /**
  105539. * Instantiates a new PBRMaterial instance.
  105540. *
  105541. * @param name The material name
  105542. * @param scene The scene the material will be use in.
  105543. */
  105544. constructor(name: string, scene: Scene);
  105545. /**
  105546. * Gets a boolean indicating that current material needs to register RTT
  105547. */
  105548. readonly hasRenderTargetTextures: boolean;
  105549. /**
  105550. * Gets the name of the material class.
  105551. */
  105552. getClassName(): string;
  105553. /**
  105554. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105555. */
  105556. /**
  105557. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105558. */
  105559. useLogarithmicDepth: boolean;
  105560. /**
  105561. * Gets the current transparency mode.
  105562. */
  105563. /**
  105564. * Sets the transparency mode of the material.
  105565. *
  105566. * | Value | Type | Description |
  105567. * | ----- | ----------------------------------- | ----------- |
  105568. * | 0 | OPAQUE | |
  105569. * | 1 | ALPHATEST | |
  105570. * | 2 | ALPHABLEND | |
  105571. * | 3 | ALPHATESTANDBLEND | |
  105572. *
  105573. */
  105574. transparencyMode: Nullable<number>;
  105575. /**
  105576. * Returns true if alpha blending should be disabled.
  105577. */
  105578. private readonly _disableAlphaBlending;
  105579. /**
  105580. * Specifies whether or not this material should be rendered in alpha blend mode.
  105581. */
  105582. needAlphaBlending(): boolean;
  105583. /**
  105584. * Specifies if the mesh will require alpha blending.
  105585. * @param mesh - BJS mesh.
  105586. */
  105587. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105588. /**
  105589. * Specifies whether or not this material should be rendered in alpha test mode.
  105590. */
  105591. needAlphaTesting(): boolean;
  105592. /**
  105593. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105594. */
  105595. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105596. /**
  105597. * Gets the texture used for the alpha test.
  105598. */
  105599. getAlphaTestTexture(): Nullable<BaseTexture>;
  105600. /**
  105601. * Specifies that the submesh is ready to be used.
  105602. * @param mesh - BJS mesh.
  105603. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105604. * @param useInstances - Specifies that instances should be used.
  105605. * @returns - boolean indicating that the submesh is ready or not.
  105606. */
  105607. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105608. /**
  105609. * Specifies if the material uses metallic roughness workflow.
  105610. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105611. */
  105612. isMetallicWorkflow(): boolean;
  105613. private _prepareEffect;
  105614. private _prepareDefines;
  105615. /**
  105616. * Force shader compilation
  105617. */
  105618. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105619. clipPlane: boolean;
  105620. }>): void;
  105621. /**
  105622. * Initializes the uniform buffer layout for the shader.
  105623. */
  105624. buildUniformLayout(): void;
  105625. /**
  105626. * Unbinds the material from the mesh
  105627. */
  105628. unbind(): void;
  105629. /**
  105630. * Binds the submesh data.
  105631. * @param world - The world matrix.
  105632. * @param mesh - The BJS mesh.
  105633. * @param subMesh - A submesh of the BJS mesh.
  105634. */
  105635. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105636. /**
  105637. * Returns the animatable textures.
  105638. * @returns - Array of animatable textures.
  105639. */
  105640. getAnimatables(): IAnimatable[];
  105641. /**
  105642. * Returns the texture used for reflections.
  105643. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105644. */
  105645. private _getReflectionTexture;
  105646. /**
  105647. * Returns an array of the actively used textures.
  105648. * @returns - Array of BaseTextures
  105649. */
  105650. getActiveTextures(): BaseTexture[];
  105651. /**
  105652. * Checks to see if a texture is used in the material.
  105653. * @param texture - Base texture to use.
  105654. * @returns - Boolean specifying if a texture is used in the material.
  105655. */
  105656. hasTexture(texture: BaseTexture): boolean;
  105657. /**
  105658. * Disposes the resources of the material.
  105659. * @param forceDisposeEffect - Forces the disposal of effects.
  105660. * @param forceDisposeTextures - Forces the disposal of all textures.
  105661. */
  105662. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105663. }
  105664. }
  105665. declare module BABYLON {
  105666. /**
  105667. * The Physically based material of BJS.
  105668. *
  105669. * This offers the main features of a standard PBR material.
  105670. * For more information, please refer to the documentation :
  105671. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105672. */
  105673. export class PBRMaterial extends PBRBaseMaterial {
  105674. /**
  105675. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105676. */
  105677. static readonly PBRMATERIAL_OPAQUE: number;
  105678. /**
  105679. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105680. */
  105681. static readonly PBRMATERIAL_ALPHATEST: number;
  105682. /**
  105683. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105684. */
  105685. static readonly PBRMATERIAL_ALPHABLEND: number;
  105686. /**
  105687. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105688. * They are also discarded below the alpha cutoff threshold to improve performances.
  105689. */
  105690. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105691. /**
  105692. * Defines the default value of how much AO map is occluding the analytical lights
  105693. * (point spot...).
  105694. */
  105695. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105696. /**
  105697. * Intensity of the direct lights e.g. the four lights available in your scene.
  105698. * This impacts both the direct diffuse and specular highlights.
  105699. */
  105700. directIntensity: number;
  105701. /**
  105702. * Intensity of the emissive part of the material.
  105703. * This helps controlling the emissive effect without modifying the emissive color.
  105704. */
  105705. emissiveIntensity: number;
  105706. /**
  105707. * Intensity of the environment e.g. how much the environment will light the object
  105708. * either through harmonics for rough material or through the refelction for shiny ones.
  105709. */
  105710. environmentIntensity: number;
  105711. /**
  105712. * This is a special control allowing the reduction of the specular highlights coming from the
  105713. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105714. */
  105715. specularIntensity: number;
  105716. /**
  105717. * Debug Control allowing disabling the bump map on this material.
  105718. */
  105719. disableBumpMap: boolean;
  105720. /**
  105721. * AKA Diffuse Texture in standard nomenclature.
  105722. */
  105723. albedoTexture: BaseTexture;
  105724. /**
  105725. * AKA Occlusion Texture in other nomenclature.
  105726. */
  105727. ambientTexture: BaseTexture;
  105728. /**
  105729. * AKA Occlusion Texture Intensity in other nomenclature.
  105730. */
  105731. ambientTextureStrength: number;
  105732. /**
  105733. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105734. * 1 means it completely occludes it
  105735. * 0 mean it has no impact
  105736. */
  105737. ambientTextureImpactOnAnalyticalLights: number;
  105738. /**
  105739. * Stores the alpha values in a texture.
  105740. */
  105741. opacityTexture: BaseTexture;
  105742. /**
  105743. * Stores the reflection values in a texture.
  105744. */
  105745. reflectionTexture: Nullable<BaseTexture>;
  105746. /**
  105747. * Stores the emissive values in a texture.
  105748. */
  105749. emissiveTexture: BaseTexture;
  105750. /**
  105751. * AKA Specular texture in other nomenclature.
  105752. */
  105753. reflectivityTexture: BaseTexture;
  105754. /**
  105755. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105756. */
  105757. metallicTexture: BaseTexture;
  105758. /**
  105759. * Specifies the metallic scalar of the metallic/roughness workflow.
  105760. * Can also be used to scale the metalness values of the metallic texture.
  105761. */
  105762. metallic: Nullable<number>;
  105763. /**
  105764. * Specifies the roughness scalar of the metallic/roughness workflow.
  105765. * Can also be used to scale the roughness values of the metallic texture.
  105766. */
  105767. roughness: Nullable<number>;
  105768. /**
  105769. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105770. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105771. */
  105772. microSurfaceTexture: BaseTexture;
  105773. /**
  105774. * Stores surface normal data used to displace a mesh in a texture.
  105775. */
  105776. bumpTexture: BaseTexture;
  105777. /**
  105778. * Stores the pre-calculated light information of a mesh in a texture.
  105779. */
  105780. lightmapTexture: BaseTexture;
  105781. /**
  105782. * Stores the refracted light information in a texture.
  105783. */
  105784. refractionTexture: Nullable<BaseTexture>;
  105785. /**
  105786. * The color of a material in ambient lighting.
  105787. */
  105788. ambientColor: Color3;
  105789. /**
  105790. * AKA Diffuse Color in other nomenclature.
  105791. */
  105792. albedoColor: Color3;
  105793. /**
  105794. * AKA Specular Color in other nomenclature.
  105795. */
  105796. reflectivityColor: Color3;
  105797. /**
  105798. * The color reflected from the material.
  105799. */
  105800. reflectionColor: Color3;
  105801. /**
  105802. * The color emitted from the material.
  105803. */
  105804. emissiveColor: Color3;
  105805. /**
  105806. * AKA Glossiness in other nomenclature.
  105807. */
  105808. microSurface: number;
  105809. /**
  105810. * source material index of refraction (IOR)' / 'destination material IOR.
  105811. */
  105812. indexOfRefraction: number;
  105813. /**
  105814. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105815. */
  105816. invertRefractionY: boolean;
  105817. /**
  105818. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105819. * Materials half opaque for instance using refraction could benefit from this control.
  105820. */
  105821. linkRefractionWithTransparency: boolean;
  105822. /**
  105823. * If true, the light map contains occlusion information instead of lighting info.
  105824. */
  105825. useLightmapAsShadowmap: boolean;
  105826. /**
  105827. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105828. */
  105829. useAlphaFromAlbedoTexture: boolean;
  105830. /**
  105831. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105832. */
  105833. forceAlphaTest: boolean;
  105834. /**
  105835. * Defines the alpha limits in alpha test mode.
  105836. */
  105837. alphaCutOff: number;
  105838. /**
  105839. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105840. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105841. */
  105842. useSpecularOverAlpha: boolean;
  105843. /**
  105844. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105845. */
  105846. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105847. /**
  105848. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105849. */
  105850. useRoughnessFromMetallicTextureAlpha: boolean;
  105851. /**
  105852. * Specifies if the metallic texture contains the roughness information in its green channel.
  105853. */
  105854. useRoughnessFromMetallicTextureGreen: boolean;
  105855. /**
  105856. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105857. */
  105858. useMetallnessFromMetallicTextureBlue: boolean;
  105859. /**
  105860. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105861. */
  105862. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105863. /**
  105864. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105865. */
  105866. useAmbientInGrayScale: boolean;
  105867. /**
  105868. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105869. * The material will try to infer what glossiness each pixel should be.
  105870. */
  105871. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105872. /**
  105873. * BJS is using an harcoded light falloff based on a manually sets up range.
  105874. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105875. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105876. */
  105877. /**
  105878. * BJS is using an harcoded light falloff based on a manually sets up range.
  105879. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105880. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105881. */
  105882. usePhysicalLightFalloff: boolean;
  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. /**
  105888. * In order to support the falloff compatibility with gltf, a special mode has been added
  105889. * to reproduce the gltf light falloff.
  105890. */
  105891. useGLTFLightFalloff: boolean;
  105892. /**
  105893. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105894. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105895. */
  105896. useRadianceOverAlpha: boolean;
  105897. /**
  105898. * Allows using an object space normal map (instead of tangent space).
  105899. */
  105900. useObjectSpaceNormalMap: boolean;
  105901. /**
  105902. * Allows using the bump map in parallax mode.
  105903. */
  105904. useParallax: boolean;
  105905. /**
  105906. * Allows using the bump map in parallax occlusion mode.
  105907. */
  105908. useParallaxOcclusion: boolean;
  105909. /**
  105910. * Controls the scale bias of the parallax mode.
  105911. */
  105912. parallaxScaleBias: number;
  105913. /**
  105914. * If sets to true, disables all the lights affecting the material.
  105915. */
  105916. disableLighting: boolean;
  105917. /**
  105918. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105919. */
  105920. forceIrradianceInFragment: boolean;
  105921. /**
  105922. * Number of Simultaneous lights allowed on the material.
  105923. */
  105924. maxSimultaneousLights: number;
  105925. /**
  105926. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105927. */
  105928. invertNormalMapX: boolean;
  105929. /**
  105930. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105931. */
  105932. invertNormalMapY: boolean;
  105933. /**
  105934. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105935. */
  105936. twoSidedLighting: boolean;
  105937. /**
  105938. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105939. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105940. */
  105941. useAlphaFresnel: boolean;
  105942. /**
  105943. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105944. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105945. */
  105946. useLinearAlphaFresnel: boolean;
  105947. /**
  105948. * Let user defines the brdf lookup texture used for IBL.
  105949. * A default 8bit version is embedded but you could point at :
  105950. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105951. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105952. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105953. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105954. */
  105955. environmentBRDFTexture: Nullable<BaseTexture>;
  105956. /**
  105957. * Force normal to face away from face.
  105958. */
  105959. forceNormalForward: boolean;
  105960. /**
  105961. * Enables specular anti aliasing in the PBR shader.
  105962. * It will both interacts on the Geometry for analytical and IBL lighting.
  105963. * It also prefilter the roughness map based on the bump values.
  105964. */
  105965. enableSpecularAntiAliasing: boolean;
  105966. /**
  105967. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105968. * makes the reflect vector face the model (under horizon).
  105969. */
  105970. useHorizonOcclusion: boolean;
  105971. /**
  105972. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105973. * too much the area relying on ambient texture to define their ambient occlusion.
  105974. */
  105975. useRadianceOcclusion: boolean;
  105976. /**
  105977. * If set to true, no lighting calculations will be applied.
  105978. */
  105979. unlit: boolean;
  105980. /**
  105981. * Gets the image processing configuration used either in this material.
  105982. */
  105983. /**
  105984. * Sets the Default image processing configuration used either in the this material.
  105985. *
  105986. * If sets to null, the scene one is in use.
  105987. */
  105988. imageProcessingConfiguration: ImageProcessingConfiguration;
  105989. /**
  105990. * Gets wether the color curves effect is enabled.
  105991. */
  105992. /**
  105993. * Sets wether the color curves effect is enabled.
  105994. */
  105995. cameraColorCurvesEnabled: boolean;
  105996. /**
  105997. * Gets wether the color grading effect is enabled.
  105998. */
  105999. /**
  106000. * Gets wether the color grading effect is enabled.
  106001. */
  106002. cameraColorGradingEnabled: boolean;
  106003. /**
  106004. * Gets wether tonemapping is enabled or not.
  106005. */
  106006. /**
  106007. * Sets wether tonemapping is enabled or not
  106008. */
  106009. cameraToneMappingEnabled: boolean;
  106010. /**
  106011. * The camera exposure used on this material.
  106012. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106013. * This corresponds to a photographic exposure.
  106014. */
  106015. /**
  106016. * The camera exposure used on this material.
  106017. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106018. * This corresponds to a photographic exposure.
  106019. */
  106020. cameraExposure: number;
  106021. /**
  106022. * Gets The camera contrast used on this material.
  106023. */
  106024. /**
  106025. * Sets The camera contrast used on this material.
  106026. */
  106027. cameraContrast: number;
  106028. /**
  106029. * Gets the Color Grading 2D Lookup Texture.
  106030. */
  106031. /**
  106032. * Sets the Color Grading 2D Lookup Texture.
  106033. */
  106034. cameraColorGradingTexture: Nullable<BaseTexture>;
  106035. /**
  106036. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106037. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106038. * 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;
  106039. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106040. */
  106041. /**
  106042. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106043. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106044. * 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;
  106045. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106046. */
  106047. cameraColorCurves: Nullable<ColorCurves>;
  106048. /**
  106049. * Instantiates a new PBRMaterial instance.
  106050. *
  106051. * @param name The material name
  106052. * @param scene The scene the material will be use in.
  106053. */
  106054. constructor(name: string, scene: Scene);
  106055. /**
  106056. * Returns the name of this material class.
  106057. */
  106058. getClassName(): string;
  106059. /**
  106060. * Makes a duplicate of the current material.
  106061. * @param name - name to use for the new material.
  106062. */
  106063. clone(name: string): PBRMaterial;
  106064. /**
  106065. * Serializes this PBR Material.
  106066. * @returns - An object with the serialized material.
  106067. */
  106068. serialize(): any;
  106069. /**
  106070. * Parses a PBR Material from a serialized object.
  106071. * @param source - Serialized object.
  106072. * @param scene - BJS scene instance.
  106073. * @param rootUrl - url for the scene object
  106074. * @returns - PBRMaterial
  106075. */
  106076. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  106077. }
  106078. }
  106079. declare module BABYLON {
  106080. /**
  106081. * Direct draw surface info
  106082. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  106083. */
  106084. export interface DDSInfo {
  106085. /**
  106086. * Width of the texture
  106087. */
  106088. width: number;
  106089. /**
  106090. * Width of the texture
  106091. */
  106092. height: number;
  106093. /**
  106094. * Number of Mipmaps for the texture
  106095. * @see https://en.wikipedia.org/wiki/Mipmap
  106096. */
  106097. mipmapCount: number;
  106098. /**
  106099. * If the textures format is a known fourCC format
  106100. * @see https://www.fourcc.org/
  106101. */
  106102. isFourCC: boolean;
  106103. /**
  106104. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  106105. */
  106106. isRGB: boolean;
  106107. /**
  106108. * If the texture is a lumincance format
  106109. */
  106110. isLuminance: boolean;
  106111. /**
  106112. * If this is a cube texture
  106113. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  106114. */
  106115. isCube: boolean;
  106116. /**
  106117. * If the texture is a compressed format eg. FOURCC_DXT1
  106118. */
  106119. isCompressed: boolean;
  106120. /**
  106121. * The dxgiFormat of the texture
  106122. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  106123. */
  106124. dxgiFormat: number;
  106125. /**
  106126. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  106127. */
  106128. textureType: number;
  106129. /**
  106130. * Sphericle polynomial created for the dds texture
  106131. */
  106132. sphericalPolynomial?: SphericalPolynomial;
  106133. }
  106134. /**
  106135. * Class used to provide DDS decompression tools
  106136. */
  106137. export class DDSTools {
  106138. /**
  106139. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  106140. */
  106141. static StoreLODInAlphaChannel: boolean;
  106142. /**
  106143. * Gets DDS information from an array buffer
  106144. * @param arrayBuffer defines the array buffer to read data from
  106145. * @returns the DDS information
  106146. */
  106147. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  106148. private static _FloatView;
  106149. private static _Int32View;
  106150. private static _ToHalfFloat;
  106151. private static _FromHalfFloat;
  106152. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  106153. private static _GetHalfFloatRGBAArrayBuffer;
  106154. private static _GetFloatRGBAArrayBuffer;
  106155. private static _GetFloatAsUIntRGBAArrayBuffer;
  106156. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  106157. private static _GetRGBAArrayBuffer;
  106158. private static _ExtractLongWordOrder;
  106159. private static _GetRGBArrayBuffer;
  106160. private static _GetLuminanceArrayBuffer;
  106161. /**
  106162. * Uploads DDS Levels to a Babylon Texture
  106163. * @hidden
  106164. */
  106165. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  106166. }
  106167. interface Engine {
  106168. /**
  106169. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  106170. * @param rootUrl defines the url where the file to load is located
  106171. * @param scene defines the current scene
  106172. * @param lodScale defines scale to apply to the mip map selection
  106173. * @param lodOffset defines offset to apply to the mip map selection
  106174. * @param onLoad defines an optional callback raised when the texture is loaded
  106175. * @param onError defines an optional callback raised if there is an issue to load the texture
  106176. * @param format defines the format of the data
  106177. * @param forcedExtension defines the extension to use to pick the right loader
  106178. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  106179. * @returns the cube texture as an InternalTexture
  106180. */
  106181. 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;
  106182. }
  106183. }
  106184. declare module BABYLON {
  106185. /**
  106186. * Implementation of the DDS Texture Loader.
  106187. * @hidden
  106188. */
  106189. export class _DDSTextureLoader implements IInternalTextureLoader {
  106190. /**
  106191. * Defines wether the loader supports cascade loading the different faces.
  106192. */
  106193. readonly supportCascades: boolean;
  106194. /**
  106195. * This returns if the loader support the current file information.
  106196. * @param extension defines the file extension of the file being loaded
  106197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106198. * @param fallback defines the fallback internal texture if any
  106199. * @param isBase64 defines whether the texture is encoded as a base64
  106200. * @param isBuffer defines whether the texture data are stored as a buffer
  106201. * @returns true if the loader can load the specified file
  106202. */
  106203. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106204. /**
  106205. * Transform the url before loading if required.
  106206. * @param rootUrl the url of the texture
  106207. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106208. * @returns the transformed texture
  106209. */
  106210. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106211. /**
  106212. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106213. * @param rootUrl the url of the texture
  106214. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106215. * @returns the fallback texture
  106216. */
  106217. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106218. /**
  106219. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106220. * @param data contains the texture data
  106221. * @param texture defines the BabylonJS internal texture
  106222. * @param createPolynomials will be true if polynomials have been requested
  106223. * @param onLoad defines the callback to trigger once the texture is ready
  106224. * @param onError defines the callback to trigger in case of error
  106225. */
  106226. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106227. /**
  106228. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106229. * @param data contains the texture data
  106230. * @param texture defines the BabylonJS internal texture
  106231. * @param callback defines the method to call once ready to upload
  106232. */
  106233. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106234. }
  106235. }
  106236. declare module BABYLON {
  106237. /** @hidden */
  106238. export var rgbdEncodePixelShader: {
  106239. name: string;
  106240. shader: string;
  106241. };
  106242. }
  106243. declare module BABYLON {
  106244. /**
  106245. * Raw texture data and descriptor sufficient for WebGL texture upload
  106246. */
  106247. export interface EnvironmentTextureInfo {
  106248. /**
  106249. * Version of the environment map
  106250. */
  106251. version: number;
  106252. /**
  106253. * Width of image
  106254. */
  106255. width: number;
  106256. /**
  106257. * Irradiance information stored in the file.
  106258. */
  106259. irradiance: any;
  106260. /**
  106261. * Specular information stored in the file.
  106262. */
  106263. specular: any;
  106264. }
  106265. /**
  106266. * Sets of helpers addressing the serialization and deserialization of environment texture
  106267. * stored in a BabylonJS env file.
  106268. * Those files are usually stored as .env files.
  106269. */
  106270. export class EnvironmentTextureTools {
  106271. /**
  106272. * Magic number identifying the env file.
  106273. */
  106274. private static _MagicBytes;
  106275. /**
  106276. * Gets the environment info from an env file.
  106277. * @param data The array buffer containing the .env bytes.
  106278. * @returns the environment file info (the json header) if successfully parsed.
  106279. */
  106280. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106281. /**
  106282. * Creates an environment texture from a loaded cube texture.
  106283. * @param texture defines the cube texture to convert in env file
  106284. * @return a promise containing the environment data if succesfull.
  106285. */
  106286. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106287. /**
  106288. * Creates a JSON representation of the spherical data.
  106289. * @param texture defines the texture containing the polynomials
  106290. * @return the JSON representation of the spherical info
  106291. */
  106292. private static _CreateEnvTextureIrradiance;
  106293. /**
  106294. * Uploads the texture info contained in the env file to the GPU.
  106295. * @param texture defines the internal texture to upload to
  106296. * @param arrayBuffer defines the buffer cotaining the data to load
  106297. * @param info defines the texture info retrieved through the GetEnvInfo method
  106298. * @returns a promise
  106299. */
  106300. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106301. /**
  106302. * Uploads the levels of image data to the GPU.
  106303. * @param texture defines the internal texture to upload to
  106304. * @param imageData defines the array buffer views of image data [mipmap][face]
  106305. * @returns a promise
  106306. */
  106307. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106308. /**
  106309. * Uploads spherical polynomials information to the texture.
  106310. * @param texture defines the texture we are trying to upload the information to
  106311. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106312. */
  106313. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106314. /** @hidden */
  106315. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106316. }
  106317. }
  106318. declare module BABYLON {
  106319. /**
  106320. * Implementation of the ENV Texture Loader.
  106321. * @hidden
  106322. */
  106323. export class _ENVTextureLoader implements IInternalTextureLoader {
  106324. /**
  106325. * Defines wether the loader supports cascade loading the different faces.
  106326. */
  106327. readonly supportCascades: boolean;
  106328. /**
  106329. * This returns if the loader support the current file information.
  106330. * @param extension defines the file extension of the file being loaded
  106331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106332. * @param fallback defines the fallback internal texture if any
  106333. * @param isBase64 defines whether the texture is encoded as a base64
  106334. * @param isBuffer defines whether the texture data are stored as a buffer
  106335. * @returns true if the loader can load the specified file
  106336. */
  106337. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106338. /**
  106339. * Transform the url before loading if required.
  106340. * @param rootUrl the url of the texture
  106341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106342. * @returns the transformed texture
  106343. */
  106344. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106345. /**
  106346. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106347. * @param rootUrl the url of the texture
  106348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106349. * @returns the fallback texture
  106350. */
  106351. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106352. /**
  106353. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106354. * @param data contains the texture data
  106355. * @param texture defines the BabylonJS internal texture
  106356. * @param createPolynomials will be true if polynomials have been requested
  106357. * @param onLoad defines the callback to trigger once the texture is ready
  106358. * @param onError defines the callback to trigger in case of error
  106359. */
  106360. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106361. /**
  106362. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106363. * @param data contains the texture data
  106364. * @param texture defines the BabylonJS internal texture
  106365. * @param callback defines the method to call once ready to upload
  106366. */
  106367. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106368. }
  106369. }
  106370. declare module BABYLON {
  106371. /**
  106372. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106373. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106374. */
  106375. export class KhronosTextureContainer {
  106376. /** contents of the KTX container file */
  106377. arrayBuffer: any;
  106378. private static HEADER_LEN;
  106379. private static COMPRESSED_2D;
  106380. private static COMPRESSED_3D;
  106381. private static TEX_2D;
  106382. private static TEX_3D;
  106383. /**
  106384. * Gets the openGL type
  106385. */
  106386. glType: number;
  106387. /**
  106388. * Gets the openGL type size
  106389. */
  106390. glTypeSize: number;
  106391. /**
  106392. * Gets the openGL format
  106393. */
  106394. glFormat: number;
  106395. /**
  106396. * Gets the openGL internal format
  106397. */
  106398. glInternalFormat: number;
  106399. /**
  106400. * Gets the base internal format
  106401. */
  106402. glBaseInternalFormat: number;
  106403. /**
  106404. * Gets image width in pixel
  106405. */
  106406. pixelWidth: number;
  106407. /**
  106408. * Gets image height in pixel
  106409. */
  106410. pixelHeight: number;
  106411. /**
  106412. * Gets image depth in pixels
  106413. */
  106414. pixelDepth: number;
  106415. /**
  106416. * Gets the number of array elements
  106417. */
  106418. numberOfArrayElements: number;
  106419. /**
  106420. * Gets the number of faces
  106421. */
  106422. numberOfFaces: number;
  106423. /**
  106424. * Gets the number of mipmap levels
  106425. */
  106426. numberOfMipmapLevels: number;
  106427. /**
  106428. * Gets the bytes of key value data
  106429. */
  106430. bytesOfKeyValueData: number;
  106431. /**
  106432. * Gets the load type
  106433. */
  106434. loadType: number;
  106435. /**
  106436. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106437. */
  106438. isInvalid: boolean;
  106439. /**
  106440. * Creates a new KhronosTextureContainer
  106441. * @param arrayBuffer contents of the KTX container file
  106442. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106443. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106444. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106445. */
  106446. constructor(
  106447. /** contents of the KTX container file */
  106448. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106449. /**
  106450. * Uploads KTX content to a Babylon Texture.
  106451. * It is assumed that the texture has already been created & is currently bound
  106452. * @hidden
  106453. */
  106454. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106455. private _upload2DCompressedLevels;
  106456. }
  106457. }
  106458. declare module BABYLON {
  106459. /**
  106460. * Implementation of the KTX Texture Loader.
  106461. * @hidden
  106462. */
  106463. export class _KTXTextureLoader implements IInternalTextureLoader {
  106464. /**
  106465. * Defines wether the loader supports cascade loading the different faces.
  106466. */
  106467. readonly supportCascades: boolean;
  106468. /**
  106469. * This returns if the loader support the current file information.
  106470. * @param extension defines the file extension of the file being loaded
  106471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106472. * @param fallback defines the fallback internal texture if any
  106473. * @param isBase64 defines whether the texture is encoded as a base64
  106474. * @param isBuffer defines whether the texture data are stored as a buffer
  106475. * @returns true if the loader can load the specified file
  106476. */
  106477. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106478. /**
  106479. * Transform the url before loading if required.
  106480. * @param rootUrl the url of the texture
  106481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106482. * @returns the transformed texture
  106483. */
  106484. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106485. /**
  106486. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106487. * @param rootUrl the url of the texture
  106488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106489. * @returns the fallback texture
  106490. */
  106491. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106492. /**
  106493. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106494. * @param data contains the texture data
  106495. * @param texture defines the BabylonJS internal texture
  106496. * @param createPolynomials will be true if polynomials have been requested
  106497. * @param onLoad defines the callback to trigger once the texture is ready
  106498. * @param onError defines the callback to trigger in case of error
  106499. */
  106500. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106501. /**
  106502. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106503. * @param data contains the texture data
  106504. * @param texture defines the BabylonJS internal texture
  106505. * @param callback defines the method to call once ready to upload
  106506. */
  106507. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106508. }
  106509. }
  106510. declare module BABYLON {
  106511. /** @hidden */
  106512. export var _forceSceneHelpersToBundle: boolean;
  106513. interface Scene {
  106514. /**
  106515. * Creates a default light for the scene.
  106516. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106517. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106518. */
  106519. createDefaultLight(replace?: boolean): void;
  106520. /**
  106521. * Creates a default camera for the scene.
  106522. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106523. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106524. * @param replace has default false, when true replaces the active camera in the scene
  106525. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106526. */
  106527. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106528. /**
  106529. * Creates a default camera and a default light.
  106530. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106531. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106532. * @param replace has the default false, when true replaces the active camera/light in the scene
  106533. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106534. */
  106535. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106536. /**
  106537. * Creates a new sky box
  106538. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106539. * @param environmentTexture defines the texture to use as environment texture
  106540. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106541. * @param scale defines the overall scale of the skybox
  106542. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106543. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106544. * @returns a new mesh holding the sky box
  106545. */
  106546. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106547. /**
  106548. * Creates a new environment
  106549. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106550. * @param options defines the options you can use to configure the environment
  106551. * @returns the new EnvironmentHelper
  106552. */
  106553. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106554. /**
  106555. * Creates a new VREXperienceHelper
  106556. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106557. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106558. * @returns a new VREXperienceHelper
  106559. */
  106560. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106561. /**
  106562. * Creates a new XREXperienceHelper
  106563. * @see http://doc.babylonjs.com/how_to/webxr
  106564. * @returns a promise for a new XREXperienceHelper
  106565. */
  106566. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106567. }
  106568. }
  106569. declare module BABYLON {
  106570. /**
  106571. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106572. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106573. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106574. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106575. */
  106576. export class VideoDome extends TransformNode {
  106577. /**
  106578. * Define the video source as a Monoscopic panoramic 360 video.
  106579. */
  106580. static readonly MODE_MONOSCOPIC: number;
  106581. /**
  106582. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106583. */
  106584. static readonly MODE_TOPBOTTOM: number;
  106585. /**
  106586. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106587. */
  106588. static readonly MODE_SIDEBYSIDE: number;
  106589. private _useDirectMapping;
  106590. /**
  106591. * The video texture being displayed on the sphere
  106592. */
  106593. protected _videoTexture: VideoTexture;
  106594. /**
  106595. * Gets the video texture being displayed on the sphere
  106596. */
  106597. readonly videoTexture: VideoTexture;
  106598. /**
  106599. * The skybox material
  106600. */
  106601. protected _material: BackgroundMaterial;
  106602. /**
  106603. * The surface used for the skybox
  106604. */
  106605. protected _mesh: Mesh;
  106606. /**
  106607. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106608. * Also see the options.resolution property.
  106609. */
  106610. fovMultiplier: number;
  106611. private _videoMode;
  106612. /**
  106613. * Gets or set the current video mode for the video. It can be:
  106614. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106615. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106616. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106617. */
  106618. videoMode: number;
  106619. /**
  106620. * Oberserver used in Stereoscopic VR Mode.
  106621. */
  106622. private _onBeforeCameraRenderObserver;
  106623. /**
  106624. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106625. * @param name Element's name, child elements will append suffixes for their own names.
  106626. * @param urlsOrVideo defines the url(s) or the video element to use
  106627. * @param options An object containing optional or exposed sub element properties
  106628. */
  106629. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106630. resolution?: number;
  106631. clickToPlay?: boolean;
  106632. autoPlay?: boolean;
  106633. loop?: boolean;
  106634. size?: number;
  106635. poster?: string;
  106636. faceForward?: boolean;
  106637. useDirectMapping?: boolean;
  106638. }, scene: Scene);
  106639. private _changeVideoMode;
  106640. /**
  106641. * Releases resources associated with this node.
  106642. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106643. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106644. */
  106645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106646. }
  106647. }
  106648. declare module BABYLON {
  106649. /**
  106650. * This class can be used to get instrumentation data from a Babylon engine
  106651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106652. */
  106653. export class EngineInstrumentation implements IDisposable {
  106654. /**
  106655. * Define the instrumented engine.
  106656. */
  106657. engine: Engine;
  106658. private _captureGPUFrameTime;
  106659. private _gpuFrameTimeToken;
  106660. private _gpuFrameTime;
  106661. private _captureShaderCompilationTime;
  106662. private _shaderCompilationTime;
  106663. private _onBeginFrameObserver;
  106664. private _onEndFrameObserver;
  106665. private _onBeforeShaderCompilationObserver;
  106666. private _onAfterShaderCompilationObserver;
  106667. /**
  106668. * Gets the perf counter used for GPU frame time
  106669. */
  106670. readonly gpuFrameTimeCounter: PerfCounter;
  106671. /**
  106672. * Gets the GPU frame time capture status
  106673. */
  106674. /**
  106675. * Enable or disable the GPU frame time capture
  106676. */
  106677. captureGPUFrameTime: boolean;
  106678. /**
  106679. * Gets the perf counter used for shader compilation time
  106680. */
  106681. readonly shaderCompilationTimeCounter: PerfCounter;
  106682. /**
  106683. * Gets the shader compilation time capture status
  106684. */
  106685. /**
  106686. * Enable or disable the shader compilation time capture
  106687. */
  106688. captureShaderCompilationTime: boolean;
  106689. /**
  106690. * Instantiates a new engine instrumentation.
  106691. * This class can be used to get instrumentation data from a Babylon engine
  106692. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106693. * @param engine Defines the engine to instrument
  106694. */
  106695. constructor(
  106696. /**
  106697. * Define the instrumented engine.
  106698. */
  106699. engine: Engine);
  106700. /**
  106701. * Dispose and release associated resources.
  106702. */
  106703. dispose(): void;
  106704. }
  106705. }
  106706. declare module BABYLON {
  106707. /**
  106708. * This class can be used to get instrumentation data from a Babylon engine
  106709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106710. */
  106711. export class SceneInstrumentation implements IDisposable {
  106712. /**
  106713. * Defines the scene to instrument
  106714. */
  106715. scene: Scene;
  106716. private _captureActiveMeshesEvaluationTime;
  106717. private _activeMeshesEvaluationTime;
  106718. private _captureRenderTargetsRenderTime;
  106719. private _renderTargetsRenderTime;
  106720. private _captureFrameTime;
  106721. private _frameTime;
  106722. private _captureRenderTime;
  106723. private _renderTime;
  106724. private _captureInterFrameTime;
  106725. private _interFrameTime;
  106726. private _captureParticlesRenderTime;
  106727. private _particlesRenderTime;
  106728. private _captureSpritesRenderTime;
  106729. private _spritesRenderTime;
  106730. private _capturePhysicsTime;
  106731. private _physicsTime;
  106732. private _captureAnimationsTime;
  106733. private _animationsTime;
  106734. private _captureCameraRenderTime;
  106735. private _cameraRenderTime;
  106736. private _onBeforeActiveMeshesEvaluationObserver;
  106737. private _onAfterActiveMeshesEvaluationObserver;
  106738. private _onBeforeRenderTargetsRenderObserver;
  106739. private _onAfterRenderTargetsRenderObserver;
  106740. private _onAfterRenderObserver;
  106741. private _onBeforeDrawPhaseObserver;
  106742. private _onAfterDrawPhaseObserver;
  106743. private _onBeforeAnimationsObserver;
  106744. private _onBeforeParticlesRenderingObserver;
  106745. private _onAfterParticlesRenderingObserver;
  106746. private _onBeforeSpritesRenderingObserver;
  106747. private _onAfterSpritesRenderingObserver;
  106748. private _onBeforePhysicsObserver;
  106749. private _onAfterPhysicsObserver;
  106750. private _onAfterAnimationsObserver;
  106751. private _onBeforeCameraRenderObserver;
  106752. private _onAfterCameraRenderObserver;
  106753. /**
  106754. * Gets the perf counter used for active meshes evaluation time
  106755. */
  106756. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106757. /**
  106758. * Gets the active meshes evaluation time capture status
  106759. */
  106760. /**
  106761. * Enable or disable the active meshes evaluation time capture
  106762. */
  106763. captureActiveMeshesEvaluationTime: boolean;
  106764. /**
  106765. * Gets the perf counter used for render targets render time
  106766. */
  106767. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106768. /**
  106769. * Gets the render targets render time capture status
  106770. */
  106771. /**
  106772. * Enable or disable the render targets render time capture
  106773. */
  106774. captureRenderTargetsRenderTime: boolean;
  106775. /**
  106776. * Gets the perf counter used for particles render time
  106777. */
  106778. readonly particlesRenderTimeCounter: PerfCounter;
  106779. /**
  106780. * Gets the particles render time capture status
  106781. */
  106782. /**
  106783. * Enable or disable the particles render time capture
  106784. */
  106785. captureParticlesRenderTime: boolean;
  106786. /**
  106787. * Gets the perf counter used for sprites render time
  106788. */
  106789. readonly spritesRenderTimeCounter: PerfCounter;
  106790. /**
  106791. * Gets the sprites render time capture status
  106792. */
  106793. /**
  106794. * Enable or disable the sprites render time capture
  106795. */
  106796. captureSpritesRenderTime: boolean;
  106797. /**
  106798. * Gets the perf counter used for physics time
  106799. */
  106800. readonly physicsTimeCounter: PerfCounter;
  106801. /**
  106802. * Gets the physics time capture status
  106803. */
  106804. /**
  106805. * Enable or disable the physics time capture
  106806. */
  106807. capturePhysicsTime: boolean;
  106808. /**
  106809. * Gets the perf counter used for animations time
  106810. */
  106811. readonly animationsTimeCounter: PerfCounter;
  106812. /**
  106813. * Gets the animations time capture status
  106814. */
  106815. /**
  106816. * Enable or disable the animations time capture
  106817. */
  106818. captureAnimationsTime: boolean;
  106819. /**
  106820. * Gets the perf counter used for frame time capture
  106821. */
  106822. readonly frameTimeCounter: PerfCounter;
  106823. /**
  106824. * Gets the frame time capture status
  106825. */
  106826. /**
  106827. * Enable or disable the frame time capture
  106828. */
  106829. captureFrameTime: boolean;
  106830. /**
  106831. * Gets the perf counter used for inter-frames time capture
  106832. */
  106833. readonly interFrameTimeCounter: PerfCounter;
  106834. /**
  106835. * Gets the inter-frames time capture status
  106836. */
  106837. /**
  106838. * Enable or disable the inter-frames time capture
  106839. */
  106840. captureInterFrameTime: boolean;
  106841. /**
  106842. * Gets the perf counter used for render time capture
  106843. */
  106844. readonly renderTimeCounter: PerfCounter;
  106845. /**
  106846. * Gets the render time capture status
  106847. */
  106848. /**
  106849. * Enable or disable the render time capture
  106850. */
  106851. captureRenderTime: boolean;
  106852. /**
  106853. * Gets the perf counter used for camera render time capture
  106854. */
  106855. readonly cameraRenderTimeCounter: PerfCounter;
  106856. /**
  106857. * Gets the camera render time capture status
  106858. */
  106859. /**
  106860. * Enable or disable the camera render time capture
  106861. */
  106862. captureCameraRenderTime: boolean;
  106863. /**
  106864. * Gets the perf counter used for draw calls
  106865. */
  106866. readonly drawCallsCounter: PerfCounter;
  106867. /**
  106868. * Instantiates a new scene instrumentation.
  106869. * This class can be used to get instrumentation data from a Babylon engine
  106870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106871. * @param scene Defines the scene to instrument
  106872. */
  106873. constructor(
  106874. /**
  106875. * Defines the scene to instrument
  106876. */
  106877. scene: Scene);
  106878. /**
  106879. * Dispose and release associated resources.
  106880. */
  106881. dispose(): void;
  106882. }
  106883. }
  106884. declare module BABYLON {
  106885. /** @hidden */
  106886. export var glowMapGenerationPixelShader: {
  106887. name: string;
  106888. shader: string;
  106889. };
  106890. }
  106891. declare module BABYLON {
  106892. /** @hidden */
  106893. export var glowMapGenerationVertexShader: {
  106894. name: string;
  106895. shader: string;
  106896. };
  106897. }
  106898. declare module BABYLON {
  106899. /**
  106900. * Effect layer options. This helps customizing the behaviour
  106901. * of the effect layer.
  106902. */
  106903. export interface IEffectLayerOptions {
  106904. /**
  106905. * Multiplication factor apply to the canvas size to compute the render target size
  106906. * used to generated the objects (the smaller the faster).
  106907. */
  106908. mainTextureRatio: number;
  106909. /**
  106910. * Enforces a fixed size texture to ensure effect stability across devices.
  106911. */
  106912. mainTextureFixedSize?: number;
  106913. /**
  106914. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106915. */
  106916. alphaBlendingMode: number;
  106917. /**
  106918. * The camera attached to the layer.
  106919. */
  106920. camera: Nullable<Camera>;
  106921. /**
  106922. * The rendering group to draw the layer in.
  106923. */
  106924. renderingGroupId: number;
  106925. }
  106926. /**
  106927. * The effect layer Helps adding post process effect blended with the main pass.
  106928. *
  106929. * This can be for instance use to generate glow or higlight effects on the scene.
  106930. *
  106931. * The effect layer class can not be used directly and is intented to inherited from to be
  106932. * customized per effects.
  106933. */
  106934. export abstract class EffectLayer {
  106935. private _vertexBuffers;
  106936. private _indexBuffer;
  106937. private _cachedDefines;
  106938. private _effectLayerMapGenerationEffect;
  106939. private _effectLayerOptions;
  106940. private _mergeEffect;
  106941. protected _scene: Scene;
  106942. protected _engine: Engine;
  106943. protected _maxSize: number;
  106944. protected _mainTextureDesiredSize: ISize;
  106945. protected _mainTexture: RenderTargetTexture;
  106946. protected _shouldRender: boolean;
  106947. protected _postProcesses: PostProcess[];
  106948. protected _textures: BaseTexture[];
  106949. protected _emissiveTextureAndColor: {
  106950. texture: Nullable<BaseTexture>;
  106951. color: Color4;
  106952. };
  106953. /**
  106954. * The name of the layer
  106955. */
  106956. name: string;
  106957. /**
  106958. * The clear color of the texture used to generate the glow map.
  106959. */
  106960. neutralColor: Color4;
  106961. /**
  106962. * Specifies wether the highlight layer is enabled or not.
  106963. */
  106964. isEnabled: boolean;
  106965. /**
  106966. * Gets the camera attached to the layer.
  106967. */
  106968. readonly camera: Nullable<Camera>;
  106969. /**
  106970. * Gets the rendering group id the layer should render in.
  106971. */
  106972. readonly renderingGroupId: number;
  106973. /**
  106974. * An event triggered when the effect layer has been disposed.
  106975. */
  106976. onDisposeObservable: Observable<EffectLayer>;
  106977. /**
  106978. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106979. */
  106980. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106981. /**
  106982. * An event triggered when the generated texture is being merged in the scene.
  106983. */
  106984. onBeforeComposeObservable: Observable<EffectLayer>;
  106985. /**
  106986. * An event triggered when the generated texture has been merged in the scene.
  106987. */
  106988. onAfterComposeObservable: Observable<EffectLayer>;
  106989. /**
  106990. * An event triggered when the efffect layer changes its size.
  106991. */
  106992. onSizeChangedObservable: Observable<EffectLayer>;
  106993. /** @hidden */
  106994. static _SceneComponentInitialization: (scene: Scene) => void;
  106995. /**
  106996. * Instantiates a new effect Layer and references it in the scene.
  106997. * @param name The name of the layer
  106998. * @param scene The scene to use the layer in
  106999. */
  107000. constructor(
  107001. /** The Friendly of the effect in the scene */
  107002. name: string, scene: Scene);
  107003. /**
  107004. * Get the effect name of the layer.
  107005. * @return The effect name
  107006. */
  107007. abstract getEffectName(): string;
  107008. /**
  107009. * Checks for the readiness of the element composing the layer.
  107010. * @param subMesh the mesh to check for
  107011. * @param useInstances specify wether or not to use instances to render the mesh
  107012. * @return true if ready otherwise, false
  107013. */
  107014. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107015. /**
  107016. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107017. * @returns true if the effect requires stencil during the main canvas render pass.
  107018. */
  107019. abstract needStencil(): boolean;
  107020. /**
  107021. * Create the merge effect. This is the shader use to blit the information back
  107022. * to the main canvas at the end of the scene rendering.
  107023. * @returns The effect containing the shader used to merge the effect on the main canvas
  107024. */
  107025. protected abstract _createMergeEffect(): Effect;
  107026. /**
  107027. * Creates the render target textures and post processes used in the effect layer.
  107028. */
  107029. protected abstract _createTextureAndPostProcesses(): void;
  107030. /**
  107031. * Implementation specific of rendering the generating effect on the main canvas.
  107032. * @param effect The effect used to render through
  107033. */
  107034. protected abstract _internalRender(effect: Effect): void;
  107035. /**
  107036. * Sets the required values for both the emissive texture and and the main color.
  107037. */
  107038. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107039. /**
  107040. * Free any resources and references associated to a mesh.
  107041. * Internal use
  107042. * @param mesh The mesh to free.
  107043. */
  107044. abstract _disposeMesh(mesh: Mesh): void;
  107045. /**
  107046. * Serializes this layer (Glow or Highlight for example)
  107047. * @returns a serialized layer object
  107048. */
  107049. abstract serialize?(): any;
  107050. /**
  107051. * Initializes the effect layer with the required options.
  107052. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  107053. */
  107054. protected _init(options: Partial<IEffectLayerOptions>): void;
  107055. /**
  107056. * Generates the index buffer of the full screen quad blending to the main canvas.
  107057. */
  107058. private _generateIndexBuffer;
  107059. /**
  107060. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  107061. */
  107062. private _generateVertexBuffer;
  107063. /**
  107064. * Sets the main texture desired size which is the closest power of two
  107065. * of the engine canvas size.
  107066. */
  107067. private _setMainTextureSize;
  107068. /**
  107069. * Creates the main texture for the effect layer.
  107070. */
  107071. protected _createMainTexture(): void;
  107072. /**
  107073. * Adds specific effects defines.
  107074. * @param defines The defines to add specifics to.
  107075. */
  107076. protected _addCustomEffectDefines(defines: string[]): void;
  107077. /**
  107078. * Checks for the readiness of the element composing the layer.
  107079. * @param subMesh the mesh to check for
  107080. * @param useInstances specify wether or not to use instances to render the mesh
  107081. * @param emissiveTexture the associated emissive texture used to generate the glow
  107082. * @return true if ready otherwise, false
  107083. */
  107084. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  107085. /**
  107086. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  107087. */
  107088. render(): void;
  107089. /**
  107090. * Determine if a given mesh will be used in the current effect.
  107091. * @param mesh mesh to test
  107092. * @returns true if the mesh will be used
  107093. */
  107094. hasMesh(mesh: AbstractMesh): boolean;
  107095. /**
  107096. * Returns true if the layer contains information to display, otherwise false.
  107097. * @returns true if the glow layer should be rendered
  107098. */
  107099. shouldRender(): boolean;
  107100. /**
  107101. * Returns true if the mesh should render, otherwise false.
  107102. * @param mesh The mesh to render
  107103. * @returns true if it should render otherwise false
  107104. */
  107105. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  107106. /**
  107107. * Returns true if the mesh can be rendered, otherwise false.
  107108. * @param mesh The mesh to render
  107109. * @param material The material used on the mesh
  107110. * @returns true if it can be rendered otherwise false
  107111. */
  107112. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107113. /**
  107114. * Returns true if the mesh should render, otherwise false.
  107115. * @param mesh The mesh to render
  107116. * @returns true if it should render otherwise false
  107117. */
  107118. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  107119. /**
  107120. * Renders the submesh passed in parameter to the generation map.
  107121. */
  107122. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  107123. /**
  107124. * Rebuild the required buffers.
  107125. * @hidden Internal use only.
  107126. */
  107127. _rebuild(): void;
  107128. /**
  107129. * Dispose only the render target textures and post process.
  107130. */
  107131. private _disposeTextureAndPostProcesses;
  107132. /**
  107133. * Dispose the highlight layer and free resources.
  107134. */
  107135. dispose(): void;
  107136. /**
  107137. * Gets the class name of the effect layer
  107138. * @returns the string with the class name of the effect layer
  107139. */
  107140. getClassName(): string;
  107141. /**
  107142. * Creates an effect layer from parsed effect layer data
  107143. * @param parsedEffectLayer defines effect layer data
  107144. * @param scene defines the current scene
  107145. * @param rootUrl defines the root URL containing the effect layer information
  107146. * @returns a parsed effect Layer
  107147. */
  107148. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  107149. }
  107150. }
  107151. declare module BABYLON {
  107152. interface AbstractScene {
  107153. /**
  107154. * The list of effect layers (highlights/glow) added to the scene
  107155. * @see http://doc.babylonjs.com/how_to/highlight_layer
  107156. * @see http://doc.babylonjs.com/how_to/glow_layer
  107157. */
  107158. effectLayers: Array<EffectLayer>;
  107159. /**
  107160. * Removes the given effect layer from this scene.
  107161. * @param toRemove defines the effect layer to remove
  107162. * @returns the index of the removed effect layer
  107163. */
  107164. removeEffectLayer(toRemove: EffectLayer): number;
  107165. /**
  107166. * Adds the given effect layer to this scene
  107167. * @param newEffectLayer defines the effect layer to add
  107168. */
  107169. addEffectLayer(newEffectLayer: EffectLayer): void;
  107170. }
  107171. /**
  107172. * Defines the layer scene component responsible to manage any effect layers
  107173. * in a given scene.
  107174. */
  107175. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  107176. /**
  107177. * The component name helpfull to identify the component in the list of scene components.
  107178. */
  107179. readonly name: string;
  107180. /**
  107181. * The scene the component belongs to.
  107182. */
  107183. scene: Scene;
  107184. private _engine;
  107185. private _renderEffects;
  107186. private _needStencil;
  107187. private _previousStencilState;
  107188. /**
  107189. * Creates a new instance of the component for the given scene
  107190. * @param scene Defines the scene to register the component in
  107191. */
  107192. constructor(scene: Scene);
  107193. /**
  107194. * Registers the component in a given scene
  107195. */
  107196. register(): void;
  107197. /**
  107198. * Rebuilds the elements related to this component in case of
  107199. * context lost for instance.
  107200. */
  107201. rebuild(): void;
  107202. /**
  107203. * Serializes the component data to the specified json object
  107204. * @param serializationObject The object to serialize to
  107205. */
  107206. serialize(serializationObject: any): void;
  107207. /**
  107208. * Adds all the element from the container to the scene
  107209. * @param container the container holding the elements
  107210. */
  107211. addFromContainer(container: AbstractScene): void;
  107212. /**
  107213. * Removes all the elements in the container from the scene
  107214. * @param container contains the elements to remove
  107215. * @param dispose if the removed element should be disposed (default: false)
  107216. */
  107217. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107218. /**
  107219. * Disposes the component and the associated ressources.
  107220. */
  107221. dispose(): void;
  107222. private _isReadyForMesh;
  107223. private _renderMainTexture;
  107224. private _setStencil;
  107225. private _setStencilBack;
  107226. private _draw;
  107227. private _drawCamera;
  107228. private _drawRenderingGroup;
  107229. }
  107230. }
  107231. declare module BABYLON {
  107232. /** @hidden */
  107233. export var glowMapMergePixelShader: {
  107234. name: string;
  107235. shader: string;
  107236. };
  107237. }
  107238. declare module BABYLON {
  107239. /** @hidden */
  107240. export var glowMapMergeVertexShader: {
  107241. name: string;
  107242. shader: string;
  107243. };
  107244. }
  107245. declare module BABYLON {
  107246. interface AbstractScene {
  107247. /**
  107248. * Return a the first highlight layer of the scene with a given name.
  107249. * @param name The name of the highlight layer to look for.
  107250. * @return The highlight layer if found otherwise null.
  107251. */
  107252. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107253. }
  107254. /**
  107255. * Glow layer options. This helps customizing the behaviour
  107256. * of the glow layer.
  107257. */
  107258. export interface IGlowLayerOptions {
  107259. /**
  107260. * Multiplication factor apply to the canvas size to compute the render target size
  107261. * used to generated the glowing objects (the smaller the faster).
  107262. */
  107263. mainTextureRatio: number;
  107264. /**
  107265. * Enforces a fixed size texture to ensure resize independant blur.
  107266. */
  107267. mainTextureFixedSize?: number;
  107268. /**
  107269. * How big is the kernel of the blur texture.
  107270. */
  107271. blurKernelSize: number;
  107272. /**
  107273. * The camera attached to the layer.
  107274. */
  107275. camera: Nullable<Camera>;
  107276. /**
  107277. * Enable MSAA by chosing the number of samples.
  107278. */
  107279. mainTextureSamples?: number;
  107280. /**
  107281. * The rendering group to draw the layer in.
  107282. */
  107283. renderingGroupId: number;
  107284. }
  107285. /**
  107286. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107287. *
  107288. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107289. * glowy meshes to your scene.
  107290. *
  107291. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107292. */
  107293. export class GlowLayer extends EffectLayer {
  107294. /**
  107295. * Effect Name of the layer.
  107296. */
  107297. static readonly EffectName: string;
  107298. /**
  107299. * The default blur kernel size used for the glow.
  107300. */
  107301. static DefaultBlurKernelSize: number;
  107302. /**
  107303. * The default texture size ratio used for the glow.
  107304. */
  107305. static DefaultTextureRatio: number;
  107306. /**
  107307. * Sets the kernel size of the blur.
  107308. */
  107309. /**
  107310. * Gets the kernel size of the blur.
  107311. */
  107312. blurKernelSize: number;
  107313. /**
  107314. * Sets the glow intensity.
  107315. */
  107316. /**
  107317. * Gets the glow intensity.
  107318. */
  107319. intensity: number;
  107320. private _options;
  107321. private _intensity;
  107322. private _horizontalBlurPostprocess1;
  107323. private _verticalBlurPostprocess1;
  107324. private _horizontalBlurPostprocess2;
  107325. private _verticalBlurPostprocess2;
  107326. private _blurTexture1;
  107327. private _blurTexture2;
  107328. private _postProcesses1;
  107329. private _postProcesses2;
  107330. private _includedOnlyMeshes;
  107331. private _excludedMeshes;
  107332. /**
  107333. * Callback used to let the user override the color selection on a per mesh basis
  107334. */
  107335. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107336. /**
  107337. * Callback used to let the user override the texture selection on a per mesh basis
  107338. */
  107339. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107340. /**
  107341. * Instantiates a new glow Layer and references it to the scene.
  107342. * @param name The name of the layer
  107343. * @param scene The scene to use the layer in
  107344. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107345. */
  107346. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107347. /**
  107348. * Get the effect name of the layer.
  107349. * @return The effect name
  107350. */
  107351. getEffectName(): string;
  107352. /**
  107353. * Create the merge effect. This is the shader use to blit the information back
  107354. * to the main canvas at the end of the scene rendering.
  107355. */
  107356. protected _createMergeEffect(): Effect;
  107357. /**
  107358. * Creates the render target textures and post processes used in the glow layer.
  107359. */
  107360. protected _createTextureAndPostProcesses(): void;
  107361. /**
  107362. * Checks for the readiness of the element composing the layer.
  107363. * @param subMesh the mesh to check for
  107364. * @param useInstances specify wether or not to use instances to render the mesh
  107365. * @param emissiveTexture the associated emissive texture used to generate the glow
  107366. * @return true if ready otherwise, false
  107367. */
  107368. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107369. /**
  107370. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107371. */
  107372. needStencil(): boolean;
  107373. /**
  107374. * Returns true if the mesh can be rendered, otherwise false.
  107375. * @param mesh The mesh to render
  107376. * @param material The material used on the mesh
  107377. * @returns true if it can be rendered otherwise false
  107378. */
  107379. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107380. /**
  107381. * Implementation specific of rendering the generating effect on the main canvas.
  107382. * @param effect The effect used to render through
  107383. */
  107384. protected _internalRender(effect: Effect): void;
  107385. /**
  107386. * Sets the required values for both the emissive texture and and the main color.
  107387. */
  107388. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107389. /**
  107390. * Returns true if the mesh should render, otherwise false.
  107391. * @param mesh The mesh to render
  107392. * @returns true if it should render otherwise false
  107393. */
  107394. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107395. /**
  107396. * Adds specific effects defines.
  107397. * @param defines The defines to add specifics to.
  107398. */
  107399. protected _addCustomEffectDefines(defines: string[]): void;
  107400. /**
  107401. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107402. * @param mesh The mesh to exclude from the glow layer
  107403. */
  107404. addExcludedMesh(mesh: Mesh): void;
  107405. /**
  107406. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107407. * @param mesh The mesh to remove
  107408. */
  107409. removeExcludedMesh(mesh: Mesh): void;
  107410. /**
  107411. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107412. * @param mesh The mesh to include in the glow layer
  107413. */
  107414. addIncludedOnlyMesh(mesh: Mesh): void;
  107415. /**
  107416. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107417. * @param mesh The mesh to remove
  107418. */
  107419. removeIncludedOnlyMesh(mesh: Mesh): void;
  107420. /**
  107421. * Determine if a given mesh will be used in the glow layer
  107422. * @param mesh The mesh to test
  107423. * @returns true if the mesh will be highlighted by the current glow layer
  107424. */
  107425. hasMesh(mesh: AbstractMesh): boolean;
  107426. /**
  107427. * Free any resources and references associated to a mesh.
  107428. * Internal use
  107429. * @param mesh The mesh to free.
  107430. * @hidden
  107431. */
  107432. _disposeMesh(mesh: Mesh): void;
  107433. /**
  107434. * Gets the class name of the effect layer
  107435. * @returns the string with the class name of the effect layer
  107436. */
  107437. getClassName(): string;
  107438. /**
  107439. * Serializes this glow layer
  107440. * @returns a serialized glow layer object
  107441. */
  107442. serialize(): any;
  107443. /**
  107444. * Creates a Glow Layer from parsed glow layer data
  107445. * @param parsedGlowLayer defines glow layer data
  107446. * @param scene defines the current scene
  107447. * @param rootUrl defines the root URL containing the glow layer information
  107448. * @returns a parsed Glow Layer
  107449. */
  107450. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107451. }
  107452. }
  107453. declare module BABYLON {
  107454. /** @hidden */
  107455. export var glowBlurPostProcessPixelShader: {
  107456. name: string;
  107457. shader: string;
  107458. };
  107459. }
  107460. declare module BABYLON {
  107461. interface AbstractScene {
  107462. /**
  107463. * Return a the first highlight layer of the scene with a given name.
  107464. * @param name The name of the highlight layer to look for.
  107465. * @return The highlight layer if found otherwise null.
  107466. */
  107467. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107468. }
  107469. /**
  107470. * Highlight layer options. This helps customizing the behaviour
  107471. * of the highlight layer.
  107472. */
  107473. export interface IHighlightLayerOptions {
  107474. /**
  107475. * Multiplication factor apply to the canvas size to compute the render target size
  107476. * used to generated the glowing objects (the smaller the faster).
  107477. */
  107478. mainTextureRatio: number;
  107479. /**
  107480. * Enforces a fixed size texture to ensure resize independant blur.
  107481. */
  107482. mainTextureFixedSize?: number;
  107483. /**
  107484. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107485. * of the picture to blur (the smaller the faster).
  107486. */
  107487. blurTextureSizeRatio: number;
  107488. /**
  107489. * How big in texel of the blur texture is the vertical blur.
  107490. */
  107491. blurVerticalSize: number;
  107492. /**
  107493. * How big in texel of the blur texture is the horizontal blur.
  107494. */
  107495. blurHorizontalSize: number;
  107496. /**
  107497. * Alpha blending mode used to apply the blur. Default is combine.
  107498. */
  107499. alphaBlendingMode: number;
  107500. /**
  107501. * The camera attached to the layer.
  107502. */
  107503. camera: Nullable<Camera>;
  107504. /**
  107505. * Should we display highlight as a solid stroke?
  107506. */
  107507. isStroke?: boolean;
  107508. /**
  107509. * The rendering group to draw the layer in.
  107510. */
  107511. renderingGroupId: number;
  107512. }
  107513. /**
  107514. * The highlight layer Helps adding a glow effect around a mesh.
  107515. *
  107516. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107517. * glowy meshes to your scene.
  107518. *
  107519. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107520. */
  107521. export class HighlightLayer extends EffectLayer {
  107522. name: string;
  107523. /**
  107524. * Effect Name of the highlight layer.
  107525. */
  107526. static readonly EffectName: string;
  107527. /**
  107528. * The neutral color used during the preparation of the glow effect.
  107529. * This is black by default as the blend operation is a blend operation.
  107530. */
  107531. static NeutralColor: Color4;
  107532. /**
  107533. * Stencil value used for glowing meshes.
  107534. */
  107535. static GlowingMeshStencilReference: number;
  107536. /**
  107537. * Stencil value used for the other meshes in the scene.
  107538. */
  107539. static NormalMeshStencilReference: number;
  107540. /**
  107541. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107542. */
  107543. innerGlow: boolean;
  107544. /**
  107545. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107546. */
  107547. outerGlow: boolean;
  107548. /**
  107549. * Specifies the horizontal size of the blur.
  107550. */
  107551. /**
  107552. * Gets the horizontal size of the blur.
  107553. */
  107554. blurHorizontalSize: number;
  107555. /**
  107556. * Specifies the vertical size of the blur.
  107557. */
  107558. /**
  107559. * Gets the vertical size of the blur.
  107560. */
  107561. blurVerticalSize: number;
  107562. /**
  107563. * An event triggered when the highlight layer is being blurred.
  107564. */
  107565. onBeforeBlurObservable: Observable<HighlightLayer>;
  107566. /**
  107567. * An event triggered when the highlight layer has been blurred.
  107568. */
  107569. onAfterBlurObservable: Observable<HighlightLayer>;
  107570. private _instanceGlowingMeshStencilReference;
  107571. private _options;
  107572. private _downSamplePostprocess;
  107573. private _horizontalBlurPostprocess;
  107574. private _verticalBlurPostprocess;
  107575. private _blurTexture;
  107576. private _meshes;
  107577. private _excludedMeshes;
  107578. /**
  107579. * Instantiates a new highlight Layer and references it to the scene..
  107580. * @param name The name of the layer
  107581. * @param scene The scene to use the layer in
  107582. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107583. */
  107584. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107585. /**
  107586. * Get the effect name of the layer.
  107587. * @return The effect name
  107588. */
  107589. getEffectName(): string;
  107590. /**
  107591. * Create the merge effect. This is the shader use to blit the information back
  107592. * to the main canvas at the end of the scene rendering.
  107593. */
  107594. protected _createMergeEffect(): Effect;
  107595. /**
  107596. * Creates the render target textures and post processes used in the highlight layer.
  107597. */
  107598. protected _createTextureAndPostProcesses(): void;
  107599. /**
  107600. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107601. */
  107602. needStencil(): boolean;
  107603. /**
  107604. * Checks for the readiness of the element composing the layer.
  107605. * @param subMesh the mesh to check for
  107606. * @param useInstances specify wether or not to use instances to render the mesh
  107607. * @param emissiveTexture the associated emissive texture used to generate the glow
  107608. * @return true if ready otherwise, false
  107609. */
  107610. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107611. /**
  107612. * Implementation specific of rendering the generating effect on the main canvas.
  107613. * @param effect The effect used to render through
  107614. */
  107615. protected _internalRender(effect: Effect): void;
  107616. /**
  107617. * Returns true if the layer contains information to display, otherwise false.
  107618. */
  107619. shouldRender(): boolean;
  107620. /**
  107621. * Returns true if the mesh should render, otherwise false.
  107622. * @param mesh The mesh to render
  107623. * @returns true if it should render otherwise false
  107624. */
  107625. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107626. /**
  107627. * Sets the required values for both the emissive texture and and the main color.
  107628. */
  107629. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107630. /**
  107631. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107632. * @param mesh The mesh to exclude from the highlight layer
  107633. */
  107634. addExcludedMesh(mesh: Mesh): void;
  107635. /**
  107636. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107637. * @param mesh The mesh to highlight
  107638. */
  107639. removeExcludedMesh(mesh: Mesh): void;
  107640. /**
  107641. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107642. * @param mesh mesh to test
  107643. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107644. */
  107645. hasMesh(mesh: AbstractMesh): boolean;
  107646. /**
  107647. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107648. * @param mesh The mesh to highlight
  107649. * @param color The color of the highlight
  107650. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107651. */
  107652. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107653. /**
  107654. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107655. * @param mesh The mesh to highlight
  107656. */
  107657. removeMesh(mesh: Mesh): void;
  107658. /**
  107659. * Force the stencil to the normal expected value for none glowing parts
  107660. */
  107661. private _defaultStencilReference;
  107662. /**
  107663. * Free any resources and references associated to a mesh.
  107664. * Internal use
  107665. * @param mesh The mesh to free.
  107666. * @hidden
  107667. */
  107668. _disposeMesh(mesh: Mesh): void;
  107669. /**
  107670. * Dispose the highlight layer and free resources.
  107671. */
  107672. dispose(): void;
  107673. /**
  107674. * Gets the class name of the effect layer
  107675. * @returns the string with the class name of the effect layer
  107676. */
  107677. getClassName(): string;
  107678. /**
  107679. * Serializes this Highlight layer
  107680. * @returns a serialized Highlight layer object
  107681. */
  107682. serialize(): any;
  107683. /**
  107684. * Creates a Highlight layer from parsed Highlight layer data
  107685. * @param parsedHightlightLayer defines the Highlight layer data
  107686. * @param scene defines the current scene
  107687. * @param rootUrl defines the root URL containing the Highlight layer information
  107688. * @returns a parsed Highlight layer
  107689. */
  107690. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107691. }
  107692. }
  107693. declare module BABYLON {
  107694. /** @hidden */
  107695. export var lensFlarePixelShader: {
  107696. name: string;
  107697. shader: string;
  107698. };
  107699. }
  107700. declare module BABYLON {
  107701. /** @hidden */
  107702. export var lensFlareVertexShader: {
  107703. name: string;
  107704. shader: string;
  107705. };
  107706. }
  107707. declare module BABYLON {
  107708. /**
  107709. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107710. * It is usually composed of several `lensFlare`.
  107711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107712. */
  107713. export class LensFlareSystem {
  107714. /**
  107715. * Define the name of the lens flare system
  107716. */
  107717. name: string;
  107718. /**
  107719. * List of lens flares used in this system.
  107720. */
  107721. lensFlares: LensFlare[];
  107722. /**
  107723. * Define a limit from the border the lens flare can be visible.
  107724. */
  107725. borderLimit: number;
  107726. /**
  107727. * Define a viewport border we do not want to see the lens flare in.
  107728. */
  107729. viewportBorder: number;
  107730. /**
  107731. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107732. */
  107733. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107734. /**
  107735. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107736. */
  107737. layerMask: number;
  107738. /**
  107739. * Define the id of the lens flare system in the scene.
  107740. * (equal to name by default)
  107741. */
  107742. id: string;
  107743. private _scene;
  107744. private _emitter;
  107745. private _vertexBuffers;
  107746. private _indexBuffer;
  107747. private _effect;
  107748. private _positionX;
  107749. private _positionY;
  107750. private _isEnabled;
  107751. /** @hidden */
  107752. static _SceneComponentInitialization: (scene: Scene) => void;
  107753. /**
  107754. * Instantiates a lens flare system.
  107755. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107756. * It is usually composed of several `lensFlare`.
  107757. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107758. * @param name Define the name of the lens flare system in the scene
  107759. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107760. * @param scene Define the scene the lens flare system belongs to
  107761. */
  107762. constructor(
  107763. /**
  107764. * Define the name of the lens flare system
  107765. */
  107766. name: string, emitter: any, scene: Scene);
  107767. /**
  107768. * Define if the lens flare system is enabled.
  107769. */
  107770. isEnabled: boolean;
  107771. /**
  107772. * Get the scene the effects belongs to.
  107773. * @returns the scene holding the lens flare system
  107774. */
  107775. getScene(): Scene;
  107776. /**
  107777. * Get the emitter of the lens flare system.
  107778. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107779. * @returns the emitter of the lens flare system
  107780. */
  107781. getEmitter(): any;
  107782. /**
  107783. * Set the emitter of the lens flare system.
  107784. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107785. * @param newEmitter Define the new emitter of the system
  107786. */
  107787. setEmitter(newEmitter: any): void;
  107788. /**
  107789. * Get the lens flare system emitter position.
  107790. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107791. * @returns the position
  107792. */
  107793. getEmitterPosition(): Vector3;
  107794. /**
  107795. * @hidden
  107796. */
  107797. computeEffectivePosition(globalViewport: Viewport): boolean;
  107798. /** @hidden */
  107799. _isVisible(): boolean;
  107800. /**
  107801. * @hidden
  107802. */
  107803. render(): boolean;
  107804. /**
  107805. * Dispose and release the lens flare with its associated resources.
  107806. */
  107807. dispose(): void;
  107808. /**
  107809. * Parse a lens flare system from a JSON repressentation
  107810. * @param parsedLensFlareSystem Define the JSON to parse
  107811. * @param scene Define the scene the parsed system should be instantiated in
  107812. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107813. * @returns the parsed system
  107814. */
  107815. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107816. /**
  107817. * Serialize the current Lens Flare System into a JSON representation.
  107818. * @returns the serialized JSON
  107819. */
  107820. serialize(): any;
  107821. }
  107822. }
  107823. declare module BABYLON {
  107824. /**
  107825. * This represents one of the lens effect in a `lensFlareSystem`.
  107826. * It controls one of the indiviual texture used in the effect.
  107827. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107828. */
  107829. export class LensFlare {
  107830. /**
  107831. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107832. */
  107833. size: number;
  107834. /**
  107835. * 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.
  107836. */
  107837. position: number;
  107838. /**
  107839. * Define the lens color.
  107840. */
  107841. color: Color3;
  107842. /**
  107843. * Define the lens texture.
  107844. */
  107845. texture: Nullable<Texture>;
  107846. /**
  107847. * Define the alpha mode to render this particular lens.
  107848. */
  107849. alphaMode: number;
  107850. private _system;
  107851. /**
  107852. * Creates a new Lens Flare.
  107853. * This represents one of the lens effect in a `lensFlareSystem`.
  107854. * It controls one of the indiviual texture used in the effect.
  107855. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107856. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107857. * @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.
  107858. * @param color Define the lens color
  107859. * @param imgUrl Define the lens texture url
  107860. * @param system Define the `lensFlareSystem` this flare is part of
  107861. * @returns The newly created Lens Flare
  107862. */
  107863. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107864. /**
  107865. * Instantiates a new Lens Flare.
  107866. * This represents one of the lens effect in a `lensFlareSystem`.
  107867. * It controls one of the indiviual texture used in the effect.
  107868. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107869. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107870. * @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.
  107871. * @param color Define the lens color
  107872. * @param imgUrl Define the lens texture url
  107873. * @param system Define the `lensFlareSystem` this flare is part of
  107874. */
  107875. constructor(
  107876. /**
  107877. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107878. */
  107879. size: number,
  107880. /**
  107881. * 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.
  107882. */
  107883. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107884. /**
  107885. * Dispose and release the lens flare with its associated resources.
  107886. */
  107887. dispose(): void;
  107888. }
  107889. }
  107890. declare module BABYLON {
  107891. interface AbstractScene {
  107892. /**
  107893. * The list of lens flare system added to the scene
  107894. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107895. */
  107896. lensFlareSystems: Array<LensFlareSystem>;
  107897. /**
  107898. * Removes the given lens flare system from this scene.
  107899. * @param toRemove The lens flare system to remove
  107900. * @returns The index of the removed lens flare system
  107901. */
  107902. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107903. /**
  107904. * Adds the given lens flare system to this scene
  107905. * @param newLensFlareSystem The lens flare system to add
  107906. */
  107907. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107908. /**
  107909. * Gets a lens flare system using its name
  107910. * @param name defines the name to look for
  107911. * @returns the lens flare system or null if not found
  107912. */
  107913. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107914. /**
  107915. * Gets a lens flare system using its id
  107916. * @param id defines the id to look for
  107917. * @returns the lens flare system or null if not found
  107918. */
  107919. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107920. }
  107921. /**
  107922. * Defines the lens flare scene component responsible to manage any lens flares
  107923. * in a given scene.
  107924. */
  107925. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107926. /**
  107927. * The component name helpfull to identify the component in the list of scene components.
  107928. */
  107929. readonly name: string;
  107930. /**
  107931. * The scene the component belongs to.
  107932. */
  107933. scene: Scene;
  107934. /**
  107935. * Creates a new instance of the component for the given scene
  107936. * @param scene Defines the scene to register the component in
  107937. */
  107938. constructor(scene: Scene);
  107939. /**
  107940. * Registers the component in a given scene
  107941. */
  107942. register(): void;
  107943. /**
  107944. * Rebuilds the elements related to this component in case of
  107945. * context lost for instance.
  107946. */
  107947. rebuild(): void;
  107948. /**
  107949. * Adds all the element from the container to the scene
  107950. * @param container the container holding the elements
  107951. */
  107952. addFromContainer(container: AbstractScene): void;
  107953. /**
  107954. * Removes all the elements in the container from the scene
  107955. * @param container contains the elements to remove
  107956. * @param dispose if the removed element should be disposed (default: false)
  107957. */
  107958. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107959. /**
  107960. * Serializes the component data to the specified json object
  107961. * @param serializationObject The object to serialize to
  107962. */
  107963. serialize(serializationObject: any): void;
  107964. /**
  107965. * Disposes the component and the associated ressources.
  107966. */
  107967. dispose(): void;
  107968. private _draw;
  107969. }
  107970. }
  107971. declare module BABYLON {
  107972. /**
  107973. * Defines the shadow generator component responsible to manage any shadow generators
  107974. * in a given scene.
  107975. */
  107976. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107977. /**
  107978. * The component name helpfull to identify the component in the list of scene components.
  107979. */
  107980. readonly name: string;
  107981. /**
  107982. * The scene the component belongs to.
  107983. */
  107984. scene: Scene;
  107985. /**
  107986. * Creates a new instance of the component for the given scene
  107987. * @param scene Defines the scene to register the component in
  107988. */
  107989. constructor(scene: Scene);
  107990. /**
  107991. * Registers the component in a given scene
  107992. */
  107993. register(): void;
  107994. /**
  107995. * Rebuilds the elements related to this component in case of
  107996. * context lost for instance.
  107997. */
  107998. rebuild(): void;
  107999. /**
  108000. * Serializes the component data to the specified json object
  108001. * @param serializationObject The object to serialize to
  108002. */
  108003. serialize(serializationObject: any): void;
  108004. /**
  108005. * Adds all the element from the container to the scene
  108006. * @param container the container holding the elements
  108007. */
  108008. addFromContainer(container: AbstractScene): void;
  108009. /**
  108010. * Removes all the elements in the container from the scene
  108011. * @param container contains the elements to remove
  108012. * @param dispose if the removed element should be disposed (default: false)
  108013. */
  108014. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108015. /**
  108016. * Rebuilds the elements related to this component in case of
  108017. * context lost for instance.
  108018. */
  108019. dispose(): void;
  108020. private _gatherRenderTargets;
  108021. }
  108022. }
  108023. declare module BABYLON {
  108024. /**
  108025. * A point light is a light defined by an unique point in world space.
  108026. * The light is emitted in every direction from this point.
  108027. * A good example of a point light is a standard light bulb.
  108028. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108029. */
  108030. export class PointLight extends ShadowLight {
  108031. private _shadowAngle;
  108032. /**
  108033. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  108034. * This specifies what angle the shadow will use to be created.
  108035. *
  108036. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  108037. */
  108038. /**
  108039. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  108040. * This specifies what angle the shadow will use to be created.
  108041. *
  108042. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  108043. */
  108044. shadowAngle: number;
  108045. /**
  108046. * Gets the direction if it has been set.
  108047. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  108048. */
  108049. /**
  108050. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  108051. */
  108052. direction: Vector3;
  108053. /**
  108054. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  108055. * A PointLight emits the light in every direction.
  108056. * It can cast shadows.
  108057. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  108058. * ```javascript
  108059. * var pointLight = new PointLight("pl", camera.position, scene);
  108060. * ```
  108061. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108062. * @param name The light friendly name
  108063. * @param position The position of the point light in the scene
  108064. * @param scene The scene the lights belongs to
  108065. */
  108066. constructor(name: string, position: Vector3, scene: Scene);
  108067. /**
  108068. * Returns the string "PointLight"
  108069. * @returns the class name
  108070. */
  108071. getClassName(): string;
  108072. /**
  108073. * Returns the integer 0.
  108074. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108075. */
  108076. getTypeID(): number;
  108077. /**
  108078. * Specifies wether or not the shadowmap should be a cube texture.
  108079. * @returns true if the shadowmap needs to be a cube texture.
  108080. */
  108081. needCube(): boolean;
  108082. /**
  108083. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  108084. * @param faceIndex The index of the face we are computed the direction to generate shadow
  108085. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  108086. */
  108087. getShadowDirection(faceIndex?: number): Vector3;
  108088. /**
  108089. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  108090. * - fov = PI / 2
  108091. * - aspect ratio : 1.0
  108092. * - z-near and far equal to the active camera minZ and maxZ.
  108093. * Returns the PointLight.
  108094. */
  108095. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108096. protected _buildUniformLayout(): void;
  108097. /**
  108098. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  108099. * @param effect The effect to update
  108100. * @param lightIndex The index of the light in the effect to update
  108101. * @returns The point light
  108102. */
  108103. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  108104. /**
  108105. * Prepares the list of defines specific to the light type.
  108106. * @param defines the list of defines
  108107. * @param lightIndex defines the index of the light for the effect
  108108. */
  108109. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108110. }
  108111. }
  108112. declare module BABYLON {
  108113. /**
  108114. * Header information of HDR texture files.
  108115. */
  108116. export interface HDRInfo {
  108117. /**
  108118. * The height of the texture in pixels.
  108119. */
  108120. height: number;
  108121. /**
  108122. * The width of the texture in pixels.
  108123. */
  108124. width: number;
  108125. /**
  108126. * The index of the beginning of the data in the binary file.
  108127. */
  108128. dataPosition: number;
  108129. }
  108130. /**
  108131. * This groups tools to convert HDR texture to native colors array.
  108132. */
  108133. export class HDRTools {
  108134. private static Ldexp;
  108135. private static Rgbe2float;
  108136. private static readStringLine;
  108137. /**
  108138. * Reads header information from an RGBE texture stored in a native array.
  108139. * More information on this format are available here:
  108140. * https://en.wikipedia.org/wiki/RGBE_image_format
  108141. *
  108142. * @param uint8array The binary file stored in native array.
  108143. * @return The header information.
  108144. */
  108145. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  108146. /**
  108147. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  108148. * This RGBE texture needs to store the information as a panorama.
  108149. *
  108150. * More information on this format are available here:
  108151. * https://en.wikipedia.org/wiki/RGBE_image_format
  108152. *
  108153. * @param buffer The binary file stored in an array buffer.
  108154. * @param size The expected size of the extracted cubemap.
  108155. * @return The Cube Map information.
  108156. */
  108157. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  108158. /**
  108159. * Returns the pixels data extracted from an RGBE texture.
  108160. * This pixels will be stored left to right up to down in the R G B order in one array.
  108161. *
  108162. * More information on this format are available here:
  108163. * https://en.wikipedia.org/wiki/RGBE_image_format
  108164. *
  108165. * @param uint8array The binary file stored in an array buffer.
  108166. * @param hdrInfo The header information of the file.
  108167. * @return The pixels data in RGB right to left up to down order.
  108168. */
  108169. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  108170. private static RGBE_ReadPixels_RLE;
  108171. }
  108172. }
  108173. declare module BABYLON {
  108174. /**
  108175. * This represents a texture coming from an HDR input.
  108176. *
  108177. * The only supported format is currently panorama picture stored in RGBE format.
  108178. * Example of such files can be found on HDRLib: http://hdrlib.com/
  108179. */
  108180. export class HDRCubeTexture extends BaseTexture {
  108181. private static _facesMapping;
  108182. private _generateHarmonics;
  108183. private _noMipmap;
  108184. private _textureMatrix;
  108185. private _size;
  108186. private _onLoad;
  108187. private _onError;
  108188. /**
  108189. * The texture URL.
  108190. */
  108191. url: string;
  108192. /**
  108193. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108194. */
  108195. coordinatesMode: number;
  108196. protected _isBlocking: boolean;
  108197. /**
  108198. * Sets wether or not the texture is blocking during loading.
  108199. */
  108200. /**
  108201. * Gets wether or not the texture is blocking during loading.
  108202. */
  108203. isBlocking: boolean;
  108204. protected _rotationY: number;
  108205. /**
  108206. * Sets texture matrix rotation angle around Y axis in radians.
  108207. */
  108208. /**
  108209. * Gets texture matrix rotation angle around Y axis radians.
  108210. */
  108211. rotationY: number;
  108212. /**
  108213. * Gets or sets the center of the bounding box associated with the cube texture
  108214. * It must define where the camera used to render the texture was set
  108215. */
  108216. boundingBoxPosition: Vector3;
  108217. private _boundingBoxSize;
  108218. /**
  108219. * Gets or sets the size of the bounding box associated with the cube texture
  108220. * When defined, the cubemap will switch to local mode
  108221. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108222. * @example https://www.babylonjs-playground.com/#RNASML
  108223. */
  108224. boundingBoxSize: Vector3;
  108225. /**
  108226. * Instantiates an HDRTexture from the following parameters.
  108227. *
  108228. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108229. * @param scene The scene the texture will be used in
  108230. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108231. * @param noMipmap Forces to not generate the mipmap if true
  108232. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108233. * @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)
  108234. * @param reserved Reserved flag for internal use.
  108235. */
  108236. 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>);
  108237. /**
  108238. * Get the current class name of the texture useful for serialization or dynamic coding.
  108239. * @returns "HDRCubeTexture"
  108240. */
  108241. getClassName(): string;
  108242. /**
  108243. * Occurs when the file is raw .hdr file.
  108244. */
  108245. private loadTexture;
  108246. clone(): HDRCubeTexture;
  108247. delayLoad(): void;
  108248. /**
  108249. * Get the texture reflection matrix used to rotate/transform the reflection.
  108250. * @returns the reflection matrix
  108251. */
  108252. getReflectionTextureMatrix(): Matrix;
  108253. /**
  108254. * Set the texture reflection matrix used to rotate/transform the reflection.
  108255. * @param value Define the reflection matrix to set
  108256. */
  108257. setReflectionTextureMatrix(value: Matrix): void;
  108258. /**
  108259. * Parses a JSON representation of an HDR Texture in order to create the texture
  108260. * @param parsedTexture Define the JSON representation
  108261. * @param scene Define the scene the texture should be created in
  108262. * @param rootUrl Define the root url in case we need to load relative dependencies
  108263. * @returns the newly created texture after parsing
  108264. */
  108265. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108266. serialize(): any;
  108267. }
  108268. }
  108269. declare module BABYLON {
  108270. /**
  108271. * Class used to control physics engine
  108272. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108273. */
  108274. export class PhysicsEngine implements IPhysicsEngine {
  108275. private _physicsPlugin;
  108276. /**
  108277. * Global value used to control the smallest number supported by the simulation
  108278. */
  108279. static Epsilon: number;
  108280. private _impostors;
  108281. private _joints;
  108282. /**
  108283. * Gets the gravity vector used by the simulation
  108284. */
  108285. gravity: Vector3;
  108286. /**
  108287. * Factory used to create the default physics plugin.
  108288. * @returns The default physics plugin
  108289. */
  108290. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108291. /**
  108292. * Creates a new Physics Engine
  108293. * @param gravity defines the gravity vector used by the simulation
  108294. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108295. */
  108296. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108297. /**
  108298. * Sets the gravity vector used by the simulation
  108299. * @param gravity defines the gravity vector to use
  108300. */
  108301. setGravity(gravity: Vector3): void;
  108302. /**
  108303. * Set the time step of the physics engine.
  108304. * Default is 1/60.
  108305. * To slow it down, enter 1/600 for example.
  108306. * To speed it up, 1/30
  108307. * @param newTimeStep defines the new timestep to apply to this world.
  108308. */
  108309. setTimeStep(newTimeStep?: number): void;
  108310. /**
  108311. * Get the time step of the physics engine.
  108312. * @returns the current time step
  108313. */
  108314. getTimeStep(): number;
  108315. /**
  108316. * Release all resources
  108317. */
  108318. dispose(): void;
  108319. /**
  108320. * Gets the name of the current physics plugin
  108321. * @returns the name of the plugin
  108322. */
  108323. getPhysicsPluginName(): string;
  108324. /**
  108325. * Adding a new impostor for the impostor tracking.
  108326. * This will be done by the impostor itself.
  108327. * @param impostor the impostor to add
  108328. */
  108329. addImpostor(impostor: PhysicsImpostor): void;
  108330. /**
  108331. * Remove an impostor from the engine.
  108332. * This impostor and its mesh will not longer be updated by the physics engine.
  108333. * @param impostor the impostor to remove
  108334. */
  108335. removeImpostor(impostor: PhysicsImpostor): void;
  108336. /**
  108337. * Add a joint to the physics engine
  108338. * @param mainImpostor defines the main impostor to which the joint is added.
  108339. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108340. * @param joint defines the joint that will connect both impostors.
  108341. */
  108342. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108343. /**
  108344. * Removes a joint from the simulation
  108345. * @param mainImpostor defines the impostor used with the joint
  108346. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108347. * @param joint defines the joint to remove
  108348. */
  108349. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108350. /**
  108351. * Called by the scene. No need to call it.
  108352. * @param delta defines the timespam between frames
  108353. */
  108354. _step(delta: number): void;
  108355. /**
  108356. * Gets the current plugin used to run the simulation
  108357. * @returns current plugin
  108358. */
  108359. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108360. /**
  108361. * Gets the list of physic impostors
  108362. * @returns an array of PhysicsImpostor
  108363. */
  108364. getImpostors(): Array<PhysicsImpostor>;
  108365. /**
  108366. * Gets the impostor for a physics enabled object
  108367. * @param object defines the object impersonated by the impostor
  108368. * @returns the PhysicsImpostor or null if not found
  108369. */
  108370. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108371. /**
  108372. * Gets the impostor for a physics body object
  108373. * @param body defines physics body used by the impostor
  108374. * @returns the PhysicsImpostor or null if not found
  108375. */
  108376. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108377. /**
  108378. * Does a raycast in the physics world
  108379. * @param from when should the ray start?
  108380. * @param to when should the ray end?
  108381. * @returns PhysicsRaycastResult
  108382. */
  108383. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108384. }
  108385. }
  108386. declare module BABYLON {
  108387. /** @hidden */
  108388. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108389. private _useDeltaForWorldStep;
  108390. world: any;
  108391. name: string;
  108392. private _physicsMaterials;
  108393. private _fixedTimeStep;
  108394. private _cannonRaycastResult;
  108395. private _raycastResult;
  108396. private _removeAfterStep;
  108397. BJSCANNON: any;
  108398. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108399. setGravity(gravity: Vector3): void;
  108400. setTimeStep(timeStep: number): void;
  108401. getTimeStep(): number;
  108402. executeStep(delta: number): void;
  108403. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108404. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108405. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108406. private _processChildMeshes;
  108407. removePhysicsBody(impostor: PhysicsImpostor): void;
  108408. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108409. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108410. private _addMaterial;
  108411. private _checkWithEpsilon;
  108412. private _createShape;
  108413. private _createHeightmap;
  108414. private _minus90X;
  108415. private _plus90X;
  108416. private _tmpPosition;
  108417. private _tmpDeltaPosition;
  108418. private _tmpUnityRotation;
  108419. private _updatePhysicsBodyTransformation;
  108420. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108421. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108422. isSupported(): boolean;
  108423. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108424. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108425. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108426. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108427. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108428. getBodyMass(impostor: PhysicsImpostor): number;
  108429. getBodyFriction(impostor: PhysicsImpostor): number;
  108430. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108431. getBodyRestitution(impostor: PhysicsImpostor): number;
  108432. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108433. sleepBody(impostor: PhysicsImpostor): void;
  108434. wakeUpBody(impostor: PhysicsImpostor): void;
  108435. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108436. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108437. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108438. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108439. getRadius(impostor: PhysicsImpostor): number;
  108440. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108441. dispose(): void;
  108442. private _extendNamespace;
  108443. /**
  108444. * Does a raycast in the physics world
  108445. * @param from when should the ray start?
  108446. * @param to when should the ray end?
  108447. * @returns PhysicsRaycastResult
  108448. */
  108449. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108450. }
  108451. }
  108452. declare module BABYLON {
  108453. /** @hidden */
  108454. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108455. world: any;
  108456. name: string;
  108457. BJSOIMO: any;
  108458. private _raycastResult;
  108459. constructor(iterations?: number, oimoInjection?: any);
  108460. setGravity(gravity: Vector3): void;
  108461. setTimeStep(timeStep: number): void;
  108462. getTimeStep(): number;
  108463. private _tmpImpostorsArray;
  108464. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108465. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108466. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108467. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108468. private _tmpPositionVector;
  108469. removePhysicsBody(impostor: PhysicsImpostor): void;
  108470. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108471. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108472. isSupported(): boolean;
  108473. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108474. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108475. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108476. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108477. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108478. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108479. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108480. getBodyMass(impostor: PhysicsImpostor): number;
  108481. getBodyFriction(impostor: PhysicsImpostor): number;
  108482. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108483. getBodyRestitution(impostor: PhysicsImpostor): number;
  108484. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108485. sleepBody(impostor: PhysicsImpostor): void;
  108486. wakeUpBody(impostor: PhysicsImpostor): void;
  108487. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108488. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108489. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108490. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108491. getRadius(impostor: PhysicsImpostor): number;
  108492. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108493. dispose(): void;
  108494. /**
  108495. * Does a raycast in the physics world
  108496. * @param from when should the ray start?
  108497. * @param to when should the ray end?
  108498. * @returns PhysicsRaycastResult
  108499. */
  108500. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108501. }
  108502. }
  108503. declare module BABYLON {
  108504. /**
  108505. * Class containing static functions to help procedurally build meshes
  108506. */
  108507. export class RibbonBuilder {
  108508. /**
  108509. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108510. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108511. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108512. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108513. * * 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
  108514. * * 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
  108515. * * 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
  108516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108519. * * 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
  108520. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108521. * * 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
  108522. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108524. * @param name defines the name of the mesh
  108525. * @param options defines the options used to create the mesh
  108526. * @param scene defines the hosting scene
  108527. * @returns the ribbon mesh
  108528. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108529. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108530. */
  108531. static CreateRibbon(name: string, options: {
  108532. pathArray: Vector3[][];
  108533. closeArray?: boolean;
  108534. closePath?: boolean;
  108535. offset?: number;
  108536. updatable?: boolean;
  108537. sideOrientation?: number;
  108538. frontUVs?: Vector4;
  108539. backUVs?: Vector4;
  108540. instance?: Mesh;
  108541. invertUV?: boolean;
  108542. uvs?: Vector2[];
  108543. colors?: Color4[];
  108544. }, scene?: Nullable<Scene>): Mesh;
  108545. }
  108546. }
  108547. declare module BABYLON {
  108548. /**
  108549. * Class containing static functions to help procedurally build meshes
  108550. */
  108551. export class ShapeBuilder {
  108552. /**
  108553. * 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.
  108554. * * 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.
  108555. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108556. * * 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.
  108557. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108558. * * 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
  108559. * * 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
  108560. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108563. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108565. * @param name defines the name of the mesh
  108566. * @param options defines the options used to create the mesh
  108567. * @param scene defines the hosting scene
  108568. * @returns the extruded shape mesh
  108569. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108571. */
  108572. static ExtrudeShape(name: string, options: {
  108573. shape: Vector3[];
  108574. path: Vector3[];
  108575. scale?: number;
  108576. rotation?: number;
  108577. cap?: number;
  108578. updatable?: boolean;
  108579. sideOrientation?: number;
  108580. frontUVs?: Vector4;
  108581. backUVs?: Vector4;
  108582. instance?: Mesh;
  108583. invertUV?: boolean;
  108584. }, scene?: Nullable<Scene>): Mesh;
  108585. /**
  108586. * Creates an custom extruded shape mesh.
  108587. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108588. * * 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.
  108589. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108590. * * 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
  108591. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108592. * * 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
  108593. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108594. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108595. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108596. * * 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
  108597. * * 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
  108598. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108601. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108603. * @param name defines the name of the mesh
  108604. * @param options defines the options used to create the mesh
  108605. * @param scene defines the hosting scene
  108606. * @returns the custom extruded shape mesh
  108607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108610. */
  108611. static ExtrudeShapeCustom(name: string, options: {
  108612. shape: Vector3[];
  108613. path: Vector3[];
  108614. scaleFunction?: any;
  108615. rotationFunction?: any;
  108616. ribbonCloseArray?: boolean;
  108617. ribbonClosePath?: boolean;
  108618. cap?: number;
  108619. updatable?: boolean;
  108620. sideOrientation?: number;
  108621. frontUVs?: Vector4;
  108622. backUVs?: Vector4;
  108623. instance?: Mesh;
  108624. invertUV?: boolean;
  108625. }, scene?: Nullable<Scene>): Mesh;
  108626. private static _ExtrudeShapeGeneric;
  108627. }
  108628. }
  108629. declare module BABYLON {
  108630. /**
  108631. * AmmoJS Physics plugin
  108632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108633. * @see https://github.com/kripken/ammo.js/
  108634. */
  108635. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108636. private _useDeltaForWorldStep;
  108637. /**
  108638. * Reference to the Ammo library
  108639. */
  108640. bjsAMMO: any;
  108641. /**
  108642. * Created ammoJS world which physics bodies are added to
  108643. */
  108644. world: any;
  108645. /**
  108646. * Name of the plugin
  108647. */
  108648. name: string;
  108649. private _timeStep;
  108650. private _fixedTimeStep;
  108651. private _maxSteps;
  108652. private _tmpQuaternion;
  108653. private _tmpAmmoTransform;
  108654. private _tmpAmmoQuaternion;
  108655. private _tmpAmmoConcreteContactResultCallback;
  108656. private _collisionConfiguration;
  108657. private _dispatcher;
  108658. private _overlappingPairCache;
  108659. private _solver;
  108660. private _softBodySolver;
  108661. private _tmpAmmoVectorA;
  108662. private _tmpAmmoVectorB;
  108663. private _tmpAmmoVectorC;
  108664. private _tmpAmmoVectorD;
  108665. private _tmpContactCallbackResult;
  108666. private _tmpAmmoVectorRCA;
  108667. private _tmpAmmoVectorRCB;
  108668. private _raycastResult;
  108669. private static readonly DISABLE_COLLISION_FLAG;
  108670. private static readonly KINEMATIC_FLAG;
  108671. private static readonly DISABLE_DEACTIVATION_FLAG;
  108672. /**
  108673. * Initializes the ammoJS plugin
  108674. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108675. * @param ammoInjection can be used to inject your own ammo reference
  108676. */
  108677. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108678. /**
  108679. * Sets the gravity of the physics world (m/(s^2))
  108680. * @param gravity Gravity to set
  108681. */
  108682. setGravity(gravity: Vector3): void;
  108683. /**
  108684. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108685. * @param timeStep timestep to use in seconds
  108686. */
  108687. setTimeStep(timeStep: number): void;
  108688. /**
  108689. * 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)
  108690. * @param fixedTimeStep fixedTimeStep to use in seconds
  108691. */
  108692. setFixedTimeStep(fixedTimeStep: number): void;
  108693. /**
  108694. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108695. * @param maxSteps the maximum number of steps by the physics engine per frame
  108696. */
  108697. setMaxSteps(maxSteps: number): void;
  108698. /**
  108699. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108700. * @returns the current timestep in seconds
  108701. */
  108702. getTimeStep(): number;
  108703. private _isImpostorInContact;
  108704. private _isImpostorPairInContact;
  108705. private _stepSimulation;
  108706. /**
  108707. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108708. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108709. * After the step the babylon meshes are set to the position of the physics imposters
  108710. * @param delta amount of time to step forward
  108711. * @param impostors array of imposters to update before/after the step
  108712. */
  108713. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108714. /**
  108715. * Update babylon mesh to match physics world object
  108716. * @param impostor imposter to match
  108717. */
  108718. private _afterSoftStep;
  108719. /**
  108720. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108721. * @param impostor imposter to match
  108722. */
  108723. private _ropeStep;
  108724. /**
  108725. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108726. * @param impostor imposter to match
  108727. */
  108728. private _softbodyOrClothStep;
  108729. private _tmpVector;
  108730. private _tmpMatrix;
  108731. /**
  108732. * Applies an impulse on the imposter
  108733. * @param impostor imposter to apply impulse to
  108734. * @param force amount of force to be applied to the imposter
  108735. * @param contactPoint the location to apply the impulse on the imposter
  108736. */
  108737. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108738. /**
  108739. * Applies a force on the imposter
  108740. * @param impostor imposter to apply force
  108741. * @param force amount of force to be applied to the imposter
  108742. * @param contactPoint the location to apply the force on the imposter
  108743. */
  108744. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108745. /**
  108746. * Creates a physics body using the plugin
  108747. * @param impostor the imposter to create the physics body on
  108748. */
  108749. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108750. /**
  108751. * Removes the physics body from the imposter and disposes of the body's memory
  108752. * @param impostor imposter to remove the physics body from
  108753. */
  108754. removePhysicsBody(impostor: PhysicsImpostor): void;
  108755. /**
  108756. * Generates a joint
  108757. * @param impostorJoint the imposter joint to create the joint with
  108758. */
  108759. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108760. /**
  108761. * Removes a joint
  108762. * @param impostorJoint the imposter joint to remove the joint from
  108763. */
  108764. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108765. private _addMeshVerts;
  108766. /**
  108767. * Initialise the soft body vertices to match its object's (mesh) vertices
  108768. * Softbody vertices (nodes) are in world space and to match this
  108769. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108770. * @param impostor to create the softbody for
  108771. */
  108772. private _softVertexData;
  108773. /**
  108774. * Create an impostor's soft body
  108775. * @param impostor to create the softbody for
  108776. */
  108777. private _createSoftbody;
  108778. /**
  108779. * Create cloth for an impostor
  108780. * @param impostor to create the softbody for
  108781. */
  108782. private _createCloth;
  108783. /**
  108784. * Create rope for an impostor
  108785. * @param impostor to create the softbody for
  108786. */
  108787. private _createRope;
  108788. private _addHullVerts;
  108789. private _createShape;
  108790. /**
  108791. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108792. * @param impostor imposter containing the physics body and babylon object
  108793. */
  108794. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108795. /**
  108796. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108797. * @param impostor imposter containing the physics body and babylon object
  108798. * @param newPosition new position
  108799. * @param newRotation new rotation
  108800. */
  108801. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108802. /**
  108803. * If this plugin is supported
  108804. * @returns true if its supported
  108805. */
  108806. isSupported(): boolean;
  108807. /**
  108808. * Sets the linear velocity of the physics body
  108809. * @param impostor imposter to set the velocity on
  108810. * @param velocity velocity to set
  108811. */
  108812. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108813. /**
  108814. * Sets the angular velocity of the physics body
  108815. * @param impostor imposter to set the velocity on
  108816. * @param velocity velocity to set
  108817. */
  108818. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108819. /**
  108820. * gets the linear velocity
  108821. * @param impostor imposter to get linear velocity from
  108822. * @returns linear velocity
  108823. */
  108824. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108825. /**
  108826. * gets the angular velocity
  108827. * @param impostor imposter to get angular velocity from
  108828. * @returns angular velocity
  108829. */
  108830. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108831. /**
  108832. * Sets the mass of physics body
  108833. * @param impostor imposter to set the mass on
  108834. * @param mass mass to set
  108835. */
  108836. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108837. /**
  108838. * Gets the mass of the physics body
  108839. * @param impostor imposter to get the mass from
  108840. * @returns mass
  108841. */
  108842. getBodyMass(impostor: PhysicsImpostor): number;
  108843. /**
  108844. * Gets friction of the impostor
  108845. * @param impostor impostor to get friction from
  108846. * @returns friction value
  108847. */
  108848. getBodyFriction(impostor: PhysicsImpostor): number;
  108849. /**
  108850. * Sets friction of the impostor
  108851. * @param impostor impostor to set friction on
  108852. * @param friction friction value
  108853. */
  108854. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108855. /**
  108856. * Gets restitution of the impostor
  108857. * @param impostor impostor to get restitution from
  108858. * @returns restitution value
  108859. */
  108860. getBodyRestitution(impostor: PhysicsImpostor): number;
  108861. /**
  108862. * Sets resitution of the impostor
  108863. * @param impostor impostor to set resitution on
  108864. * @param restitution resitution value
  108865. */
  108866. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108867. /**
  108868. * Gets pressure inside the impostor
  108869. * @param impostor impostor to get pressure from
  108870. * @returns pressure value
  108871. */
  108872. getBodyPressure(impostor: PhysicsImpostor): number;
  108873. /**
  108874. * Sets pressure inside a soft body impostor
  108875. * Cloth and rope must remain 0 pressure
  108876. * @param impostor impostor to set pressure on
  108877. * @param pressure pressure value
  108878. */
  108879. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108880. /**
  108881. * Gets stiffness of the impostor
  108882. * @param impostor impostor to get stiffness from
  108883. * @returns pressure value
  108884. */
  108885. getBodyStiffness(impostor: PhysicsImpostor): number;
  108886. /**
  108887. * Sets stiffness of the impostor
  108888. * @param impostor impostor to set stiffness on
  108889. * @param stiffness stiffness value from 0 to 1
  108890. */
  108891. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108892. /**
  108893. * Gets velocityIterations of the impostor
  108894. * @param impostor impostor to get velocity iterations from
  108895. * @returns velocityIterations value
  108896. */
  108897. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108898. /**
  108899. * Sets velocityIterations of the impostor
  108900. * @param impostor impostor to set velocity iterations on
  108901. * @param velocityIterations velocityIterations value
  108902. */
  108903. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108904. /**
  108905. * Gets positionIterations of the impostor
  108906. * @param impostor impostor to get position iterations from
  108907. * @returns positionIterations value
  108908. */
  108909. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108910. /**
  108911. * Sets positionIterations of the impostor
  108912. * @param impostor impostor to set position on
  108913. * @param positionIterations positionIterations value
  108914. */
  108915. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108916. /**
  108917. * Append an anchor to a cloth object
  108918. * @param impostor is the cloth impostor to add anchor to
  108919. * @param otherImpostor is the rigid impostor to anchor to
  108920. * @param width ratio across width from 0 to 1
  108921. * @param height ratio up height from 0 to 1
  108922. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108923. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108924. */
  108925. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108926. /**
  108927. * Append an hook to a rope object
  108928. * @param impostor is the rope impostor to add hook to
  108929. * @param otherImpostor is the rigid impostor to hook to
  108930. * @param length ratio along the rope from 0 to 1
  108931. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108932. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108933. */
  108934. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108935. /**
  108936. * Sleeps the physics body and stops it from being active
  108937. * @param impostor impostor to sleep
  108938. */
  108939. sleepBody(impostor: PhysicsImpostor): void;
  108940. /**
  108941. * Activates the physics body
  108942. * @param impostor impostor to activate
  108943. */
  108944. wakeUpBody(impostor: PhysicsImpostor): void;
  108945. /**
  108946. * Updates the distance parameters of the joint
  108947. * @param joint joint to update
  108948. * @param maxDistance maximum distance of the joint
  108949. * @param minDistance minimum distance of the joint
  108950. */
  108951. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108952. /**
  108953. * Sets a motor on the joint
  108954. * @param joint joint to set motor on
  108955. * @param speed speed of the motor
  108956. * @param maxForce maximum force of the motor
  108957. * @param motorIndex index of the motor
  108958. */
  108959. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108960. /**
  108961. * Sets the motors limit
  108962. * @param joint joint to set limit on
  108963. * @param upperLimit upper limit
  108964. * @param lowerLimit lower limit
  108965. */
  108966. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108967. /**
  108968. * Syncs the position and rotation of a mesh with the impostor
  108969. * @param mesh mesh to sync
  108970. * @param impostor impostor to update the mesh with
  108971. */
  108972. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108973. /**
  108974. * Gets the radius of the impostor
  108975. * @param impostor impostor to get radius from
  108976. * @returns the radius
  108977. */
  108978. getRadius(impostor: PhysicsImpostor): number;
  108979. /**
  108980. * Gets the box size of the impostor
  108981. * @param impostor impostor to get box size from
  108982. * @param result the resulting box size
  108983. */
  108984. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108985. /**
  108986. * Disposes of the impostor
  108987. */
  108988. dispose(): void;
  108989. /**
  108990. * Does a raycast in the physics world
  108991. * @param from when should the ray start?
  108992. * @param to when should the ray end?
  108993. * @returns PhysicsRaycastResult
  108994. */
  108995. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108996. }
  108997. }
  108998. declare module BABYLON {
  108999. interface AbstractScene {
  109000. /**
  109001. * The list of reflection probes added to the scene
  109002. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  109003. */
  109004. reflectionProbes: Array<ReflectionProbe>;
  109005. /**
  109006. * Removes the given reflection probe from this scene.
  109007. * @param toRemove The reflection probe to remove
  109008. * @returns The index of the removed reflection probe
  109009. */
  109010. removeReflectionProbe(toRemove: ReflectionProbe): number;
  109011. /**
  109012. * Adds the given reflection probe to this scene.
  109013. * @param newReflectionProbe The reflection probe to add
  109014. */
  109015. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  109016. }
  109017. /**
  109018. * Class used to generate realtime reflection / refraction cube textures
  109019. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  109020. */
  109021. export class ReflectionProbe {
  109022. /** defines the name of the probe */
  109023. name: string;
  109024. private _scene;
  109025. private _renderTargetTexture;
  109026. private _projectionMatrix;
  109027. private _viewMatrix;
  109028. private _target;
  109029. private _add;
  109030. private _attachedMesh;
  109031. private _invertYAxis;
  109032. /** Gets or sets probe position (center of the cube map) */
  109033. position: Vector3;
  109034. /**
  109035. * Creates a new reflection probe
  109036. * @param name defines the name of the probe
  109037. * @param size defines the texture resolution (for each face)
  109038. * @param scene defines the hosting scene
  109039. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  109040. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  109041. */
  109042. constructor(
  109043. /** defines the name of the probe */
  109044. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  109045. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  109046. samples: number;
  109047. /** Gets or sets the refresh rate to use (on every frame by default) */
  109048. refreshRate: number;
  109049. /**
  109050. * Gets the hosting scene
  109051. * @returns a Scene
  109052. */
  109053. getScene(): Scene;
  109054. /** Gets the internal CubeTexture used to render to */
  109055. readonly cubeTexture: RenderTargetTexture;
  109056. /** Gets the list of meshes to render */
  109057. readonly renderList: Nullable<AbstractMesh[]>;
  109058. /**
  109059. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  109060. * @param mesh defines the mesh to attach to
  109061. */
  109062. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  109063. /**
  109064. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  109065. * @param renderingGroupId The rendering group id corresponding to its index
  109066. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109067. */
  109068. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109069. /**
  109070. * Clean all associated resources
  109071. */
  109072. dispose(): void;
  109073. /**
  109074. * Converts the reflection probe information to a readable string for debug purpose.
  109075. * @param fullDetails Supports for multiple levels of logging within scene loading
  109076. * @returns the human readable reflection probe info
  109077. */
  109078. toString(fullDetails?: boolean): string;
  109079. /**
  109080. * Get the class name of the relfection probe.
  109081. * @returns "ReflectionProbe"
  109082. */
  109083. getClassName(): string;
  109084. /**
  109085. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  109086. * @returns The JSON representation of the texture
  109087. */
  109088. serialize(): any;
  109089. /**
  109090. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  109091. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  109092. * @param scene Define the scene the parsed reflection probe should be instantiated in
  109093. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109094. * @returns The parsed reflection probe if successful
  109095. */
  109096. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  109097. }
  109098. }
  109099. declare module BABYLON {
  109100. /** @hidden */
  109101. export var _BabylonLoaderRegistered: boolean;
  109102. }
  109103. declare module BABYLON {
  109104. /**
  109105. * The Physically based simple base material of BJS.
  109106. *
  109107. * This enables better naming and convention enforcements on top of the pbrMaterial.
  109108. * It is used as the base class for both the specGloss and metalRough conventions.
  109109. */
  109110. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  109111. /**
  109112. * Number of Simultaneous lights allowed on the material.
  109113. */
  109114. maxSimultaneousLights: number;
  109115. /**
  109116. * If sets to true, disables all the lights affecting the material.
  109117. */
  109118. disableLighting: boolean;
  109119. /**
  109120. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  109121. */
  109122. environmentTexture: BaseTexture;
  109123. /**
  109124. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109125. */
  109126. invertNormalMapX: boolean;
  109127. /**
  109128. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109129. */
  109130. invertNormalMapY: boolean;
  109131. /**
  109132. * Normal map used in the model.
  109133. */
  109134. normalTexture: BaseTexture;
  109135. /**
  109136. * Emissivie color used to self-illuminate the model.
  109137. */
  109138. emissiveColor: Color3;
  109139. /**
  109140. * Emissivie texture used to self-illuminate the model.
  109141. */
  109142. emissiveTexture: BaseTexture;
  109143. /**
  109144. * Occlusion Channel Strenght.
  109145. */
  109146. occlusionStrength: number;
  109147. /**
  109148. * Occlusion Texture of the material (adding extra occlusion effects).
  109149. */
  109150. occlusionTexture: BaseTexture;
  109151. /**
  109152. * Defines the alpha limits in alpha test mode.
  109153. */
  109154. alphaCutOff: number;
  109155. /**
  109156. * Gets the current double sided mode.
  109157. */
  109158. /**
  109159. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109160. */
  109161. doubleSided: boolean;
  109162. /**
  109163. * Stores the pre-calculated light information of a mesh in a texture.
  109164. */
  109165. lightmapTexture: BaseTexture;
  109166. /**
  109167. * If true, the light map contains occlusion information instead of lighting info.
  109168. */
  109169. useLightmapAsShadowmap: boolean;
  109170. /**
  109171. * Instantiates a new PBRMaterial instance.
  109172. *
  109173. * @param name The material name
  109174. * @param scene The scene the material will be use in.
  109175. */
  109176. constructor(name: string, scene: Scene);
  109177. getClassName(): string;
  109178. }
  109179. }
  109180. declare module BABYLON {
  109181. /**
  109182. * The PBR material of BJS following the metal roughness convention.
  109183. *
  109184. * This fits to the PBR convention in the GLTF definition:
  109185. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  109186. */
  109187. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  109188. /**
  109189. * The base color has two different interpretations depending on the value of metalness.
  109190. * When the material is a metal, the base color is the specific measured reflectance value
  109191. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  109192. * of the material.
  109193. */
  109194. baseColor: Color3;
  109195. /**
  109196. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109197. * well as opacity information in the alpha channel.
  109198. */
  109199. baseTexture: BaseTexture;
  109200. /**
  109201. * Specifies the metallic scalar value of the material.
  109202. * Can also be used to scale the metalness values of the metallic texture.
  109203. */
  109204. metallic: number;
  109205. /**
  109206. * Specifies the roughness scalar value of the material.
  109207. * Can also be used to scale the roughness values of the metallic texture.
  109208. */
  109209. roughness: number;
  109210. /**
  109211. * Texture containing both the metallic value in the B channel and the
  109212. * roughness value in the G channel to keep better precision.
  109213. */
  109214. metallicRoughnessTexture: BaseTexture;
  109215. /**
  109216. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109217. *
  109218. * @param name The material name
  109219. * @param scene The scene the material will be use in.
  109220. */
  109221. constructor(name: string, scene: Scene);
  109222. /**
  109223. * Return the currrent class name of the material.
  109224. */
  109225. getClassName(): string;
  109226. /**
  109227. * Makes a duplicate of the current material.
  109228. * @param name - name to use for the new material.
  109229. */
  109230. clone(name: string): PBRMetallicRoughnessMaterial;
  109231. /**
  109232. * Serialize the material to a parsable JSON object.
  109233. */
  109234. serialize(): any;
  109235. /**
  109236. * Parses a JSON object correponding to the serialize function.
  109237. */
  109238. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109239. }
  109240. }
  109241. declare module BABYLON {
  109242. /**
  109243. * The PBR material of BJS following the specular glossiness convention.
  109244. *
  109245. * This fits to the PBR convention in the GLTF definition:
  109246. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109247. */
  109248. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109249. /**
  109250. * Specifies the diffuse color of the material.
  109251. */
  109252. diffuseColor: Color3;
  109253. /**
  109254. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109255. * channel.
  109256. */
  109257. diffuseTexture: BaseTexture;
  109258. /**
  109259. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109260. */
  109261. specularColor: Color3;
  109262. /**
  109263. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109264. */
  109265. glossiness: number;
  109266. /**
  109267. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109268. */
  109269. specularGlossinessTexture: BaseTexture;
  109270. /**
  109271. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109272. *
  109273. * @param name The material name
  109274. * @param scene The scene the material will be use in.
  109275. */
  109276. constructor(name: string, scene: Scene);
  109277. /**
  109278. * Return the currrent class name of the material.
  109279. */
  109280. getClassName(): string;
  109281. /**
  109282. * Makes a duplicate of the current material.
  109283. * @param name - name to use for the new material.
  109284. */
  109285. clone(name: string): PBRSpecularGlossinessMaterial;
  109286. /**
  109287. * Serialize the material to a parsable JSON object.
  109288. */
  109289. serialize(): any;
  109290. /**
  109291. * Parses a JSON object correponding to the serialize function.
  109292. */
  109293. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109294. }
  109295. }
  109296. declare module BABYLON {
  109297. /**
  109298. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109299. * It can help converting any input color in a desired output one. This can then be used to create effects
  109300. * from sepia, black and white to sixties or futuristic rendering...
  109301. *
  109302. * The only supported format is currently 3dl.
  109303. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109304. */
  109305. export class ColorGradingTexture extends BaseTexture {
  109306. /**
  109307. * The current texture matrix. (will always be identity in color grading texture)
  109308. */
  109309. private _textureMatrix;
  109310. /**
  109311. * The texture URL.
  109312. */
  109313. url: string;
  109314. /**
  109315. * Empty line regex stored for GC.
  109316. */
  109317. private static _noneEmptyLineRegex;
  109318. private _engine;
  109319. /**
  109320. * Instantiates a ColorGradingTexture from the following parameters.
  109321. *
  109322. * @param url The location of the color gradind data (currently only supporting 3dl)
  109323. * @param scene The scene the texture will be used in
  109324. */
  109325. constructor(url: string, scene: Scene);
  109326. /**
  109327. * Returns the texture matrix used in most of the material.
  109328. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109329. */
  109330. getTextureMatrix(): Matrix;
  109331. /**
  109332. * Occurs when the file being loaded is a .3dl LUT file.
  109333. */
  109334. private load3dlTexture;
  109335. /**
  109336. * Starts the loading process of the texture.
  109337. */
  109338. private loadTexture;
  109339. /**
  109340. * Clones the color gradind texture.
  109341. */
  109342. clone(): ColorGradingTexture;
  109343. /**
  109344. * Called during delayed load for textures.
  109345. */
  109346. delayLoad(): void;
  109347. /**
  109348. * Parses a color grading texture serialized by Babylon.
  109349. * @param parsedTexture The texture information being parsedTexture
  109350. * @param scene The scene to load the texture in
  109351. * @param rootUrl The root url of the data assets to load
  109352. * @return A color gradind texture
  109353. */
  109354. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109355. /**
  109356. * Serializes the LUT texture to json format.
  109357. */
  109358. serialize(): any;
  109359. }
  109360. }
  109361. declare module BABYLON {
  109362. /**
  109363. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109364. */
  109365. export class EquiRectangularCubeTexture extends BaseTexture {
  109366. /** The six faces of the cube. */
  109367. private static _FacesMapping;
  109368. private _noMipmap;
  109369. private _onLoad;
  109370. private _onError;
  109371. /** The size of the cubemap. */
  109372. private _size;
  109373. /** The buffer of the image. */
  109374. private _buffer;
  109375. /** The width of the input image. */
  109376. private _width;
  109377. /** The height of the input image. */
  109378. private _height;
  109379. /** The URL to the image. */
  109380. url: string;
  109381. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109382. coordinatesMode: number;
  109383. /**
  109384. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109385. * @param url The location of the image
  109386. * @param scene The scene the texture will be used in
  109387. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109388. * @param noMipmap Forces to not generate the mipmap if true
  109389. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109390. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109391. * @param onLoad — defines a callback called when texture is loaded
  109392. * @param onError — defines a callback called if there is an error
  109393. */
  109394. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109395. /**
  109396. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109397. */
  109398. private loadImage;
  109399. /**
  109400. * Convert the image buffer into a cubemap and create a CubeTexture.
  109401. */
  109402. private loadTexture;
  109403. /**
  109404. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109405. * @param buffer The ArrayBuffer that should be converted.
  109406. * @returns The buffer as Float32Array.
  109407. */
  109408. private getFloat32ArrayFromArrayBuffer;
  109409. /**
  109410. * Get the current class name of the texture useful for serialization or dynamic coding.
  109411. * @returns "EquiRectangularCubeTexture"
  109412. */
  109413. getClassName(): string;
  109414. /**
  109415. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109416. * @returns A clone of the current EquiRectangularCubeTexture.
  109417. */
  109418. clone(): EquiRectangularCubeTexture;
  109419. }
  109420. }
  109421. declare module BABYLON {
  109422. /**
  109423. * Based on jsTGALoader - Javascript loader for TGA file
  109424. * By Vincent Thibault
  109425. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109426. */
  109427. export class TGATools {
  109428. private static _TYPE_INDEXED;
  109429. private static _TYPE_RGB;
  109430. private static _TYPE_GREY;
  109431. private static _TYPE_RLE_INDEXED;
  109432. private static _TYPE_RLE_RGB;
  109433. private static _TYPE_RLE_GREY;
  109434. private static _ORIGIN_MASK;
  109435. private static _ORIGIN_SHIFT;
  109436. private static _ORIGIN_BL;
  109437. private static _ORIGIN_BR;
  109438. private static _ORIGIN_UL;
  109439. private static _ORIGIN_UR;
  109440. /**
  109441. * Gets the header of a TGA file
  109442. * @param data defines the TGA data
  109443. * @returns the header
  109444. */
  109445. static GetTGAHeader(data: Uint8Array): any;
  109446. /**
  109447. * Uploads TGA content to a Babylon Texture
  109448. * @hidden
  109449. */
  109450. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109451. /** @hidden */
  109452. 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;
  109453. /** @hidden */
  109454. 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;
  109455. /** @hidden */
  109456. 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;
  109457. /** @hidden */
  109458. 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;
  109459. /** @hidden */
  109460. 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;
  109461. /** @hidden */
  109462. 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;
  109463. }
  109464. }
  109465. declare module BABYLON {
  109466. /**
  109467. * Implementation of the TGA Texture Loader.
  109468. * @hidden
  109469. */
  109470. export class _TGATextureLoader implements IInternalTextureLoader {
  109471. /**
  109472. * Defines wether the loader supports cascade loading the different faces.
  109473. */
  109474. readonly supportCascades: boolean;
  109475. /**
  109476. * This returns if the loader support the current file information.
  109477. * @param extension defines the file extension of the file being loaded
  109478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109479. * @param fallback defines the fallback internal texture if any
  109480. * @param isBase64 defines whether the texture is encoded as a base64
  109481. * @param isBuffer defines whether the texture data are stored as a buffer
  109482. * @returns true if the loader can load the specified file
  109483. */
  109484. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109485. /**
  109486. * Transform the url before loading if required.
  109487. * @param rootUrl the url of the texture
  109488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109489. * @returns the transformed texture
  109490. */
  109491. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109492. /**
  109493. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109494. * @param rootUrl the url of the texture
  109495. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109496. * @returns the fallback texture
  109497. */
  109498. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109499. /**
  109500. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109501. * @param data contains the texture data
  109502. * @param texture defines the BabylonJS internal texture
  109503. * @param createPolynomials will be true if polynomials have been requested
  109504. * @param onLoad defines the callback to trigger once the texture is ready
  109505. * @param onError defines the callback to trigger in case of error
  109506. */
  109507. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109508. /**
  109509. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109510. * @param data contains the texture data
  109511. * @param texture defines the BabylonJS internal texture
  109512. * @param callback defines the method to call once ready to upload
  109513. */
  109514. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109515. }
  109516. }
  109517. declare module BABYLON {
  109518. /**
  109519. * 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.
  109520. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109521. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109522. */
  109523. export class CustomProceduralTexture extends ProceduralTexture {
  109524. private _animate;
  109525. private _time;
  109526. private _config;
  109527. private _texturePath;
  109528. /**
  109529. * Instantiates a new Custom Procedural Texture.
  109530. * 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.
  109531. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109532. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109533. * @param name Define the name of the texture
  109534. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109535. * @param size Define the size of the texture to create
  109536. * @param scene Define the scene the texture belongs to
  109537. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109538. * @param generateMipMaps Define if the texture should creates mip maps or not
  109539. */
  109540. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109541. private _loadJson;
  109542. /**
  109543. * Is the texture ready to be used ? (rendered at least once)
  109544. * @returns true if ready, otherwise, false.
  109545. */
  109546. isReady(): boolean;
  109547. /**
  109548. * Render the texture to its associated render target.
  109549. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109550. */
  109551. render(useCameraPostProcess?: boolean): void;
  109552. /**
  109553. * Update the list of dependant textures samplers in the shader.
  109554. */
  109555. updateTextures(): void;
  109556. /**
  109557. * Update the uniform values of the procedural texture in the shader.
  109558. */
  109559. updateShaderUniforms(): void;
  109560. /**
  109561. * Define if the texture animates or not.
  109562. */
  109563. animate: boolean;
  109564. }
  109565. }
  109566. declare module BABYLON {
  109567. /** @hidden */
  109568. export var noisePixelShader: {
  109569. name: string;
  109570. shader: string;
  109571. };
  109572. }
  109573. declare module BABYLON {
  109574. /**
  109575. * Class used to generate noise procedural textures
  109576. */
  109577. export class NoiseProceduralTexture extends ProceduralTexture {
  109578. private _time;
  109579. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109580. brightness: number;
  109581. /** Defines the number of octaves to process */
  109582. octaves: number;
  109583. /** Defines the level of persistence (0.8 by default) */
  109584. persistence: number;
  109585. /** Gets or sets animation speed factor (default is 1) */
  109586. animationSpeedFactor: number;
  109587. /**
  109588. * Creates a new NoiseProceduralTexture
  109589. * @param name defines the name fo the texture
  109590. * @param size defines the size of the texture (default is 256)
  109591. * @param scene defines the hosting scene
  109592. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109593. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109594. */
  109595. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109596. private _updateShaderUniforms;
  109597. protected _getDefines(): string;
  109598. /** Generate the current state of the procedural texture */
  109599. render(useCameraPostProcess?: boolean): void;
  109600. /**
  109601. * Serializes this noise procedural texture
  109602. * @returns a serialized noise procedural texture object
  109603. */
  109604. serialize(): any;
  109605. /**
  109606. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109607. * @param parsedTexture defines parsed texture data
  109608. * @param scene defines the current scene
  109609. * @param rootUrl defines the root URL containing noise procedural texture information
  109610. * @returns a parsed NoiseProceduralTexture
  109611. */
  109612. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109613. }
  109614. }
  109615. declare module BABYLON {
  109616. /**
  109617. * Raw cube texture where the raw buffers are passed in
  109618. */
  109619. export class RawCubeTexture extends CubeTexture {
  109620. /**
  109621. * Creates a cube texture where the raw buffers are passed in.
  109622. * @param scene defines the scene the texture is attached to
  109623. * @param data defines the array of data to use to create each face
  109624. * @param size defines the size of the textures
  109625. * @param format defines the format of the data
  109626. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109627. * @param generateMipMaps defines if the engine should generate the mip levels
  109628. * @param invertY defines if data must be stored with Y axis inverted
  109629. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109630. * @param compression defines the compression used (null by default)
  109631. */
  109632. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109633. /**
  109634. * Updates the raw cube texture.
  109635. * @param data defines the data to store
  109636. * @param format defines the data format
  109637. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109638. * @param invertY defines if data must be stored with Y axis inverted
  109639. * @param compression defines the compression used (null by default)
  109640. * @param level defines which level of the texture to update
  109641. */
  109642. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109643. /**
  109644. * Updates a raw cube texture with RGBD encoded data.
  109645. * @param data defines the array of data [mipmap][face] to use to create each face
  109646. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109649. * @returns a promsie that resolves when the operation is complete
  109650. */
  109651. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109652. /**
  109653. * Clones the raw cube texture.
  109654. * @return a new cube texture
  109655. */
  109656. clone(): CubeTexture;
  109657. /** @hidden */
  109658. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109659. }
  109660. }
  109661. declare module BABYLON {
  109662. /**
  109663. * Class used to store 3D textures containing user data
  109664. */
  109665. export class RawTexture3D extends Texture {
  109666. /** Gets or sets the texture format to use */
  109667. format: number;
  109668. private _engine;
  109669. /**
  109670. * Create a new RawTexture3D
  109671. * @param data defines the data of the texture
  109672. * @param width defines the width of the texture
  109673. * @param height defines the height of the texture
  109674. * @param depth defines the depth of the texture
  109675. * @param format defines the texture format to use
  109676. * @param scene defines the hosting scene
  109677. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109678. * @param invertY defines if texture must be stored with Y axis inverted
  109679. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109680. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109681. */
  109682. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109683. /** Gets or sets the texture format to use */
  109684. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109685. /**
  109686. * Update the texture with new data
  109687. * @param data defines the data to store in the texture
  109688. */
  109689. update(data: ArrayBufferView): void;
  109690. }
  109691. }
  109692. declare module BABYLON {
  109693. /**
  109694. * Creates a refraction texture used by refraction channel of the standard material.
  109695. * It is like a mirror but to see through a material.
  109696. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109697. */
  109698. export class RefractionTexture extends RenderTargetTexture {
  109699. /**
  109700. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109701. * 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.
  109702. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109703. */
  109704. refractionPlane: Plane;
  109705. /**
  109706. * Define how deep under the surface we should see.
  109707. */
  109708. depth: number;
  109709. /**
  109710. * Creates a refraction texture used by refraction channel of the standard material.
  109711. * It is like a mirror but to see through a material.
  109712. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109713. * @param name Define the texture name
  109714. * @param size Define the size of the underlying texture
  109715. * @param scene Define the scene the refraction belongs to
  109716. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109717. */
  109718. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109719. /**
  109720. * Clone the refraction texture.
  109721. * @returns the cloned texture
  109722. */
  109723. clone(): RefractionTexture;
  109724. /**
  109725. * Serialize the texture to a JSON representation you could use in Parse later on
  109726. * @returns the serialized JSON representation
  109727. */
  109728. serialize(): any;
  109729. }
  109730. }
  109731. declare module BABYLON {
  109732. /**
  109733. * Defines the options related to the creation of an HtmlElementTexture
  109734. */
  109735. export interface IHtmlElementTextureOptions {
  109736. /**
  109737. * Defines wether mip maps should be created or not.
  109738. */
  109739. generateMipMaps?: boolean;
  109740. /**
  109741. * Defines the sampling mode of the texture.
  109742. */
  109743. samplingMode?: number;
  109744. /**
  109745. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109746. */
  109747. engine: Nullable<Engine>;
  109748. /**
  109749. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109750. */
  109751. scene: Nullable<Scene>;
  109752. }
  109753. /**
  109754. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109755. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109756. * is automatically managed.
  109757. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109758. * in your application.
  109759. *
  109760. * As the update is not automatic, you need to call them manually.
  109761. */
  109762. export class HtmlElementTexture extends BaseTexture {
  109763. /**
  109764. * The texture URL.
  109765. */
  109766. element: HTMLVideoElement | HTMLCanvasElement;
  109767. private static readonly DefaultOptions;
  109768. private _textureMatrix;
  109769. private _engine;
  109770. private _isVideo;
  109771. private _generateMipMaps;
  109772. private _samplingMode;
  109773. /**
  109774. * Instantiates a HtmlElementTexture from the following parameters.
  109775. *
  109776. * @param name Defines the name of the texture
  109777. * @param element Defines the video or canvas the texture is filled with
  109778. * @param options Defines the other none mandatory texture creation options
  109779. */
  109780. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109781. private _createInternalTexture;
  109782. /**
  109783. * Returns the texture matrix used in most of the material.
  109784. */
  109785. getTextureMatrix(): Matrix;
  109786. /**
  109787. * Updates the content of the texture.
  109788. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109789. */
  109790. update(invertY?: Nullable<boolean>): void;
  109791. }
  109792. }
  109793. declare module BABYLON {
  109794. /**
  109795. * Helper class to push actions to a pool of workers.
  109796. */
  109797. export class WorkerPool implements IDisposable {
  109798. private _workerInfos;
  109799. private _pendingActions;
  109800. /**
  109801. * Constructor
  109802. * @param workers Array of workers to use for actions
  109803. */
  109804. constructor(workers: Array<Worker>);
  109805. /**
  109806. * Terminates all workers and clears any pending actions.
  109807. */
  109808. dispose(): void;
  109809. /**
  109810. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109811. * pended until a worker has completed its action.
  109812. * @param action The action to perform. Call onComplete when the action is complete.
  109813. */
  109814. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109815. private _execute;
  109816. }
  109817. }
  109818. declare module BABYLON {
  109819. /**
  109820. * Configuration for Draco compression
  109821. */
  109822. export interface IDracoCompressionConfiguration {
  109823. /**
  109824. * Configuration for the decoder.
  109825. */
  109826. decoder: {
  109827. /**
  109828. * The url to the WebAssembly module.
  109829. */
  109830. wasmUrl?: string;
  109831. /**
  109832. * The url to the WebAssembly binary.
  109833. */
  109834. wasmBinaryUrl?: string;
  109835. /**
  109836. * The url to the fallback JavaScript module.
  109837. */
  109838. fallbackUrl?: string;
  109839. };
  109840. }
  109841. /**
  109842. * Draco compression (https://google.github.io/draco/)
  109843. *
  109844. * This class wraps the Draco module.
  109845. *
  109846. * **Encoder**
  109847. *
  109848. * The encoder is not currently implemented.
  109849. *
  109850. * **Decoder**
  109851. *
  109852. * 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.
  109853. *
  109854. * To update the configuration, use the following code:
  109855. * ```javascript
  109856. * DracoCompression.Configuration = {
  109857. * decoder: {
  109858. * wasmUrl: "<url to the WebAssembly library>",
  109859. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109860. * fallbackUrl: "<url to the fallback JavaScript library>",
  109861. * }
  109862. * };
  109863. * ```
  109864. *
  109865. * 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.
  109866. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109867. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  109868. *
  109869. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  109870. * ```javascript
  109871. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  109872. * ```
  109873. *
  109874. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109875. */
  109876. export class DracoCompression implements IDisposable {
  109877. private _workerPoolPromise?;
  109878. private _decoderModulePromise?;
  109879. /**
  109880. * The configuration. Defaults to the following urls:
  109881. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109882. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109883. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109884. */
  109885. static Configuration: IDracoCompressionConfiguration;
  109886. /**
  109887. * Returns true if the decoder configuration is available.
  109888. */
  109889. static readonly DecoderAvailable: boolean;
  109890. /**
  109891. * Default number of workers to create when creating the draco compression object.
  109892. */
  109893. static DefaultNumWorkers: number;
  109894. private static GetDefaultNumWorkers;
  109895. private static _Default;
  109896. /**
  109897. * Default instance for the draco compression object.
  109898. */
  109899. static readonly Default: DracoCompression;
  109900. /**
  109901. * Constructor
  109902. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  109903. */
  109904. constructor(numWorkers?: number);
  109905. /**
  109906. * Stop all async operations and release resources.
  109907. */
  109908. dispose(): void;
  109909. /**
  109910. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109911. * @returns a promise that resolves when ready
  109912. */
  109913. whenReadyAsync(): Promise<void>;
  109914. /**
  109915. * Decode Draco compressed mesh data to vertex data.
  109916. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109917. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109918. * @returns A promise that resolves with the decoded vertex data
  109919. */
  109920. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109921. [kind: string]: number;
  109922. }): Promise<VertexData>;
  109923. }
  109924. }
  109925. declare module BABYLON {
  109926. /**
  109927. * Class for building Constructive Solid Geometry
  109928. */
  109929. export class CSG {
  109930. private polygons;
  109931. /**
  109932. * The world matrix
  109933. */
  109934. matrix: Matrix;
  109935. /**
  109936. * Stores the position
  109937. */
  109938. position: Vector3;
  109939. /**
  109940. * Stores the rotation
  109941. */
  109942. rotation: Vector3;
  109943. /**
  109944. * Stores the rotation quaternion
  109945. */
  109946. rotationQuaternion: Nullable<Quaternion>;
  109947. /**
  109948. * Stores the scaling vector
  109949. */
  109950. scaling: Vector3;
  109951. /**
  109952. * Convert the Mesh to CSG
  109953. * @param mesh The Mesh to convert to CSG
  109954. * @returns A new CSG from the Mesh
  109955. */
  109956. static FromMesh(mesh: Mesh): CSG;
  109957. /**
  109958. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109959. * @param polygons Polygons used to construct a CSG solid
  109960. */
  109961. private static FromPolygons;
  109962. /**
  109963. * Clones, or makes a deep copy, of the CSG
  109964. * @returns A new CSG
  109965. */
  109966. clone(): CSG;
  109967. /**
  109968. * Unions this CSG with another CSG
  109969. * @param csg The CSG to union against this CSG
  109970. * @returns The unioned CSG
  109971. */
  109972. union(csg: CSG): CSG;
  109973. /**
  109974. * Unions this CSG with another CSG in place
  109975. * @param csg The CSG to union against this CSG
  109976. */
  109977. unionInPlace(csg: CSG): void;
  109978. /**
  109979. * Subtracts this CSG with another CSG
  109980. * @param csg The CSG to subtract against this CSG
  109981. * @returns A new CSG
  109982. */
  109983. subtract(csg: CSG): CSG;
  109984. /**
  109985. * Subtracts this CSG with another CSG in place
  109986. * @param csg The CSG to subtact against this CSG
  109987. */
  109988. subtractInPlace(csg: CSG): void;
  109989. /**
  109990. * Intersect this CSG with another CSG
  109991. * @param csg The CSG to intersect against this CSG
  109992. * @returns A new CSG
  109993. */
  109994. intersect(csg: CSG): CSG;
  109995. /**
  109996. * Intersects this CSG with another CSG in place
  109997. * @param csg The CSG to intersect against this CSG
  109998. */
  109999. intersectInPlace(csg: CSG): void;
  110000. /**
  110001. * Return a new CSG solid with solid and empty space switched. This solid is
  110002. * not modified.
  110003. * @returns A new CSG solid with solid and empty space switched
  110004. */
  110005. inverse(): CSG;
  110006. /**
  110007. * Inverses the CSG in place
  110008. */
  110009. inverseInPlace(): void;
  110010. /**
  110011. * This is used to keep meshes transformations so they can be restored
  110012. * when we build back a Babylon Mesh
  110013. * NB : All CSG operations are performed in world coordinates
  110014. * @param csg The CSG to copy the transform attributes from
  110015. * @returns This CSG
  110016. */
  110017. copyTransformAttributes(csg: CSG): CSG;
  110018. /**
  110019. * Build Raw mesh from CSG
  110020. * Coordinates here are in world space
  110021. * @param name The name of the mesh geometry
  110022. * @param scene The Scene
  110023. * @param keepSubMeshes Specifies if the submeshes should be kept
  110024. * @returns A new Mesh
  110025. */
  110026. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  110027. /**
  110028. * Build Mesh from CSG taking material and transforms into account
  110029. * @param name The name of the Mesh
  110030. * @param material The material of the Mesh
  110031. * @param scene The Scene
  110032. * @param keepSubMeshes Specifies if submeshes should be kept
  110033. * @returns The new Mesh
  110034. */
  110035. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  110036. }
  110037. }
  110038. declare module BABYLON {
  110039. /**
  110040. * Class used to create a trail following a mesh
  110041. */
  110042. export class TrailMesh extends Mesh {
  110043. private _generator;
  110044. private _autoStart;
  110045. private _running;
  110046. private _diameter;
  110047. private _length;
  110048. private _sectionPolygonPointsCount;
  110049. private _sectionVectors;
  110050. private _sectionNormalVectors;
  110051. private _beforeRenderObserver;
  110052. /**
  110053. * @constructor
  110054. * @param name The value used by scene.getMeshByName() to do a lookup.
  110055. * @param generator The mesh to generate a trail.
  110056. * @param scene The scene to add this mesh to.
  110057. * @param diameter Diameter of trailing mesh. Default is 1.
  110058. * @param length Length of trailing mesh. Default is 60.
  110059. * @param autoStart Automatically start trailing mesh. Default true.
  110060. */
  110061. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  110062. /**
  110063. * "TrailMesh"
  110064. * @returns "TrailMesh"
  110065. */
  110066. getClassName(): string;
  110067. private _createMesh;
  110068. /**
  110069. * Start trailing mesh.
  110070. */
  110071. start(): void;
  110072. /**
  110073. * Stop trailing mesh.
  110074. */
  110075. stop(): void;
  110076. /**
  110077. * Update trailing mesh geometry.
  110078. */
  110079. update(): void;
  110080. /**
  110081. * Returns a new TrailMesh object.
  110082. * @param name is a string, the name given to the new mesh
  110083. * @param newGenerator use new generator object for cloned trail mesh
  110084. * @returns a new mesh
  110085. */
  110086. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  110087. /**
  110088. * Serializes this trail mesh
  110089. * @param serializationObject object to write serialization to
  110090. */
  110091. serialize(serializationObject: any): void;
  110092. /**
  110093. * Parses a serialized trail mesh
  110094. * @param parsedMesh the serialized mesh
  110095. * @param scene the scene to create the trail mesh in
  110096. * @returns the created trail mesh
  110097. */
  110098. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  110099. }
  110100. }
  110101. declare module BABYLON {
  110102. /**
  110103. * Class containing static functions to help procedurally build meshes
  110104. */
  110105. export class TorusKnotBuilder {
  110106. /**
  110107. * Creates a torus knot mesh
  110108. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110109. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110110. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110111. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110115. * @param name defines the name of the mesh
  110116. * @param options defines the options used to create the mesh
  110117. * @param scene defines the hosting scene
  110118. * @returns the torus knot mesh
  110119. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110120. */
  110121. static CreateTorusKnot(name: string, options: {
  110122. radius?: number;
  110123. tube?: number;
  110124. radialSegments?: number;
  110125. tubularSegments?: number;
  110126. p?: number;
  110127. q?: number;
  110128. updatable?: boolean;
  110129. sideOrientation?: number;
  110130. frontUVs?: Vector4;
  110131. backUVs?: Vector4;
  110132. }, scene: any): Mesh;
  110133. }
  110134. }
  110135. declare module BABYLON {
  110136. /**
  110137. * Polygon
  110138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  110139. */
  110140. export class Polygon {
  110141. /**
  110142. * Creates a rectangle
  110143. * @param xmin bottom X coord
  110144. * @param ymin bottom Y coord
  110145. * @param xmax top X coord
  110146. * @param ymax top Y coord
  110147. * @returns points that make the resulting rectation
  110148. */
  110149. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  110150. /**
  110151. * Creates a circle
  110152. * @param radius radius of circle
  110153. * @param cx scale in x
  110154. * @param cy scale in y
  110155. * @param numberOfSides number of sides that make up the circle
  110156. * @returns points that make the resulting circle
  110157. */
  110158. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  110159. /**
  110160. * Creates a polygon from input string
  110161. * @param input Input polygon data
  110162. * @returns the parsed points
  110163. */
  110164. static Parse(input: string): Vector2[];
  110165. /**
  110166. * Starts building a polygon from x and y coordinates
  110167. * @param x x coordinate
  110168. * @param y y coordinate
  110169. * @returns the started path2
  110170. */
  110171. static StartingAt(x: number, y: number): Path2;
  110172. }
  110173. /**
  110174. * Builds a polygon
  110175. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  110176. */
  110177. export class PolygonMeshBuilder {
  110178. private _points;
  110179. private _outlinepoints;
  110180. private _holes;
  110181. private _name;
  110182. private _scene;
  110183. private _epoints;
  110184. private _eholes;
  110185. private _addToepoint;
  110186. /**
  110187. * Babylon reference to the earcut plugin.
  110188. */
  110189. bjsEarcut: any;
  110190. /**
  110191. * Creates a PolygonMeshBuilder
  110192. * @param name name of the builder
  110193. * @param contours Path of the polygon
  110194. * @param scene scene to add to when creating the mesh
  110195. * @param earcutInjection can be used to inject your own earcut reference
  110196. */
  110197. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110198. /**
  110199. * Adds a whole within the polygon
  110200. * @param hole Array of points defining the hole
  110201. * @returns this
  110202. */
  110203. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110204. /**
  110205. * Creates the polygon
  110206. * @param updatable If the mesh should be updatable
  110207. * @param depth The depth of the mesh created
  110208. * @returns the created mesh
  110209. */
  110210. build(updatable?: boolean, depth?: number): Mesh;
  110211. /**
  110212. * Creates the polygon
  110213. * @param depth The depth of the mesh created
  110214. * @returns the created VertexData
  110215. */
  110216. buildVertexData(depth?: number): VertexData;
  110217. /**
  110218. * Adds a side to the polygon
  110219. * @param positions points that make the polygon
  110220. * @param normals normals of the polygon
  110221. * @param uvs uvs of the polygon
  110222. * @param indices indices of the polygon
  110223. * @param bounds bounds of the polygon
  110224. * @param points points of the polygon
  110225. * @param depth depth of the polygon
  110226. * @param flip flip of the polygon
  110227. */
  110228. private addSide;
  110229. }
  110230. }
  110231. declare module BABYLON {
  110232. /**
  110233. * Class containing static functions to help procedurally build meshes
  110234. */
  110235. export class PolygonBuilder {
  110236. /**
  110237. * Creates a polygon mesh
  110238. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110239. * * 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
  110240. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110243. * * Remember you can only change the shape positions, not their number when updating a polygon
  110244. * @param name defines the name of the mesh
  110245. * @param options defines the options used to create the mesh
  110246. * @param scene defines the hosting scene
  110247. * @param earcutInjection can be used to inject your own earcut reference
  110248. * @returns the polygon mesh
  110249. */
  110250. static CreatePolygon(name: string, options: {
  110251. shape: Vector3[];
  110252. holes?: Vector3[][];
  110253. depth?: number;
  110254. faceUV?: Vector4[];
  110255. faceColors?: Color4[];
  110256. updatable?: boolean;
  110257. sideOrientation?: number;
  110258. frontUVs?: Vector4;
  110259. backUVs?: Vector4;
  110260. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110261. /**
  110262. * Creates an extruded polygon mesh, with depth in the Y direction.
  110263. * * 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)
  110264. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110265. * @param name defines the name of the mesh
  110266. * @param options defines the options used to create the mesh
  110267. * @param scene defines the hosting scene
  110268. * @param earcutInjection can be used to inject your own earcut reference
  110269. * @returns the polygon mesh
  110270. */
  110271. static ExtrudePolygon(name: string, options: {
  110272. shape: Vector3[];
  110273. holes?: Vector3[][];
  110274. depth?: number;
  110275. faceUV?: Vector4[];
  110276. faceColors?: Color4[];
  110277. updatable?: boolean;
  110278. sideOrientation?: number;
  110279. frontUVs?: Vector4;
  110280. backUVs?: Vector4;
  110281. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110282. }
  110283. }
  110284. declare module BABYLON {
  110285. /**
  110286. * Class containing static functions to help procedurally build meshes
  110287. */
  110288. export class LatheBuilder {
  110289. /**
  110290. * Creates lathe mesh.
  110291. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110292. * * 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
  110293. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110294. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110295. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110296. * * 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
  110297. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110298. * * 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
  110299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110303. * @param name defines the name of the mesh
  110304. * @param options defines the options used to create the mesh
  110305. * @param scene defines the hosting scene
  110306. * @returns the lathe mesh
  110307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110308. */
  110309. static CreateLathe(name: string, options: {
  110310. shape: Vector3[];
  110311. radius?: number;
  110312. tessellation?: number;
  110313. clip?: number;
  110314. arc?: number;
  110315. closed?: boolean;
  110316. updatable?: boolean;
  110317. sideOrientation?: number;
  110318. frontUVs?: Vector4;
  110319. backUVs?: Vector4;
  110320. cap?: number;
  110321. invertUV?: boolean;
  110322. }, scene?: Nullable<Scene>): Mesh;
  110323. }
  110324. }
  110325. declare module BABYLON {
  110326. /**
  110327. * Class containing static functions to help procedurally build meshes
  110328. */
  110329. export class TubeBuilder {
  110330. /**
  110331. * Creates a tube mesh.
  110332. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110333. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110334. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110335. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110336. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110337. * * 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)
  110338. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110339. * * 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
  110340. * * 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
  110341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110343. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110345. * @param name defines the name of the mesh
  110346. * @param options defines the options used to create the mesh
  110347. * @param scene defines the hosting scene
  110348. * @returns the tube mesh
  110349. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110350. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110351. */
  110352. static CreateTube(name: string, options: {
  110353. path: Vector3[];
  110354. radius?: number;
  110355. tessellation?: number;
  110356. radiusFunction?: {
  110357. (i: number, distance: number): number;
  110358. };
  110359. cap?: number;
  110360. arc?: number;
  110361. updatable?: boolean;
  110362. sideOrientation?: number;
  110363. frontUVs?: Vector4;
  110364. backUVs?: Vector4;
  110365. instance?: Mesh;
  110366. invertUV?: boolean;
  110367. }, scene?: Nullable<Scene>): Mesh;
  110368. }
  110369. }
  110370. declare module BABYLON {
  110371. /**
  110372. * Class containing static functions to help procedurally build meshes
  110373. */
  110374. export class IcoSphereBuilder {
  110375. /**
  110376. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110377. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110378. * * 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`)
  110379. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110380. * * 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
  110381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110384. * @param name defines the name of the mesh
  110385. * @param options defines the options used to create the mesh
  110386. * @param scene defines the hosting scene
  110387. * @returns the icosahedron mesh
  110388. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110389. */
  110390. static CreateIcoSphere(name: string, options: {
  110391. radius?: number;
  110392. radiusX?: number;
  110393. radiusY?: number;
  110394. radiusZ?: number;
  110395. flat?: boolean;
  110396. subdivisions?: number;
  110397. sideOrientation?: number;
  110398. frontUVs?: Vector4;
  110399. backUVs?: Vector4;
  110400. updatable?: boolean;
  110401. }, scene?: Nullable<Scene>): Mesh;
  110402. }
  110403. }
  110404. declare module BABYLON {
  110405. /**
  110406. * Class containing static functions to help procedurally build meshes
  110407. */
  110408. export class DecalBuilder {
  110409. /**
  110410. * Creates a decal mesh.
  110411. * 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
  110412. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110413. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110414. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110415. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110416. * @param name defines the name of the mesh
  110417. * @param sourceMesh defines the mesh where the decal must be applied
  110418. * @param options defines the options used to create the mesh
  110419. * @param scene defines the hosting scene
  110420. * @returns the decal mesh
  110421. * @see https://doc.babylonjs.com/how_to/decals
  110422. */
  110423. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110424. position?: Vector3;
  110425. normal?: Vector3;
  110426. size?: Vector3;
  110427. angle?: number;
  110428. }): Mesh;
  110429. }
  110430. }
  110431. declare module BABYLON {
  110432. /**
  110433. * Class containing static functions to help procedurally build meshes
  110434. */
  110435. export class MeshBuilder {
  110436. /**
  110437. * Creates a box mesh
  110438. * * The parameter `size` sets the size (float) of each box side (default 1)
  110439. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110440. * * 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)
  110441. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110445. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110446. * @param name defines the name of the mesh
  110447. * @param options defines the options used to create the mesh
  110448. * @param scene defines the hosting scene
  110449. * @returns the box mesh
  110450. */
  110451. static CreateBox(name: string, options: {
  110452. size?: number;
  110453. width?: number;
  110454. height?: number;
  110455. depth?: number;
  110456. faceUV?: Vector4[];
  110457. faceColors?: Color4[];
  110458. sideOrientation?: number;
  110459. frontUVs?: Vector4;
  110460. backUVs?: Vector4;
  110461. updatable?: boolean;
  110462. }, scene?: Nullable<Scene>): Mesh;
  110463. /**
  110464. * Creates a sphere mesh
  110465. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110466. * * 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`)
  110467. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110468. * * 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
  110469. * * 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)
  110470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110473. * @param name defines the name of the mesh
  110474. * @param options defines the options used to create the mesh
  110475. * @param scene defines the hosting scene
  110476. * @returns the sphere mesh
  110477. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110478. */
  110479. static CreateSphere(name: string, options: {
  110480. segments?: number;
  110481. diameter?: number;
  110482. diameterX?: number;
  110483. diameterY?: number;
  110484. diameterZ?: number;
  110485. arc?: number;
  110486. slice?: number;
  110487. sideOrientation?: number;
  110488. frontUVs?: Vector4;
  110489. backUVs?: Vector4;
  110490. updatable?: boolean;
  110491. }, scene?: Nullable<Scene>): Mesh;
  110492. /**
  110493. * Creates a plane polygonal mesh. By default, this is a disc
  110494. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110495. * * 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
  110496. * * 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
  110497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110500. * @param name defines the name of the mesh
  110501. * @param options defines the options used to create the mesh
  110502. * @param scene defines the hosting scene
  110503. * @returns the plane polygonal mesh
  110504. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110505. */
  110506. static CreateDisc(name: string, options: {
  110507. radius?: number;
  110508. tessellation?: number;
  110509. arc?: number;
  110510. updatable?: boolean;
  110511. sideOrientation?: number;
  110512. frontUVs?: Vector4;
  110513. backUVs?: Vector4;
  110514. }, scene?: Nullable<Scene>): Mesh;
  110515. /**
  110516. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110517. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110518. * * 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`)
  110519. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110520. * * 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
  110521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110524. * @param name defines the name of the mesh
  110525. * @param options defines the options used to create the mesh
  110526. * @param scene defines the hosting scene
  110527. * @returns the icosahedron mesh
  110528. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110529. */
  110530. static CreateIcoSphere(name: string, options: {
  110531. radius?: number;
  110532. radiusX?: number;
  110533. radiusY?: number;
  110534. radiusZ?: number;
  110535. flat?: boolean;
  110536. subdivisions?: number;
  110537. sideOrientation?: number;
  110538. frontUVs?: Vector4;
  110539. backUVs?: Vector4;
  110540. updatable?: boolean;
  110541. }, scene?: Nullable<Scene>): Mesh;
  110542. /**
  110543. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110544. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110545. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110546. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110547. * * 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
  110548. * * 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
  110549. * * 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
  110550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110552. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110553. * * 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
  110554. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110555. * * 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
  110556. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110558. * @param name defines the name of the mesh
  110559. * @param options defines the options used to create the mesh
  110560. * @param scene defines the hosting scene
  110561. * @returns the ribbon mesh
  110562. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110564. */
  110565. static CreateRibbon(name: string, options: {
  110566. pathArray: Vector3[][];
  110567. closeArray?: boolean;
  110568. closePath?: boolean;
  110569. offset?: number;
  110570. updatable?: boolean;
  110571. sideOrientation?: number;
  110572. frontUVs?: Vector4;
  110573. backUVs?: Vector4;
  110574. instance?: Mesh;
  110575. invertUV?: boolean;
  110576. uvs?: Vector2[];
  110577. colors?: Color4[];
  110578. }, scene?: Nullable<Scene>): Mesh;
  110579. /**
  110580. * Creates a cylinder or a cone mesh
  110581. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110582. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110583. * * 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.
  110584. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110585. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110586. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110587. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110588. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110589. * * 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).
  110590. * * 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
  110591. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110592. * * 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
  110593. * * 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.
  110594. * * If `enclose` is false, a ring surface is one element.
  110595. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110596. * * 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
  110597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110600. * @param name defines the name of the mesh
  110601. * @param options defines the options used to create the mesh
  110602. * @param scene defines the hosting scene
  110603. * @returns the cylinder mesh
  110604. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110605. */
  110606. static CreateCylinder(name: string, options: {
  110607. height?: number;
  110608. diameterTop?: number;
  110609. diameterBottom?: number;
  110610. diameter?: number;
  110611. tessellation?: number;
  110612. subdivisions?: number;
  110613. arc?: number;
  110614. faceColors?: Color4[];
  110615. faceUV?: Vector4[];
  110616. updatable?: boolean;
  110617. hasRings?: boolean;
  110618. enclose?: boolean;
  110619. sideOrientation?: number;
  110620. frontUVs?: Vector4;
  110621. backUVs?: Vector4;
  110622. }, scene?: Nullable<Scene>): Mesh;
  110623. /**
  110624. * Creates a torus mesh
  110625. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110626. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110627. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110631. * @param name defines the name of the mesh
  110632. * @param options defines the options used to create the mesh
  110633. * @param scene defines the hosting scene
  110634. * @returns the torus mesh
  110635. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110636. */
  110637. static CreateTorus(name: string, options: {
  110638. diameter?: number;
  110639. thickness?: number;
  110640. tessellation?: number;
  110641. updatable?: boolean;
  110642. sideOrientation?: number;
  110643. frontUVs?: Vector4;
  110644. backUVs?: Vector4;
  110645. }, scene?: Nullable<Scene>): Mesh;
  110646. /**
  110647. * Creates a torus knot mesh
  110648. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110649. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110650. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110651. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110653. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110655. * @param name defines the name of the mesh
  110656. * @param options defines the options used to create the mesh
  110657. * @param scene defines the hosting scene
  110658. * @returns the torus knot mesh
  110659. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110660. */
  110661. static CreateTorusKnot(name: string, options: {
  110662. radius?: number;
  110663. tube?: number;
  110664. radialSegments?: number;
  110665. tubularSegments?: number;
  110666. p?: number;
  110667. q?: number;
  110668. updatable?: boolean;
  110669. sideOrientation?: number;
  110670. frontUVs?: Vector4;
  110671. backUVs?: Vector4;
  110672. }, scene?: Nullable<Scene>): Mesh;
  110673. /**
  110674. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110675. * * 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
  110676. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110677. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110678. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110679. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110680. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110681. * * 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
  110682. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110685. * @param name defines the name of the new line system
  110686. * @param options defines the options used to create the line system
  110687. * @param scene defines the hosting scene
  110688. * @returns a new line system mesh
  110689. */
  110690. static CreateLineSystem(name: string, options: {
  110691. lines: Vector3[][];
  110692. updatable?: boolean;
  110693. instance?: Nullable<LinesMesh>;
  110694. colors?: Nullable<Color4[][]>;
  110695. useVertexAlpha?: boolean;
  110696. }, scene: Nullable<Scene>): LinesMesh;
  110697. /**
  110698. * Creates a line mesh
  110699. * 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
  110700. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110701. * * The parameter `points` is an array successive Vector3
  110702. * * 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
  110703. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110704. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110705. * * When updating an instance, remember that only point positions can change, not the number of points
  110706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110708. * @param name defines the name of the new line system
  110709. * @param options defines the options used to create the line system
  110710. * @param scene defines the hosting scene
  110711. * @returns a new line mesh
  110712. */
  110713. static CreateLines(name: string, options: {
  110714. points: Vector3[];
  110715. updatable?: boolean;
  110716. instance?: Nullable<LinesMesh>;
  110717. colors?: Color4[];
  110718. useVertexAlpha?: boolean;
  110719. }, scene?: Nullable<Scene>): LinesMesh;
  110720. /**
  110721. * Creates a dashed line mesh
  110722. * * 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
  110723. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110724. * * The parameter `points` is an array successive Vector3
  110725. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110726. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110727. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110728. * * 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
  110729. * * When updating an instance, remember that only point positions can change, not the number of points
  110730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110731. * @param name defines the name of the mesh
  110732. * @param options defines the options used to create the mesh
  110733. * @param scene defines the hosting scene
  110734. * @returns the dashed line mesh
  110735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110736. */
  110737. static CreateDashedLines(name: string, options: {
  110738. points: Vector3[];
  110739. dashSize?: number;
  110740. gapSize?: number;
  110741. dashNb?: number;
  110742. updatable?: boolean;
  110743. instance?: LinesMesh;
  110744. }, scene?: Nullable<Scene>): LinesMesh;
  110745. /**
  110746. * 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.
  110747. * * 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.
  110748. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110749. * * 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.
  110750. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110751. * * 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
  110752. * * 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
  110753. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110756. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110758. * @param name defines the name of the mesh
  110759. * @param options defines the options used to create the mesh
  110760. * @param scene defines the hosting scene
  110761. * @returns the extruded shape mesh
  110762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110764. */
  110765. static ExtrudeShape(name: string, options: {
  110766. shape: Vector3[];
  110767. path: Vector3[];
  110768. scale?: number;
  110769. rotation?: number;
  110770. cap?: number;
  110771. updatable?: boolean;
  110772. sideOrientation?: number;
  110773. frontUVs?: Vector4;
  110774. backUVs?: Vector4;
  110775. instance?: Mesh;
  110776. invertUV?: boolean;
  110777. }, scene?: Nullable<Scene>): Mesh;
  110778. /**
  110779. * Creates an custom extruded shape mesh.
  110780. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110781. * * 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.
  110782. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110783. * * 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
  110784. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110785. * * 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
  110786. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110787. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110788. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110789. * * 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
  110790. * * 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
  110791. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110794. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110796. * @param name defines the name of the mesh
  110797. * @param options defines the options used to create the mesh
  110798. * @param scene defines the hosting scene
  110799. * @returns the custom extruded shape mesh
  110800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110801. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110803. */
  110804. static ExtrudeShapeCustom(name: string, options: {
  110805. shape: Vector3[];
  110806. path: Vector3[];
  110807. scaleFunction?: any;
  110808. rotationFunction?: any;
  110809. ribbonCloseArray?: boolean;
  110810. ribbonClosePath?: boolean;
  110811. cap?: number;
  110812. updatable?: boolean;
  110813. sideOrientation?: number;
  110814. frontUVs?: Vector4;
  110815. backUVs?: Vector4;
  110816. instance?: Mesh;
  110817. invertUV?: boolean;
  110818. }, scene?: Nullable<Scene>): Mesh;
  110819. /**
  110820. * Creates lathe mesh.
  110821. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110822. * * 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
  110823. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110824. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110825. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110826. * * 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
  110827. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110828. * * 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
  110829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110831. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110833. * @param name defines the name of the mesh
  110834. * @param options defines the options used to create the mesh
  110835. * @param scene defines the hosting scene
  110836. * @returns the lathe mesh
  110837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110838. */
  110839. static CreateLathe(name: string, options: {
  110840. shape: Vector3[];
  110841. radius?: number;
  110842. tessellation?: number;
  110843. clip?: number;
  110844. arc?: number;
  110845. closed?: boolean;
  110846. updatable?: boolean;
  110847. sideOrientation?: number;
  110848. frontUVs?: Vector4;
  110849. backUVs?: Vector4;
  110850. cap?: number;
  110851. invertUV?: boolean;
  110852. }, scene?: Nullable<Scene>): Mesh;
  110853. /**
  110854. * Creates a plane mesh
  110855. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110856. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110857. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110861. * @param name defines the name of the mesh
  110862. * @param options defines the options used to create the mesh
  110863. * @param scene defines the hosting scene
  110864. * @returns the plane mesh
  110865. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110866. */
  110867. static CreatePlane(name: string, options: {
  110868. size?: number;
  110869. width?: number;
  110870. height?: number;
  110871. sideOrientation?: number;
  110872. frontUVs?: Vector4;
  110873. backUVs?: Vector4;
  110874. updatable?: boolean;
  110875. sourcePlane?: Plane;
  110876. }, scene?: Nullable<Scene>): Mesh;
  110877. /**
  110878. * Creates a ground mesh
  110879. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110880. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110882. * @param name defines the name of the mesh
  110883. * @param options defines the options used to create the mesh
  110884. * @param scene defines the hosting scene
  110885. * @returns the ground mesh
  110886. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110887. */
  110888. static CreateGround(name: string, options: {
  110889. width?: number;
  110890. height?: number;
  110891. subdivisions?: number;
  110892. subdivisionsX?: number;
  110893. subdivisionsY?: number;
  110894. updatable?: boolean;
  110895. }, scene?: Nullable<Scene>): Mesh;
  110896. /**
  110897. * Creates a tiled ground mesh
  110898. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110899. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110900. * * 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
  110901. * * 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
  110902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110903. * @param name defines the name of the mesh
  110904. * @param options defines the options used to create the mesh
  110905. * @param scene defines the hosting scene
  110906. * @returns the tiled ground mesh
  110907. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110908. */
  110909. static CreateTiledGround(name: string, options: {
  110910. xmin: number;
  110911. zmin: number;
  110912. xmax: number;
  110913. zmax: number;
  110914. subdivisions?: {
  110915. w: number;
  110916. h: number;
  110917. };
  110918. precision?: {
  110919. w: number;
  110920. h: number;
  110921. };
  110922. updatable?: boolean;
  110923. }, scene?: Nullable<Scene>): Mesh;
  110924. /**
  110925. * Creates a ground mesh from a height map
  110926. * * The parameter `url` sets the URL of the height map image resource.
  110927. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110928. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110929. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110930. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110931. * * 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.
  110932. * * 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).
  110933. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110935. * @param name defines the name of the mesh
  110936. * @param url defines the url to the height map
  110937. * @param options defines the options used to create the mesh
  110938. * @param scene defines the hosting scene
  110939. * @returns the ground mesh
  110940. * @see https://doc.babylonjs.com/babylon101/height_map
  110941. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110942. */
  110943. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110944. width?: number;
  110945. height?: number;
  110946. subdivisions?: number;
  110947. minHeight?: number;
  110948. maxHeight?: number;
  110949. colorFilter?: Color3;
  110950. alphaFilter?: number;
  110951. updatable?: boolean;
  110952. onReady?: (mesh: GroundMesh) => void;
  110953. }, scene?: Nullable<Scene>): GroundMesh;
  110954. /**
  110955. * Creates a polygon mesh
  110956. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110957. * * 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
  110958. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110961. * * Remember you can only change the shape positions, not their number when updating a polygon
  110962. * @param name defines the name of the mesh
  110963. * @param options defines the options used to create the mesh
  110964. * @param scene defines the hosting scene
  110965. * @param earcutInjection can be used to inject your own earcut reference
  110966. * @returns the polygon mesh
  110967. */
  110968. static CreatePolygon(name: string, options: {
  110969. shape: Vector3[];
  110970. holes?: Vector3[][];
  110971. depth?: number;
  110972. faceUV?: Vector4[];
  110973. faceColors?: Color4[];
  110974. updatable?: boolean;
  110975. sideOrientation?: number;
  110976. frontUVs?: Vector4;
  110977. backUVs?: Vector4;
  110978. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110979. /**
  110980. * Creates an extruded polygon mesh, with depth in the Y direction.
  110981. * * 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)
  110982. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110983. * @param name defines the name of the mesh
  110984. * @param options defines the options used to create the mesh
  110985. * @param scene defines the hosting scene
  110986. * @param earcutInjection can be used to inject your own earcut reference
  110987. * @returns the polygon mesh
  110988. */
  110989. static ExtrudePolygon(name: string, options: {
  110990. shape: Vector3[];
  110991. holes?: Vector3[][];
  110992. depth?: number;
  110993. faceUV?: Vector4[];
  110994. faceColors?: Color4[];
  110995. updatable?: boolean;
  110996. sideOrientation?: number;
  110997. frontUVs?: Vector4;
  110998. backUVs?: Vector4;
  110999. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  111000. /**
  111001. * Creates a tube mesh.
  111002. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111003. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  111004. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  111005. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  111006. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  111007. * * 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)
  111008. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  111009. * * 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
  111010. * * 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
  111011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111015. * @param name defines the name of the mesh
  111016. * @param options defines the options used to create the mesh
  111017. * @param scene defines the hosting scene
  111018. * @returns the tube mesh
  111019. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111020. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  111021. */
  111022. static CreateTube(name: string, options: {
  111023. path: Vector3[];
  111024. radius?: number;
  111025. tessellation?: number;
  111026. radiusFunction?: {
  111027. (i: number, distance: number): number;
  111028. };
  111029. cap?: number;
  111030. arc?: number;
  111031. updatable?: boolean;
  111032. sideOrientation?: number;
  111033. frontUVs?: Vector4;
  111034. backUVs?: Vector4;
  111035. instance?: Mesh;
  111036. invertUV?: boolean;
  111037. }, scene?: Nullable<Scene>): Mesh;
  111038. /**
  111039. * Creates a polyhedron mesh
  111040. * * 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
  111041. * * The parameter `size` (positive float, default 1) sets the polygon size
  111042. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111043. * * 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`
  111044. * * 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
  111045. * * 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)`)
  111046. * * 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
  111047. * * 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
  111048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111051. * @param name defines the name of the mesh
  111052. * @param options defines the options used to create the mesh
  111053. * @param scene defines the hosting scene
  111054. * @returns the polyhedron mesh
  111055. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111056. */
  111057. static CreatePolyhedron(name: string, options: {
  111058. type?: number;
  111059. size?: number;
  111060. sizeX?: number;
  111061. sizeY?: number;
  111062. sizeZ?: number;
  111063. custom?: any;
  111064. faceUV?: Vector4[];
  111065. faceColors?: Color4[];
  111066. flat?: boolean;
  111067. updatable?: boolean;
  111068. sideOrientation?: number;
  111069. frontUVs?: Vector4;
  111070. backUVs?: Vector4;
  111071. }, scene?: Nullable<Scene>): Mesh;
  111072. /**
  111073. * Creates a decal mesh.
  111074. * 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
  111075. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  111076. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  111077. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  111078. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  111079. * @param name defines the name of the mesh
  111080. * @param sourceMesh defines the mesh where the decal must be applied
  111081. * @param options defines the options used to create the mesh
  111082. * @param scene defines the hosting scene
  111083. * @returns the decal mesh
  111084. * @see https://doc.babylonjs.com/how_to/decals
  111085. */
  111086. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  111087. position?: Vector3;
  111088. normal?: Vector3;
  111089. size?: Vector3;
  111090. angle?: number;
  111091. }): Mesh;
  111092. }
  111093. }
  111094. declare module BABYLON {
  111095. /**
  111096. * A simplifier interface for future simplification implementations
  111097. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111098. */
  111099. export interface ISimplifier {
  111100. /**
  111101. * Simplification of a given mesh according to the given settings.
  111102. * Since this requires computation, it is assumed that the function runs async.
  111103. * @param settings The settings of the simplification, including quality and distance
  111104. * @param successCallback A callback that will be called after the mesh was simplified.
  111105. * @param errorCallback in case of an error, this callback will be called. optional.
  111106. */
  111107. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  111108. }
  111109. /**
  111110. * Expected simplification settings.
  111111. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  111112. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111113. */
  111114. export interface ISimplificationSettings {
  111115. /**
  111116. * Gets or sets the expected quality
  111117. */
  111118. quality: number;
  111119. /**
  111120. * Gets or sets the distance when this optimized version should be used
  111121. */
  111122. distance: number;
  111123. /**
  111124. * Gets an already optimized mesh
  111125. */
  111126. optimizeMesh?: boolean;
  111127. }
  111128. /**
  111129. * Class used to specify simplification options
  111130. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111131. */
  111132. export class SimplificationSettings implements ISimplificationSettings {
  111133. /** expected quality */
  111134. quality: number;
  111135. /** distance when this optimized version should be used */
  111136. distance: number;
  111137. /** already optimized mesh */
  111138. optimizeMesh?: boolean | undefined;
  111139. /**
  111140. * Creates a SimplificationSettings
  111141. * @param quality expected quality
  111142. * @param distance distance when this optimized version should be used
  111143. * @param optimizeMesh already optimized mesh
  111144. */
  111145. constructor(
  111146. /** expected quality */
  111147. quality: number,
  111148. /** distance when this optimized version should be used */
  111149. distance: number,
  111150. /** already optimized mesh */
  111151. optimizeMesh?: boolean | undefined);
  111152. }
  111153. /**
  111154. * Interface used to define a simplification task
  111155. */
  111156. export interface ISimplificationTask {
  111157. /**
  111158. * Array of settings
  111159. */
  111160. settings: Array<ISimplificationSettings>;
  111161. /**
  111162. * Simplification type
  111163. */
  111164. simplificationType: SimplificationType;
  111165. /**
  111166. * Mesh to simplify
  111167. */
  111168. mesh: Mesh;
  111169. /**
  111170. * Callback called on success
  111171. */
  111172. successCallback?: () => void;
  111173. /**
  111174. * Defines if parallel processing can be used
  111175. */
  111176. parallelProcessing: boolean;
  111177. }
  111178. /**
  111179. * Queue used to order the simplification tasks
  111180. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111181. */
  111182. export class SimplificationQueue {
  111183. private _simplificationArray;
  111184. /**
  111185. * Gets a boolean indicating that the process is still running
  111186. */
  111187. running: boolean;
  111188. /**
  111189. * Creates a new queue
  111190. */
  111191. constructor();
  111192. /**
  111193. * Adds a new simplification task
  111194. * @param task defines a task to add
  111195. */
  111196. addTask(task: ISimplificationTask): void;
  111197. /**
  111198. * Execute next task
  111199. */
  111200. executeNext(): void;
  111201. /**
  111202. * Execute a simplification task
  111203. * @param task defines the task to run
  111204. */
  111205. runSimplification(task: ISimplificationTask): void;
  111206. private getSimplifier;
  111207. }
  111208. /**
  111209. * The implemented types of simplification
  111210. * At the moment only Quadratic Error Decimation is implemented
  111211. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111212. */
  111213. export enum SimplificationType {
  111214. /** Quadratic error decimation */
  111215. QUADRATIC = 0
  111216. }
  111217. }
  111218. declare module BABYLON {
  111219. interface Scene {
  111220. /** @hidden (Backing field) */
  111221. _simplificationQueue: SimplificationQueue;
  111222. /**
  111223. * Gets or sets the simplification queue attached to the scene
  111224. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111225. */
  111226. simplificationQueue: SimplificationQueue;
  111227. }
  111228. interface Mesh {
  111229. /**
  111230. * Simplify the mesh according to the given array of settings.
  111231. * Function will return immediately and will simplify async
  111232. * @param settings a collection of simplification settings
  111233. * @param parallelProcessing should all levels calculate parallel or one after the other
  111234. * @param simplificationType the type of simplification to run
  111235. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111236. * @returns the current mesh
  111237. */
  111238. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111239. }
  111240. /**
  111241. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111242. * created in a scene
  111243. */
  111244. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111245. /**
  111246. * The component name helpfull to identify the component in the list of scene components.
  111247. */
  111248. readonly name: string;
  111249. /**
  111250. * The scene the component belongs to.
  111251. */
  111252. scene: Scene;
  111253. /**
  111254. * Creates a new instance of the component for the given scene
  111255. * @param scene Defines the scene to register the component in
  111256. */
  111257. constructor(scene: Scene);
  111258. /**
  111259. * Registers the component in a given scene
  111260. */
  111261. register(): void;
  111262. /**
  111263. * Rebuilds the elements related to this component in case of
  111264. * context lost for instance.
  111265. */
  111266. rebuild(): void;
  111267. /**
  111268. * Disposes the component and the associated ressources
  111269. */
  111270. dispose(): void;
  111271. private _beforeCameraUpdate;
  111272. }
  111273. }
  111274. declare module BABYLON {
  111275. /**
  111276. * Class used to enable access to IndexedDB
  111277. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111278. */
  111279. export class Database implements IOfflineProvider {
  111280. private _callbackManifestChecked;
  111281. private _currentSceneUrl;
  111282. private _db;
  111283. private _enableSceneOffline;
  111284. private _enableTexturesOffline;
  111285. private _manifestVersionFound;
  111286. private _mustUpdateRessources;
  111287. private _hasReachedQuota;
  111288. private _isSupported;
  111289. private _idbFactory;
  111290. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111291. private static IsUASupportingBlobStorage;
  111292. /**
  111293. * Gets a boolean indicating if Database storate is enabled (off by default)
  111294. */
  111295. static IDBStorageEnabled: boolean;
  111296. /**
  111297. * Gets a boolean indicating if scene must be saved in the database
  111298. */
  111299. readonly enableSceneOffline: boolean;
  111300. /**
  111301. * Gets a boolean indicating if textures must be saved in the database
  111302. */
  111303. readonly enableTexturesOffline: boolean;
  111304. /**
  111305. * Creates a new Database
  111306. * @param urlToScene defines the url to load the scene
  111307. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111308. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111309. */
  111310. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111311. private static _ParseURL;
  111312. private static _ReturnFullUrlLocation;
  111313. private _checkManifestFile;
  111314. /**
  111315. * Open the database and make it available
  111316. * @param successCallback defines the callback to call on success
  111317. * @param errorCallback defines the callback to call on error
  111318. */
  111319. open(successCallback: () => void, errorCallback: () => void): void;
  111320. /**
  111321. * Loads an image from the database
  111322. * @param url defines the url to load from
  111323. * @param image defines the target DOM image
  111324. */
  111325. loadImage(url: string, image: HTMLImageElement): void;
  111326. private _loadImageFromDBAsync;
  111327. private _saveImageIntoDBAsync;
  111328. private _checkVersionFromDB;
  111329. private _loadVersionFromDBAsync;
  111330. private _saveVersionIntoDBAsync;
  111331. /**
  111332. * Loads a file from database
  111333. * @param url defines the URL to load from
  111334. * @param sceneLoaded defines a callback to call on success
  111335. * @param progressCallBack defines a callback to call when progress changed
  111336. * @param errorCallback defines a callback to call on error
  111337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111338. */
  111339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111340. private _loadFileAsync;
  111341. private _saveFileAsync;
  111342. /**
  111343. * Validates if xhr data is correct
  111344. * @param xhr defines the request to validate
  111345. * @param dataType defines the expected data type
  111346. * @returns true if data is correct
  111347. */
  111348. private static _ValidateXHRData;
  111349. }
  111350. }
  111351. declare module BABYLON {
  111352. /** @hidden */
  111353. export var gpuUpdateParticlesPixelShader: {
  111354. name: string;
  111355. shader: string;
  111356. };
  111357. }
  111358. declare module BABYLON {
  111359. /** @hidden */
  111360. export var gpuUpdateParticlesVertexShader: {
  111361. name: string;
  111362. shader: string;
  111363. };
  111364. }
  111365. declare module BABYLON {
  111366. /** @hidden */
  111367. export var clipPlaneFragmentDeclaration2: {
  111368. name: string;
  111369. shader: string;
  111370. };
  111371. }
  111372. declare module BABYLON {
  111373. /** @hidden */
  111374. export var gpuRenderParticlesPixelShader: {
  111375. name: string;
  111376. shader: string;
  111377. };
  111378. }
  111379. declare module BABYLON {
  111380. /** @hidden */
  111381. export var clipPlaneVertexDeclaration2: {
  111382. name: string;
  111383. shader: string;
  111384. };
  111385. }
  111386. declare module BABYLON {
  111387. /** @hidden */
  111388. export var gpuRenderParticlesVertexShader: {
  111389. name: string;
  111390. shader: string;
  111391. };
  111392. }
  111393. declare module BABYLON {
  111394. /**
  111395. * This represents a GPU particle system in Babylon
  111396. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111397. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111398. */
  111399. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111400. /**
  111401. * The layer mask we are rendering the particles through.
  111402. */
  111403. layerMask: number;
  111404. private _capacity;
  111405. private _activeCount;
  111406. private _currentActiveCount;
  111407. private _accumulatedCount;
  111408. private _renderEffect;
  111409. private _updateEffect;
  111410. private _buffer0;
  111411. private _buffer1;
  111412. private _spriteBuffer;
  111413. private _updateVAO;
  111414. private _renderVAO;
  111415. private _targetIndex;
  111416. private _sourceBuffer;
  111417. private _targetBuffer;
  111418. private _engine;
  111419. private _currentRenderId;
  111420. private _started;
  111421. private _stopped;
  111422. private _timeDelta;
  111423. private _randomTexture;
  111424. private _randomTexture2;
  111425. private _attributesStrideSize;
  111426. private _updateEffectOptions;
  111427. private _randomTextureSize;
  111428. private _actualFrame;
  111429. private readonly _rawTextureWidth;
  111430. /**
  111431. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111432. */
  111433. static readonly IsSupported: boolean;
  111434. /**
  111435. * An event triggered when the system is disposed.
  111436. */
  111437. onDisposeObservable: Observable<GPUParticleSystem>;
  111438. /**
  111439. * Gets the maximum number of particles active at the same time.
  111440. * @returns The max number of active particles.
  111441. */
  111442. getCapacity(): number;
  111443. /**
  111444. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111445. * to override the particles.
  111446. */
  111447. forceDepthWrite: boolean;
  111448. /**
  111449. * Gets or set the number of active particles
  111450. */
  111451. activeParticleCount: number;
  111452. private _preWarmDone;
  111453. /**
  111454. * Is this system ready to be used/rendered
  111455. * @return true if the system is ready
  111456. */
  111457. isReady(): boolean;
  111458. /**
  111459. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111460. * @returns True if it has been started, otherwise false.
  111461. */
  111462. isStarted(): boolean;
  111463. /**
  111464. * Starts the particle system and begins to emit
  111465. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111466. */
  111467. start(delay?: number): void;
  111468. /**
  111469. * Stops the particle system.
  111470. */
  111471. stop(): void;
  111472. /**
  111473. * Remove all active particles
  111474. */
  111475. reset(): void;
  111476. /**
  111477. * Returns the string "GPUParticleSystem"
  111478. * @returns a string containing the class name
  111479. */
  111480. getClassName(): string;
  111481. private _colorGradientsTexture;
  111482. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111483. /**
  111484. * Adds a new color gradient
  111485. * @param gradient defines the gradient to use (between 0 and 1)
  111486. * @param color1 defines the color to affect to the specified gradient
  111487. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111488. * @returns the current particle system
  111489. */
  111490. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111491. /**
  111492. * Remove a specific color gradient
  111493. * @param gradient defines the gradient to remove
  111494. * @returns the current particle system
  111495. */
  111496. removeColorGradient(gradient: number): GPUParticleSystem;
  111497. private _angularSpeedGradientsTexture;
  111498. private _sizeGradientsTexture;
  111499. private _velocityGradientsTexture;
  111500. private _limitVelocityGradientsTexture;
  111501. private _dragGradientsTexture;
  111502. private _addFactorGradient;
  111503. /**
  111504. * Adds a new size gradient
  111505. * @param gradient defines the gradient to use (between 0 and 1)
  111506. * @param factor defines the size factor to affect to the specified gradient
  111507. * @returns the current particle system
  111508. */
  111509. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111510. /**
  111511. * Remove a specific size gradient
  111512. * @param gradient defines the gradient to remove
  111513. * @returns the current particle system
  111514. */
  111515. removeSizeGradient(gradient: number): GPUParticleSystem;
  111516. /**
  111517. * Adds a new angular speed gradient
  111518. * @param gradient defines the gradient to use (between 0 and 1)
  111519. * @param factor defines the angular speed to affect to the specified gradient
  111520. * @returns the current particle system
  111521. */
  111522. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111523. /**
  111524. * Remove a specific angular speed gradient
  111525. * @param gradient defines the gradient to remove
  111526. * @returns the current particle system
  111527. */
  111528. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111529. /**
  111530. * Adds a new velocity gradient
  111531. * @param gradient defines the gradient to use (between 0 and 1)
  111532. * @param factor defines the velocity to affect to the specified gradient
  111533. * @returns the current particle system
  111534. */
  111535. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111536. /**
  111537. * Remove a specific velocity gradient
  111538. * @param gradient defines the gradient to remove
  111539. * @returns the current particle system
  111540. */
  111541. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111542. /**
  111543. * Adds a new limit velocity gradient
  111544. * @param gradient defines the gradient to use (between 0 and 1)
  111545. * @param factor defines the limit velocity value to affect to the specified gradient
  111546. * @returns the current particle system
  111547. */
  111548. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111549. /**
  111550. * Remove a specific limit velocity gradient
  111551. * @param gradient defines the gradient to remove
  111552. * @returns the current particle system
  111553. */
  111554. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111555. /**
  111556. * Adds a new drag gradient
  111557. * @param gradient defines the gradient to use (between 0 and 1)
  111558. * @param factor defines the drag value to affect to the specified gradient
  111559. * @returns the current particle system
  111560. */
  111561. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111562. /**
  111563. * Remove a specific drag gradient
  111564. * @param gradient defines the gradient to remove
  111565. * @returns the current particle system
  111566. */
  111567. removeDragGradient(gradient: number): GPUParticleSystem;
  111568. /**
  111569. * Not supported by GPUParticleSystem
  111570. * @param gradient defines the gradient to use (between 0 and 1)
  111571. * @param factor defines the emit rate value to affect to the specified gradient
  111572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111573. * @returns the current particle system
  111574. */
  111575. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111576. /**
  111577. * Not supported by GPUParticleSystem
  111578. * @param gradient defines the gradient to remove
  111579. * @returns the current particle system
  111580. */
  111581. removeEmitRateGradient(gradient: number): IParticleSystem;
  111582. /**
  111583. * Not supported by GPUParticleSystem
  111584. * @param gradient defines the gradient to use (between 0 and 1)
  111585. * @param factor defines the start size value to affect to the specified gradient
  111586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111587. * @returns the current particle system
  111588. */
  111589. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111590. /**
  111591. * Not supported by GPUParticleSystem
  111592. * @param gradient defines the gradient to remove
  111593. * @returns the current particle system
  111594. */
  111595. removeStartSizeGradient(gradient: number): IParticleSystem;
  111596. /**
  111597. * Not supported by GPUParticleSystem
  111598. * @param gradient defines the gradient to use (between 0 and 1)
  111599. * @param min defines the color remap minimal range
  111600. * @param max defines the color remap maximal range
  111601. * @returns the current particle system
  111602. */
  111603. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111604. /**
  111605. * Not supported by GPUParticleSystem
  111606. * @param gradient defines the gradient to remove
  111607. * @returns the current particle system
  111608. */
  111609. removeColorRemapGradient(): IParticleSystem;
  111610. /**
  111611. * Not supported by GPUParticleSystem
  111612. * @param gradient defines the gradient to use (between 0 and 1)
  111613. * @param min defines the alpha remap minimal range
  111614. * @param max defines the alpha remap maximal range
  111615. * @returns the current particle system
  111616. */
  111617. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111618. /**
  111619. * Not supported by GPUParticleSystem
  111620. * @param gradient defines the gradient to remove
  111621. * @returns the current particle system
  111622. */
  111623. removeAlphaRemapGradient(): IParticleSystem;
  111624. /**
  111625. * Not supported by GPUParticleSystem
  111626. * @param gradient defines the gradient to use (between 0 and 1)
  111627. * @param color defines the color to affect to the specified gradient
  111628. * @returns the current particle system
  111629. */
  111630. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111631. /**
  111632. * Not supported by GPUParticleSystem
  111633. * @param gradient defines the gradient to remove
  111634. * @returns the current particle system
  111635. */
  111636. removeRampGradient(): IParticleSystem;
  111637. /**
  111638. * Not supported by GPUParticleSystem
  111639. * @returns the list of ramp gradients
  111640. */
  111641. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111642. /**
  111643. * Not supported by GPUParticleSystem
  111644. * Gets or sets a boolean indicating that ramp gradients must be used
  111645. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111646. */
  111647. useRampGradients: boolean;
  111648. /**
  111649. * Not supported by GPUParticleSystem
  111650. * @param gradient defines the gradient to use (between 0 and 1)
  111651. * @param factor defines the life time factor to affect to the specified gradient
  111652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111653. * @returns the current particle system
  111654. */
  111655. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111656. /**
  111657. * Not supported by GPUParticleSystem
  111658. * @param gradient defines the gradient to remove
  111659. * @returns the current particle system
  111660. */
  111661. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111662. /**
  111663. * Instantiates a GPU particle system.
  111664. * 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.
  111665. * @param name The name of the particle system
  111666. * @param options The options used to create the system
  111667. * @param scene The scene the particle system belongs to
  111668. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111669. */
  111670. constructor(name: string, options: Partial<{
  111671. capacity: number;
  111672. randomTextureSize: number;
  111673. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111674. protected _reset(): void;
  111675. private _createUpdateVAO;
  111676. private _createRenderVAO;
  111677. private _initialize;
  111678. /** @hidden */
  111679. _recreateUpdateEffect(): void;
  111680. /** @hidden */
  111681. _recreateRenderEffect(): void;
  111682. /**
  111683. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111684. * @param preWarm defines if we are in the pre-warmimg phase
  111685. */
  111686. animate(preWarm?: boolean): void;
  111687. private _createFactorGradientTexture;
  111688. private _createSizeGradientTexture;
  111689. private _createAngularSpeedGradientTexture;
  111690. private _createVelocityGradientTexture;
  111691. private _createLimitVelocityGradientTexture;
  111692. private _createDragGradientTexture;
  111693. private _createColorGradientTexture;
  111694. /**
  111695. * Renders the particle system in its current state
  111696. * @param preWarm defines if the system should only update the particles but not render them
  111697. * @returns the current number of particles
  111698. */
  111699. render(preWarm?: boolean): number;
  111700. /**
  111701. * Rebuilds the particle system
  111702. */
  111703. rebuild(): void;
  111704. private _releaseBuffers;
  111705. private _releaseVAOs;
  111706. /**
  111707. * Disposes the particle system and free the associated resources
  111708. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111709. */
  111710. dispose(disposeTexture?: boolean): void;
  111711. /**
  111712. * Clones the particle system.
  111713. * @param name The name of the cloned object
  111714. * @param newEmitter The new emitter to use
  111715. * @returns the cloned particle system
  111716. */
  111717. clone(name: string, newEmitter: any): GPUParticleSystem;
  111718. /**
  111719. * Serializes the particle system to a JSON object.
  111720. * @returns the JSON object
  111721. */
  111722. serialize(): any;
  111723. /**
  111724. * Parses a JSON object to create a GPU particle system.
  111725. * @param parsedParticleSystem The JSON object to parse
  111726. * @param scene The scene to create the particle system in
  111727. * @param rootUrl The root url to use to load external dependencies like texture
  111728. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111729. * @returns the parsed GPU particle system
  111730. */
  111731. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111732. }
  111733. }
  111734. declare module BABYLON {
  111735. /**
  111736. * Represents a set of particle systems working together to create a specific effect
  111737. */
  111738. export class ParticleSystemSet implements IDisposable {
  111739. private _emitterCreationOptions;
  111740. private _emitterNode;
  111741. /**
  111742. * Gets the particle system list
  111743. */
  111744. systems: IParticleSystem[];
  111745. /**
  111746. * Gets the emitter node used with this set
  111747. */
  111748. readonly emitterNode: Nullable<TransformNode>;
  111749. /**
  111750. * Creates a new emitter mesh as a sphere
  111751. * @param options defines the options used to create the sphere
  111752. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111753. * @param scene defines the hosting scene
  111754. */
  111755. setEmitterAsSphere(options: {
  111756. diameter: number;
  111757. segments: number;
  111758. color: Color3;
  111759. }, renderingGroupId: number, scene: Scene): void;
  111760. /**
  111761. * Starts all particle systems of the set
  111762. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111763. */
  111764. start(emitter?: AbstractMesh): void;
  111765. /**
  111766. * Release all associated resources
  111767. */
  111768. dispose(): void;
  111769. /**
  111770. * Serialize the set into a JSON compatible object
  111771. * @returns a JSON compatible representation of the set
  111772. */
  111773. serialize(): any;
  111774. /**
  111775. * Parse a new ParticleSystemSet from a serialized source
  111776. * @param data defines a JSON compatible representation of the set
  111777. * @param scene defines the hosting scene
  111778. * @param gpu defines if we want GPU particles or CPU particles
  111779. * @returns a new ParticleSystemSet
  111780. */
  111781. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111782. }
  111783. }
  111784. declare module BABYLON {
  111785. /**
  111786. * This class is made for on one-liner static method to help creating particle system set.
  111787. */
  111788. export class ParticleHelper {
  111789. /**
  111790. * Gets or sets base Assets URL
  111791. */
  111792. static BaseAssetsUrl: string;
  111793. /**
  111794. * Create a default particle system that you can tweak
  111795. * @param emitter defines the emitter to use
  111796. * @param capacity defines the system capacity (default is 500 particles)
  111797. * @param scene defines the hosting scene
  111798. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111799. * @returns the new Particle system
  111800. */
  111801. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111802. /**
  111803. * This is the main static method (one-liner) of this helper to create different particle systems
  111804. * @param type This string represents the type to the particle system to create
  111805. * @param scene The scene where the particle system should live
  111806. * @param gpu If the system will use gpu
  111807. * @returns the ParticleSystemSet created
  111808. */
  111809. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111810. /**
  111811. * Static function used to export a particle system to a ParticleSystemSet variable.
  111812. * Please note that the emitter shape is not exported
  111813. * @param systems defines the particle systems to export
  111814. * @returns the created particle system set
  111815. */
  111816. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111817. }
  111818. }
  111819. declare module BABYLON {
  111820. interface Engine {
  111821. /**
  111822. * Create an effect to use with particle systems.
  111823. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111824. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111825. * @param uniformsNames defines a list of attribute names
  111826. * @param samplers defines an array of string used to represent textures
  111827. * @param defines defines the string containing the defines to use to compile the shaders
  111828. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111829. * @param onCompiled defines a function to call when the effect creation is successful
  111830. * @param onError defines a function to call when the effect creation has failed
  111831. * @returns the new Effect
  111832. */
  111833. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111834. }
  111835. interface Mesh {
  111836. /**
  111837. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111838. * @returns an array of IParticleSystem
  111839. */
  111840. getEmittedParticleSystems(): IParticleSystem[];
  111841. /**
  111842. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111843. * @returns an array of IParticleSystem
  111844. */
  111845. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111846. }
  111847. /**
  111848. * @hidden
  111849. */
  111850. export var _IDoNeedToBeInTheBuild: number;
  111851. }
  111852. declare module BABYLON {
  111853. interface Scene {
  111854. /** @hidden (Backing field) */
  111855. _physicsEngine: Nullable<IPhysicsEngine>;
  111856. /**
  111857. * Gets the current physics engine
  111858. * @returns a IPhysicsEngine or null if none attached
  111859. */
  111860. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111861. /**
  111862. * Enables physics to the current scene
  111863. * @param gravity defines the scene's gravity for the physics engine
  111864. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111865. * @return a boolean indicating if the physics engine was initialized
  111866. */
  111867. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111868. /**
  111869. * Disables and disposes the physics engine associated with the scene
  111870. */
  111871. disablePhysicsEngine(): void;
  111872. /**
  111873. * Gets a boolean indicating if there is an active physics engine
  111874. * @returns a boolean indicating if there is an active physics engine
  111875. */
  111876. isPhysicsEnabled(): boolean;
  111877. /**
  111878. * Deletes a physics compound impostor
  111879. * @param compound defines the compound to delete
  111880. */
  111881. deleteCompoundImpostor(compound: any): void;
  111882. /**
  111883. * An event triggered when physic simulation is about to be run
  111884. */
  111885. onBeforePhysicsObservable: Observable<Scene>;
  111886. /**
  111887. * An event triggered when physic simulation has been done
  111888. */
  111889. onAfterPhysicsObservable: Observable<Scene>;
  111890. }
  111891. interface AbstractMesh {
  111892. /** @hidden */
  111893. _physicsImpostor: Nullable<PhysicsImpostor>;
  111894. /**
  111895. * Gets or sets impostor used for physic simulation
  111896. * @see http://doc.babylonjs.com/features/physics_engine
  111897. */
  111898. physicsImpostor: Nullable<PhysicsImpostor>;
  111899. /**
  111900. * Gets the current physics impostor
  111901. * @see http://doc.babylonjs.com/features/physics_engine
  111902. * @returns a physics impostor or null
  111903. */
  111904. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111905. /** Apply a physic impulse to the mesh
  111906. * @param force defines the force to apply
  111907. * @param contactPoint defines where to apply the force
  111908. * @returns the current mesh
  111909. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111910. */
  111911. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111912. /**
  111913. * Creates a physic joint between two meshes
  111914. * @param otherMesh defines the other mesh to use
  111915. * @param pivot1 defines the pivot to use on this mesh
  111916. * @param pivot2 defines the pivot to use on the other mesh
  111917. * @param options defines additional options (can be plugin dependent)
  111918. * @returns the current mesh
  111919. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111920. */
  111921. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111922. /** @hidden */
  111923. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111924. }
  111925. /**
  111926. * Defines the physics engine scene component responsible to manage a physics engine
  111927. */
  111928. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111929. /**
  111930. * The component name helpful to identify the component in the list of scene components.
  111931. */
  111932. readonly name: string;
  111933. /**
  111934. * The scene the component belongs to.
  111935. */
  111936. scene: Scene;
  111937. /**
  111938. * Creates a new instance of the component for the given scene
  111939. * @param scene Defines the scene to register the component in
  111940. */
  111941. constructor(scene: Scene);
  111942. /**
  111943. * Registers the component in a given scene
  111944. */
  111945. register(): void;
  111946. /**
  111947. * Rebuilds the elements related to this component in case of
  111948. * context lost for instance.
  111949. */
  111950. rebuild(): void;
  111951. /**
  111952. * Disposes the component and the associated ressources
  111953. */
  111954. dispose(): void;
  111955. }
  111956. }
  111957. declare module BABYLON {
  111958. /**
  111959. * A helper for physics simulations
  111960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111961. */
  111962. export class PhysicsHelper {
  111963. private _scene;
  111964. private _physicsEngine;
  111965. /**
  111966. * Initializes the Physics helper
  111967. * @param scene Babylon.js scene
  111968. */
  111969. constructor(scene: Scene);
  111970. /**
  111971. * Applies a radial explosion impulse
  111972. * @param origin the origin of the explosion
  111973. * @param radiusOrEventOptions the radius or the options of radial explosion
  111974. * @param strength the explosion strength
  111975. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111976. * @returns A physics radial explosion event, or null
  111977. */
  111978. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111979. /**
  111980. * Applies a radial explosion force
  111981. * @param origin the origin of the explosion
  111982. * @param radiusOrEventOptions the radius or the options of radial explosion
  111983. * @param strength the explosion strength
  111984. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111985. * @returns A physics radial explosion event, or null
  111986. */
  111987. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111988. /**
  111989. * Creates a gravitational field
  111990. * @param origin the origin of the explosion
  111991. * @param radiusOrEventOptions the radius or the options of radial explosion
  111992. * @param strength the explosion strength
  111993. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111994. * @returns A physics gravitational field event, or null
  111995. */
  111996. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111997. /**
  111998. * Creates a physics updraft event
  111999. * @param origin the origin of the updraft
  112000. * @param radiusOrEventOptions the radius or the options of the updraft
  112001. * @param strength the strength of the updraft
  112002. * @param height the height of the updraft
  112003. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  112004. * @returns A physics updraft event, or null
  112005. */
  112006. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  112007. /**
  112008. * Creates a physics vortex event
  112009. * @param origin the of the vortex
  112010. * @param radiusOrEventOptions the radius or the options of the vortex
  112011. * @param strength the strength of the vortex
  112012. * @param height the height of the vortex
  112013. * @returns a Physics vortex event, or null
  112014. * A physics vortex event or null
  112015. */
  112016. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  112017. }
  112018. /**
  112019. * Represents a physics radial explosion event
  112020. */
  112021. class PhysicsRadialExplosionEvent {
  112022. private _scene;
  112023. private _options;
  112024. private _sphere;
  112025. private _dataFetched;
  112026. /**
  112027. * Initializes a radial explosioin event
  112028. * @param _scene BabylonJS scene
  112029. * @param _options The options for the vortex event
  112030. */
  112031. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  112032. /**
  112033. * Returns the data related to the radial explosion event (sphere).
  112034. * @returns The radial explosion event data
  112035. */
  112036. getData(): PhysicsRadialExplosionEventData;
  112037. /**
  112038. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  112039. * @param impostor A physics imposter
  112040. * @param origin the origin of the explosion
  112041. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  112042. */
  112043. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  112044. /**
  112045. * Triggers affecterd impostors callbacks
  112046. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  112047. */
  112048. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  112049. /**
  112050. * Disposes the sphere.
  112051. * @param force Specifies if the sphere should be disposed by force
  112052. */
  112053. dispose(force?: boolean): void;
  112054. /*** Helpers ***/
  112055. private _prepareSphere;
  112056. private _intersectsWithSphere;
  112057. }
  112058. /**
  112059. * Represents a gravitational field event
  112060. */
  112061. class PhysicsGravitationalFieldEvent {
  112062. private _physicsHelper;
  112063. private _scene;
  112064. private _origin;
  112065. private _options;
  112066. private _tickCallback;
  112067. private _sphere;
  112068. private _dataFetched;
  112069. /**
  112070. * Initializes the physics gravitational field event
  112071. * @param _physicsHelper A physics helper
  112072. * @param _scene BabylonJS scene
  112073. * @param _origin The origin position of the gravitational field event
  112074. * @param _options The options for the vortex event
  112075. */
  112076. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  112077. /**
  112078. * Returns the data related to the gravitational field event (sphere).
  112079. * @returns A gravitational field event
  112080. */
  112081. getData(): PhysicsGravitationalFieldEventData;
  112082. /**
  112083. * Enables the gravitational field.
  112084. */
  112085. enable(): void;
  112086. /**
  112087. * Disables the gravitational field.
  112088. */
  112089. disable(): void;
  112090. /**
  112091. * Disposes the sphere.
  112092. * @param force The force to dispose from the gravitational field event
  112093. */
  112094. dispose(force?: boolean): void;
  112095. private _tick;
  112096. }
  112097. /**
  112098. * Represents a physics updraft event
  112099. */
  112100. class PhysicsUpdraftEvent {
  112101. private _scene;
  112102. private _origin;
  112103. private _options;
  112104. private _physicsEngine;
  112105. private _originTop;
  112106. private _originDirection;
  112107. private _tickCallback;
  112108. private _cylinder;
  112109. private _cylinderPosition;
  112110. private _dataFetched;
  112111. /**
  112112. * Initializes the physics updraft event
  112113. * @param _scene BabylonJS scene
  112114. * @param _origin The origin position of the updraft
  112115. * @param _options The options for the updraft event
  112116. */
  112117. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  112118. /**
  112119. * Returns the data related to the updraft event (cylinder).
  112120. * @returns A physics updraft event
  112121. */
  112122. getData(): PhysicsUpdraftEventData;
  112123. /**
  112124. * Enables the updraft.
  112125. */
  112126. enable(): void;
  112127. /**
  112128. * Disables the updraft.
  112129. */
  112130. disable(): void;
  112131. /**
  112132. * Disposes the cylinder.
  112133. * @param force Specifies if the updraft should be disposed by force
  112134. */
  112135. dispose(force?: boolean): void;
  112136. private getImpostorHitData;
  112137. private _tick;
  112138. /*** Helpers ***/
  112139. private _prepareCylinder;
  112140. private _intersectsWithCylinder;
  112141. }
  112142. /**
  112143. * Represents a physics vortex event
  112144. */
  112145. class PhysicsVortexEvent {
  112146. private _scene;
  112147. private _origin;
  112148. private _options;
  112149. private _physicsEngine;
  112150. private _originTop;
  112151. private _tickCallback;
  112152. private _cylinder;
  112153. private _cylinderPosition;
  112154. private _dataFetched;
  112155. /**
  112156. * Initializes the physics vortex event
  112157. * @param _scene The BabylonJS scene
  112158. * @param _origin The origin position of the vortex
  112159. * @param _options The options for the vortex event
  112160. */
  112161. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  112162. /**
  112163. * Returns the data related to the vortex event (cylinder).
  112164. * @returns The physics vortex event data
  112165. */
  112166. getData(): PhysicsVortexEventData;
  112167. /**
  112168. * Enables the vortex.
  112169. */
  112170. enable(): void;
  112171. /**
  112172. * Disables the cortex.
  112173. */
  112174. disable(): void;
  112175. /**
  112176. * Disposes the sphere.
  112177. * @param force
  112178. */
  112179. dispose(force?: boolean): void;
  112180. private getImpostorHitData;
  112181. private _tick;
  112182. /*** Helpers ***/
  112183. private _prepareCylinder;
  112184. private _intersectsWithCylinder;
  112185. }
  112186. /**
  112187. * Options fot the radial explosion event
  112188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112189. */
  112190. export class PhysicsRadialExplosionEventOptions {
  112191. /**
  112192. * The radius of the sphere for the radial explosion.
  112193. */
  112194. radius: number;
  112195. /**
  112196. * The strenth of the explosion.
  112197. */
  112198. strength: number;
  112199. /**
  112200. * The strenght of the force in correspondence to the distance of the affected object
  112201. */
  112202. falloff: PhysicsRadialImpulseFalloff;
  112203. /**
  112204. * Sphere options for the radial explosion.
  112205. */
  112206. sphere: {
  112207. segments: number;
  112208. diameter: number;
  112209. };
  112210. /**
  112211. * Sphere options for the radial explosion.
  112212. */
  112213. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112214. }
  112215. /**
  112216. * Options fot the updraft event
  112217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112218. */
  112219. export class PhysicsUpdraftEventOptions {
  112220. /**
  112221. * The radius of the cylinder for the vortex
  112222. */
  112223. radius: number;
  112224. /**
  112225. * The strenth of the updraft.
  112226. */
  112227. strength: number;
  112228. /**
  112229. * The height of the cylinder for the updraft.
  112230. */
  112231. height: number;
  112232. /**
  112233. * The mode for the the updraft.
  112234. */
  112235. updraftMode: PhysicsUpdraftMode;
  112236. }
  112237. /**
  112238. * Options fot the vortex event
  112239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112240. */
  112241. export class PhysicsVortexEventOptions {
  112242. /**
  112243. * The radius of the cylinder for the vortex
  112244. */
  112245. radius: number;
  112246. /**
  112247. * The strenth of the vortex.
  112248. */
  112249. strength: number;
  112250. /**
  112251. * The height of the cylinder for the vortex.
  112252. */
  112253. height: number;
  112254. /**
  112255. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112256. */
  112257. centripetalForceThreshold: number;
  112258. /**
  112259. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112260. */
  112261. centripetalForceMultiplier: number;
  112262. /**
  112263. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112264. */
  112265. centrifugalForceMultiplier: number;
  112266. /**
  112267. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112268. */
  112269. updraftForceMultiplier: number;
  112270. }
  112271. /**
  112272. * The strenght of the force in correspondence to the distance of the affected object
  112273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112274. */
  112275. export enum PhysicsRadialImpulseFalloff {
  112276. /** Defines that impulse is constant in strength across it's whole radius */
  112277. Constant = 0,
  112278. /** Defines that impulse gets weaker if it's further from the origin */
  112279. Linear = 1
  112280. }
  112281. /**
  112282. * The strength of the force in correspondence to the distance of the affected object
  112283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112284. */
  112285. export enum PhysicsUpdraftMode {
  112286. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112287. Center = 0,
  112288. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112289. Perpendicular = 1
  112290. }
  112291. /**
  112292. * Interface for a physics hit data
  112293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112294. */
  112295. export interface PhysicsHitData {
  112296. /**
  112297. * The force applied at the contact point
  112298. */
  112299. force: Vector3;
  112300. /**
  112301. * The contact point
  112302. */
  112303. contactPoint: Vector3;
  112304. /**
  112305. * The distance from the origin to the contact point
  112306. */
  112307. distanceFromOrigin: number;
  112308. }
  112309. /**
  112310. * Interface for radial explosion event data
  112311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112312. */
  112313. export interface PhysicsRadialExplosionEventData {
  112314. /**
  112315. * A sphere used for the radial explosion event
  112316. */
  112317. sphere: Mesh;
  112318. }
  112319. /**
  112320. * Interface for gravitational field event data
  112321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112322. */
  112323. export interface PhysicsGravitationalFieldEventData {
  112324. /**
  112325. * A sphere mesh used for the gravitational field event
  112326. */
  112327. sphere: Mesh;
  112328. }
  112329. /**
  112330. * Interface for updraft event data
  112331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112332. */
  112333. export interface PhysicsUpdraftEventData {
  112334. /**
  112335. * A cylinder used for the updraft event
  112336. */
  112337. cylinder: Mesh;
  112338. }
  112339. /**
  112340. * Interface for vortex event data
  112341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112342. */
  112343. export interface PhysicsVortexEventData {
  112344. /**
  112345. * A cylinder used for the vortex event
  112346. */
  112347. cylinder: Mesh;
  112348. }
  112349. /**
  112350. * Interface for an affected physics impostor
  112351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112352. */
  112353. export interface PhysicsAffectedImpostorWithData {
  112354. /**
  112355. * The impostor affected by the effect
  112356. */
  112357. impostor: PhysicsImpostor;
  112358. /**
  112359. * The data about the hit/horce from the explosion
  112360. */
  112361. hitData: PhysicsHitData;
  112362. }
  112363. }
  112364. declare module BABYLON {
  112365. /** @hidden */
  112366. export var blackAndWhitePixelShader: {
  112367. name: string;
  112368. shader: string;
  112369. };
  112370. }
  112371. declare module BABYLON {
  112372. /**
  112373. * Post process used to render in black and white
  112374. */
  112375. export class BlackAndWhitePostProcess extends PostProcess {
  112376. /**
  112377. * Linear about to convert he result to black and white (default: 1)
  112378. */
  112379. degree: number;
  112380. /**
  112381. * Creates a black and white post process
  112382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112383. * @param name The name of the effect.
  112384. * @param options The required width/height ratio to downsize to before computing the render pass.
  112385. * @param camera The camera to apply the render pass to.
  112386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112387. * @param engine The engine which the post process will be applied. (default: current engine)
  112388. * @param reusable If the post process can be reused on the same frame. (default: false)
  112389. */
  112390. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112391. }
  112392. }
  112393. declare module BABYLON {
  112394. /**
  112395. * This represents a set of one or more post processes in Babylon.
  112396. * A post process can be used to apply a shader to a texture after it is rendered.
  112397. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112398. */
  112399. export class PostProcessRenderEffect {
  112400. private _postProcesses;
  112401. private _getPostProcesses;
  112402. private _singleInstance;
  112403. private _cameras;
  112404. private _indicesForCamera;
  112405. /**
  112406. * Name of the effect
  112407. * @hidden
  112408. */
  112409. _name: string;
  112410. /**
  112411. * Instantiates a post process render effect.
  112412. * A post process can be used to apply a shader to a texture after it is rendered.
  112413. * @param engine The engine the effect is tied to
  112414. * @param name The name of the effect
  112415. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112416. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112417. */
  112418. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112419. /**
  112420. * Checks if all the post processes in the effect are supported.
  112421. */
  112422. readonly isSupported: boolean;
  112423. /**
  112424. * Updates the current state of the effect
  112425. * @hidden
  112426. */
  112427. _update(): void;
  112428. /**
  112429. * Attaches the effect on cameras
  112430. * @param cameras The camera to attach to.
  112431. * @hidden
  112432. */
  112433. _attachCameras(cameras: Camera): void;
  112434. /**
  112435. * Attaches the effect on cameras
  112436. * @param cameras The camera to attach to.
  112437. * @hidden
  112438. */
  112439. _attachCameras(cameras: Camera[]): void;
  112440. /**
  112441. * Detaches the effect on cameras
  112442. * @param cameras The camera to detatch from.
  112443. * @hidden
  112444. */
  112445. _detachCameras(cameras: Camera): void;
  112446. /**
  112447. * Detatches the effect on cameras
  112448. * @param cameras The camera to detatch from.
  112449. * @hidden
  112450. */
  112451. _detachCameras(cameras: Camera[]): void;
  112452. /**
  112453. * Enables the effect on given cameras
  112454. * @param cameras The camera to enable.
  112455. * @hidden
  112456. */
  112457. _enable(cameras: Camera): void;
  112458. /**
  112459. * Enables the effect on given cameras
  112460. * @param cameras The camera to enable.
  112461. * @hidden
  112462. */
  112463. _enable(cameras: Nullable<Camera[]>): void;
  112464. /**
  112465. * Disables the effect on the given cameras
  112466. * @param cameras The camera to disable.
  112467. * @hidden
  112468. */
  112469. _disable(cameras: Camera): void;
  112470. /**
  112471. * Disables the effect on the given cameras
  112472. * @param cameras The camera to disable.
  112473. * @hidden
  112474. */
  112475. _disable(cameras: Nullable<Camera[]>): void;
  112476. /**
  112477. * Gets a list of the post processes contained in the effect.
  112478. * @param camera The camera to get the post processes on.
  112479. * @returns The list of the post processes in the effect.
  112480. */
  112481. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112482. }
  112483. }
  112484. declare module BABYLON {
  112485. /** @hidden */
  112486. export var extractHighlightsPixelShader: {
  112487. name: string;
  112488. shader: string;
  112489. };
  112490. }
  112491. declare module BABYLON {
  112492. /**
  112493. * 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.
  112494. */
  112495. export class ExtractHighlightsPostProcess extends PostProcess {
  112496. /**
  112497. * The luminance threshold, pixels below this value will be set to black.
  112498. */
  112499. threshold: number;
  112500. /** @hidden */
  112501. _exposure: number;
  112502. /**
  112503. * Post process which has the input texture to be used when performing highlight extraction
  112504. * @hidden
  112505. */
  112506. _inputPostProcess: Nullable<PostProcess>;
  112507. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112508. }
  112509. }
  112510. declare module BABYLON {
  112511. /** @hidden */
  112512. export var bloomMergePixelShader: {
  112513. name: string;
  112514. shader: string;
  112515. };
  112516. }
  112517. declare module BABYLON {
  112518. /**
  112519. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112520. */
  112521. export class BloomMergePostProcess extends PostProcess {
  112522. /** Weight of the bloom to be added to the original input. */
  112523. weight: number;
  112524. /**
  112525. * Creates a new instance of @see BloomMergePostProcess
  112526. * @param name The name of the effect.
  112527. * @param originalFromInput Post process which's input will be used for the merge.
  112528. * @param blurred Blurred highlights post process which's output will be used.
  112529. * @param weight Weight of the bloom to be added to the original input.
  112530. * @param options The required width/height ratio to downsize to before computing the render pass.
  112531. * @param camera The camera to apply the render pass to.
  112532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112533. * @param engine The engine which the post process will be applied. (default: current engine)
  112534. * @param reusable If the post process can be reused on the same frame. (default: false)
  112535. * @param textureType Type of textures used when performing the post process. (default: 0)
  112536. * @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)
  112537. */
  112538. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112539. /** Weight of the bloom to be added to the original input. */
  112540. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112541. }
  112542. }
  112543. declare module BABYLON {
  112544. /**
  112545. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112546. */
  112547. export class BloomEffect extends PostProcessRenderEffect {
  112548. private bloomScale;
  112549. /**
  112550. * @hidden Internal
  112551. */
  112552. _effects: Array<PostProcess>;
  112553. /**
  112554. * @hidden Internal
  112555. */
  112556. _downscale: ExtractHighlightsPostProcess;
  112557. private _blurX;
  112558. private _blurY;
  112559. private _merge;
  112560. /**
  112561. * The luminance threshold to find bright areas of the image to bloom.
  112562. */
  112563. threshold: number;
  112564. /**
  112565. * The strength of the bloom.
  112566. */
  112567. weight: number;
  112568. /**
  112569. * Specifies the size of the bloom blur kernel, relative to the final output size
  112570. */
  112571. kernel: number;
  112572. /**
  112573. * Creates a new instance of @see BloomEffect
  112574. * @param scene The scene the effect belongs to.
  112575. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112576. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112577. * @param bloomWeight The the strength of bloom.
  112578. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112579. * @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)
  112580. */
  112581. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112582. /**
  112583. * Disposes each of the internal effects for a given camera.
  112584. * @param camera The camera to dispose the effect on.
  112585. */
  112586. disposeEffects(camera: Camera): void;
  112587. /**
  112588. * @hidden Internal
  112589. */
  112590. _updateEffects(): void;
  112591. /**
  112592. * Internal
  112593. * @returns if all the contained post processes are ready.
  112594. * @hidden
  112595. */
  112596. _isReady(): boolean;
  112597. }
  112598. }
  112599. declare module BABYLON {
  112600. /** @hidden */
  112601. export var chromaticAberrationPixelShader: {
  112602. name: string;
  112603. shader: string;
  112604. };
  112605. }
  112606. declare module BABYLON {
  112607. /**
  112608. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112609. */
  112610. export class ChromaticAberrationPostProcess extends PostProcess {
  112611. /**
  112612. * The amount of seperation of rgb channels (default: 30)
  112613. */
  112614. aberrationAmount: number;
  112615. /**
  112616. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112617. */
  112618. radialIntensity: number;
  112619. /**
  112620. * 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))
  112621. */
  112622. direction: Vector2;
  112623. /**
  112624. * 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))
  112625. */
  112626. centerPosition: Vector2;
  112627. /**
  112628. * Creates a new instance ChromaticAberrationPostProcess
  112629. * @param name The name of the effect.
  112630. * @param screenWidth The width of the screen to apply the effect on.
  112631. * @param screenHeight The height of the screen to apply the effect on.
  112632. * @param options The required width/height ratio to downsize to before computing the render pass.
  112633. * @param camera The camera to apply the render pass to.
  112634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112635. * @param engine The engine which the post process will be applied. (default: current engine)
  112636. * @param reusable If the post process can be reused on the same frame. (default: false)
  112637. * @param textureType Type of textures used when performing the post process. (default: 0)
  112638. * @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)
  112639. */
  112640. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112641. }
  112642. }
  112643. declare module BABYLON {
  112644. /** @hidden */
  112645. export var circleOfConfusionPixelShader: {
  112646. name: string;
  112647. shader: string;
  112648. };
  112649. }
  112650. declare module BABYLON {
  112651. /**
  112652. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112653. */
  112654. export class CircleOfConfusionPostProcess extends PostProcess {
  112655. /**
  112656. * 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.
  112657. */
  112658. lensSize: number;
  112659. /**
  112660. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112661. */
  112662. fStop: number;
  112663. /**
  112664. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112665. */
  112666. focusDistance: number;
  112667. /**
  112668. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112669. */
  112670. focalLength: number;
  112671. private _depthTexture;
  112672. /**
  112673. * Creates a new instance CircleOfConfusionPostProcess
  112674. * @param name The name of the effect.
  112675. * @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.
  112676. * @param options The required width/height ratio to downsize to before computing the render pass.
  112677. * @param camera The camera to apply the render pass to.
  112678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112679. * @param engine The engine which the post process will be applied. (default: current engine)
  112680. * @param reusable If the post process can be reused on the same frame. (default: false)
  112681. * @param textureType Type of textures used when performing the post process. (default: 0)
  112682. * @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)
  112683. */
  112684. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112685. /**
  112686. * 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.
  112687. */
  112688. depthTexture: RenderTargetTexture;
  112689. }
  112690. }
  112691. declare module BABYLON {
  112692. /** @hidden */
  112693. export var colorCorrectionPixelShader: {
  112694. name: string;
  112695. shader: string;
  112696. };
  112697. }
  112698. declare module BABYLON {
  112699. /**
  112700. *
  112701. * This post-process allows the modification of rendered colors by using
  112702. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112703. *
  112704. * The object needs to be provided an url to a texture containing the color
  112705. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112706. * Use an image editing software to tweak the LUT to match your needs.
  112707. *
  112708. * For an example of a color LUT, see here:
  112709. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112710. * For explanations on color grading, see here:
  112711. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112712. *
  112713. */
  112714. export class ColorCorrectionPostProcess extends PostProcess {
  112715. private _colorTableTexture;
  112716. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112717. }
  112718. }
  112719. declare module BABYLON {
  112720. /** @hidden */
  112721. export var convolutionPixelShader: {
  112722. name: string;
  112723. shader: string;
  112724. };
  112725. }
  112726. declare module BABYLON {
  112727. /**
  112728. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112729. * input texture to perform effects such as edge detection or sharpening
  112730. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112731. */
  112732. export class ConvolutionPostProcess extends PostProcess {
  112733. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112734. kernel: number[];
  112735. /**
  112736. * Creates a new instance ConvolutionPostProcess
  112737. * @param name The name of the effect.
  112738. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112739. * @param options The required width/height ratio to downsize to before computing the render pass.
  112740. * @param camera The camera to apply the render pass to.
  112741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112742. * @param engine The engine which the post process will be applied. (default: current engine)
  112743. * @param reusable If the post process can be reused on the same frame. (default: false)
  112744. * @param textureType Type of textures used when performing the post process. (default: 0)
  112745. */
  112746. constructor(name: string,
  112747. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112748. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112749. /**
  112750. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112751. */
  112752. static EdgeDetect0Kernel: number[];
  112753. /**
  112754. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112755. */
  112756. static EdgeDetect1Kernel: number[];
  112757. /**
  112758. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112759. */
  112760. static EdgeDetect2Kernel: number[];
  112761. /**
  112762. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112763. */
  112764. static SharpenKernel: number[];
  112765. /**
  112766. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112767. */
  112768. static EmbossKernel: number[];
  112769. /**
  112770. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112771. */
  112772. static GaussianKernel: number[];
  112773. }
  112774. }
  112775. declare module BABYLON {
  112776. /**
  112777. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112778. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112779. * based on samples that have a large difference in distance than the center pixel.
  112780. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112781. */
  112782. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112783. direction: Vector2;
  112784. /**
  112785. * Creates a new instance CircleOfConfusionPostProcess
  112786. * @param name The name of the effect.
  112787. * @param scene The scene the effect belongs to.
  112788. * @param direction The direction the blur should be applied.
  112789. * @param kernel The size of the kernel used to blur.
  112790. * @param options The required width/height ratio to downsize to before computing the render pass.
  112791. * @param camera The camera to apply the render pass to.
  112792. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112793. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112795. * @param engine The engine which the post process will be applied. (default: current engine)
  112796. * @param reusable If the post process can be reused on the same frame. (default: false)
  112797. * @param textureType Type of textures used when performing the post process. (default: 0)
  112798. * @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)
  112799. */
  112800. 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);
  112801. }
  112802. }
  112803. declare module BABYLON {
  112804. /** @hidden */
  112805. export var depthOfFieldMergePixelShader: {
  112806. name: string;
  112807. shader: string;
  112808. };
  112809. }
  112810. declare module BABYLON {
  112811. /**
  112812. * Options to be set when merging outputs from the default pipeline.
  112813. */
  112814. export class DepthOfFieldMergePostProcessOptions {
  112815. /**
  112816. * The original image to merge on top of
  112817. */
  112818. originalFromInput: PostProcess;
  112819. /**
  112820. * Parameters to perform the merge of the depth of field effect
  112821. */
  112822. depthOfField?: {
  112823. circleOfConfusion: PostProcess;
  112824. blurSteps: Array<PostProcess>;
  112825. };
  112826. /**
  112827. * Parameters to perform the merge of bloom effect
  112828. */
  112829. bloom?: {
  112830. blurred: PostProcess;
  112831. weight: number;
  112832. };
  112833. }
  112834. /**
  112835. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112836. */
  112837. export class DepthOfFieldMergePostProcess extends PostProcess {
  112838. private blurSteps;
  112839. /**
  112840. * Creates a new instance of DepthOfFieldMergePostProcess
  112841. * @param name The name of the effect.
  112842. * @param originalFromInput Post process which's input will be used for the merge.
  112843. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112844. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112845. * @param options The required width/height ratio to downsize to before computing the render pass.
  112846. * @param camera The camera to apply the render pass to.
  112847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112848. * @param engine The engine which the post process will be applied. (default: current engine)
  112849. * @param reusable If the post process can be reused on the same frame. (default: false)
  112850. * @param textureType Type of textures used when performing the post process. (default: 0)
  112851. * @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)
  112852. */
  112853. 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);
  112854. /**
  112855. * Updates the effect with the current post process compile time values and recompiles the shader.
  112856. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112857. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112858. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112859. * @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
  112860. * @param onCompiled Called when the shader has been compiled.
  112861. * @param onError Called if there is an error when compiling a shader.
  112862. */
  112863. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112864. }
  112865. }
  112866. declare module BABYLON {
  112867. /**
  112868. * Specifies the level of max blur that should be applied when using the depth of field effect
  112869. */
  112870. export enum DepthOfFieldEffectBlurLevel {
  112871. /**
  112872. * Subtle blur
  112873. */
  112874. Low = 0,
  112875. /**
  112876. * Medium blur
  112877. */
  112878. Medium = 1,
  112879. /**
  112880. * Large blur
  112881. */
  112882. High = 2
  112883. }
  112884. /**
  112885. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112886. */
  112887. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112888. private _circleOfConfusion;
  112889. /**
  112890. * @hidden Internal, blurs from high to low
  112891. */
  112892. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112893. private _depthOfFieldBlurY;
  112894. private _dofMerge;
  112895. /**
  112896. * @hidden Internal post processes in depth of field effect
  112897. */
  112898. _effects: Array<PostProcess>;
  112899. /**
  112900. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112901. */
  112902. focalLength: number;
  112903. /**
  112904. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112905. */
  112906. fStop: number;
  112907. /**
  112908. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112909. */
  112910. focusDistance: number;
  112911. /**
  112912. * 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.
  112913. */
  112914. lensSize: number;
  112915. /**
  112916. * Creates a new instance DepthOfFieldEffect
  112917. * @param scene The scene the effect belongs to.
  112918. * @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.
  112919. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112920. * @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)
  112921. */
  112922. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112923. /**
  112924. * Get the current class name of the current effet
  112925. * @returns "DepthOfFieldEffect"
  112926. */
  112927. getClassName(): string;
  112928. /**
  112929. * 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.
  112930. */
  112931. depthTexture: RenderTargetTexture;
  112932. /**
  112933. * Disposes each of the internal effects for a given camera.
  112934. * @param camera The camera to dispose the effect on.
  112935. */
  112936. disposeEffects(camera: Camera): void;
  112937. /**
  112938. * @hidden Internal
  112939. */
  112940. _updateEffects(): void;
  112941. /**
  112942. * Internal
  112943. * @returns if all the contained post processes are ready.
  112944. * @hidden
  112945. */
  112946. _isReady(): boolean;
  112947. }
  112948. }
  112949. declare module BABYLON {
  112950. /** @hidden */
  112951. export var displayPassPixelShader: {
  112952. name: string;
  112953. shader: string;
  112954. };
  112955. }
  112956. declare module BABYLON {
  112957. /**
  112958. * DisplayPassPostProcess which produces an output the same as it's input
  112959. */
  112960. export class DisplayPassPostProcess extends PostProcess {
  112961. /**
  112962. * Creates the DisplayPassPostProcess
  112963. * @param name The name of the effect.
  112964. * @param options The required width/height ratio to downsize to before computing the render pass.
  112965. * @param camera The camera to apply the render pass to.
  112966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112967. * @param engine The engine which the post process will be applied. (default: current engine)
  112968. * @param reusable If the post process can be reused on the same frame. (default: false)
  112969. */
  112970. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112971. }
  112972. }
  112973. declare module BABYLON {
  112974. /** @hidden */
  112975. export var filterPixelShader: {
  112976. name: string;
  112977. shader: string;
  112978. };
  112979. }
  112980. declare module BABYLON {
  112981. /**
  112982. * Applies a kernel filter to the image
  112983. */
  112984. export class FilterPostProcess extends PostProcess {
  112985. /** The matrix to be applied to the image */
  112986. kernelMatrix: Matrix;
  112987. /**
  112988. *
  112989. * @param name The name of the effect.
  112990. * @param kernelMatrix The matrix to be applied to the image
  112991. * @param options The required width/height ratio to downsize to before computing the render pass.
  112992. * @param camera The camera to apply the render pass to.
  112993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112994. * @param engine The engine which the post process will be applied. (default: current engine)
  112995. * @param reusable If the post process can be reused on the same frame. (default: false)
  112996. */
  112997. constructor(name: string,
  112998. /** The matrix to be applied to the image */
  112999. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113000. }
  113001. }
  113002. declare module BABYLON {
  113003. /** @hidden */
  113004. export var fxaaPixelShader: {
  113005. name: string;
  113006. shader: string;
  113007. };
  113008. }
  113009. declare module BABYLON {
  113010. /** @hidden */
  113011. export var fxaaVertexShader: {
  113012. name: string;
  113013. shader: string;
  113014. };
  113015. }
  113016. declare module BABYLON {
  113017. /**
  113018. * Fxaa post process
  113019. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  113020. */
  113021. export class FxaaPostProcess extends PostProcess {
  113022. /** @hidden */
  113023. texelWidth: number;
  113024. /** @hidden */
  113025. texelHeight: number;
  113026. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  113027. private _getDefines;
  113028. }
  113029. }
  113030. declare module BABYLON {
  113031. /** @hidden */
  113032. export var grainPixelShader: {
  113033. name: string;
  113034. shader: string;
  113035. };
  113036. }
  113037. declare module BABYLON {
  113038. /**
  113039. * The GrainPostProcess adds noise to the image at mid luminance levels
  113040. */
  113041. export class GrainPostProcess extends PostProcess {
  113042. /**
  113043. * The intensity of the grain added (default: 30)
  113044. */
  113045. intensity: number;
  113046. /**
  113047. * If the grain should be randomized on every frame
  113048. */
  113049. animated: boolean;
  113050. /**
  113051. * Creates a new instance of @see GrainPostProcess
  113052. * @param name The name of the effect.
  113053. * @param options The required width/height ratio to downsize to before computing the render pass.
  113054. * @param camera The camera to apply the render pass to.
  113055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113056. * @param engine The engine which the post process will be applied. (default: current engine)
  113057. * @param reusable If the post process can be reused on the same frame. (default: false)
  113058. * @param textureType Type of textures used when performing the post process. (default: 0)
  113059. * @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)
  113060. */
  113061. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113062. }
  113063. }
  113064. declare module BABYLON {
  113065. /** @hidden */
  113066. export var highlightsPixelShader: {
  113067. name: string;
  113068. shader: string;
  113069. };
  113070. }
  113071. declare module BABYLON {
  113072. /**
  113073. * Extracts highlights from the image
  113074. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  113075. */
  113076. export class HighlightsPostProcess extends PostProcess {
  113077. /**
  113078. * Extracts highlights from the image
  113079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  113080. * @param name The name of the effect.
  113081. * @param options The required width/height ratio to downsize to before computing the render pass.
  113082. * @param camera The camera to apply the render pass to.
  113083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113084. * @param engine The engine which the post process will be applied. (default: current engine)
  113085. * @param reusable If the post process can be reused on the same frame. (default: false)
  113086. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  113087. */
  113088. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  113089. }
  113090. }
  113091. declare module BABYLON {
  113092. /** @hidden */
  113093. export var mrtFragmentDeclaration: {
  113094. name: string;
  113095. shader: string;
  113096. };
  113097. }
  113098. declare module BABYLON {
  113099. /** @hidden */
  113100. export var geometryPixelShader: {
  113101. name: string;
  113102. shader: string;
  113103. };
  113104. }
  113105. declare module BABYLON {
  113106. /** @hidden */
  113107. export var geometryVertexShader: {
  113108. name: string;
  113109. shader: string;
  113110. };
  113111. }
  113112. declare module BABYLON {
  113113. /** @hidden */
  113114. interface ISavedTransformationMatrix {
  113115. world: Matrix;
  113116. viewProjection: Matrix;
  113117. }
  113118. /**
  113119. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  113120. */
  113121. export class GeometryBufferRenderer {
  113122. /**
  113123. * Constant used to retrieve the position texture index in the G-Buffer textures array
  113124. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  113125. */
  113126. static readonly POSITION_TEXTURE_TYPE: number;
  113127. /**
  113128. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  113129. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  113130. */
  113131. static readonly VELOCITY_TEXTURE_TYPE: number;
  113132. /**
  113133. * Dictionary used to store the previous transformation matrices of each rendered mesh
  113134. * in order to compute objects velocities when enableVelocity is set to "true"
  113135. * @hidden
  113136. */
  113137. _previousTransformationMatrices: {
  113138. [index: number]: ISavedTransformationMatrix;
  113139. };
  113140. /**
  113141. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  113142. * in order to compute objects velocities when enableVelocity is set to "true"
  113143. * @hidden
  113144. */
  113145. _previousBonesTransformationMatrices: {
  113146. [index: number]: Float32Array;
  113147. };
  113148. /**
  113149. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  113150. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  113151. */
  113152. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  113153. private _scene;
  113154. private _multiRenderTarget;
  113155. private _ratio;
  113156. private _enablePosition;
  113157. private _enableVelocity;
  113158. private _positionIndex;
  113159. private _velocityIndex;
  113160. protected _effect: Effect;
  113161. protected _cachedDefines: string;
  113162. /**
  113163. * Set the render list (meshes to be rendered) used in the G buffer.
  113164. */
  113165. renderList: Mesh[];
  113166. /**
  113167. * Gets wether or not G buffer are supported by the running hardware.
  113168. * This requires draw buffer supports
  113169. */
  113170. readonly isSupported: boolean;
  113171. /**
  113172. * Returns the index of the given texture type in the G-Buffer textures array
  113173. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  113174. * @returns the index of the given texture type in the G-Buffer textures array
  113175. */
  113176. getTextureIndex(textureType: number): number;
  113177. /**
  113178. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  113179. */
  113180. /**
  113181. * Sets whether or not objects positions are enabled for the G buffer.
  113182. */
  113183. enablePosition: boolean;
  113184. /**
  113185. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  113186. */
  113187. /**
  113188. * Sets wether or not objects velocities are enabled for the G buffer.
  113189. */
  113190. enableVelocity: boolean;
  113191. /**
  113192. * Gets the scene associated with the buffer.
  113193. */
  113194. readonly scene: Scene;
  113195. /**
  113196. * Gets the ratio used by the buffer during its creation.
  113197. * How big is the buffer related to the main canvas.
  113198. */
  113199. readonly ratio: number;
  113200. /** @hidden */
  113201. static _SceneComponentInitialization: (scene: Scene) => void;
  113202. /**
  113203. * Creates a new G Buffer for the scene
  113204. * @param scene The scene the buffer belongs to
  113205. * @param ratio How big is the buffer related to the main canvas.
  113206. */
  113207. constructor(scene: Scene, ratio?: number);
  113208. /**
  113209. * Checks wether everything is ready to render a submesh to the G buffer.
  113210. * @param subMesh the submesh to check readiness for
  113211. * @param useInstances is the mesh drawn using instance or not
  113212. * @returns true if ready otherwise false
  113213. */
  113214. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113215. /**
  113216. * Gets the current underlying G Buffer.
  113217. * @returns the buffer
  113218. */
  113219. getGBuffer(): MultiRenderTarget;
  113220. /**
  113221. * Gets the number of samples used to render the buffer (anti aliasing).
  113222. */
  113223. /**
  113224. * Sets the number of samples used to render the buffer (anti aliasing).
  113225. */
  113226. samples: number;
  113227. /**
  113228. * Disposes the renderer and frees up associated resources.
  113229. */
  113230. dispose(): void;
  113231. protected _createRenderTargets(): void;
  113232. private _copyBonesTransformationMatrices;
  113233. }
  113234. }
  113235. declare module BABYLON {
  113236. interface Scene {
  113237. /** @hidden (Backing field) */
  113238. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113239. /**
  113240. * Gets or Sets the current geometry buffer associated to the scene.
  113241. */
  113242. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113243. /**
  113244. * Enables a GeometryBufferRender and associates it with the scene
  113245. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113246. * @returns the GeometryBufferRenderer
  113247. */
  113248. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113249. /**
  113250. * Disables the GeometryBufferRender associated with the scene
  113251. */
  113252. disableGeometryBufferRenderer(): void;
  113253. }
  113254. /**
  113255. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113256. * in several rendering techniques.
  113257. */
  113258. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113259. /**
  113260. * The component name helpful to identify the component in the list of scene components.
  113261. */
  113262. readonly name: string;
  113263. /**
  113264. * The scene the component belongs to.
  113265. */
  113266. scene: Scene;
  113267. /**
  113268. * Creates a new instance of the component for the given scene
  113269. * @param scene Defines the scene to register the component in
  113270. */
  113271. constructor(scene: Scene);
  113272. /**
  113273. * Registers the component in a given scene
  113274. */
  113275. register(): void;
  113276. /**
  113277. * Rebuilds the elements related to this component in case of
  113278. * context lost for instance.
  113279. */
  113280. rebuild(): void;
  113281. /**
  113282. * Disposes the component and the associated ressources
  113283. */
  113284. dispose(): void;
  113285. private _gatherRenderTargets;
  113286. }
  113287. }
  113288. declare module BABYLON {
  113289. /** @hidden */
  113290. export var motionBlurPixelShader: {
  113291. name: string;
  113292. shader: string;
  113293. };
  113294. }
  113295. declare module BABYLON {
  113296. /**
  113297. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113298. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113299. * As an example, all you have to do is to create the post-process:
  113300. * var mb = new BABYLON.MotionBlurPostProcess(
  113301. * 'mb', // The name of the effect.
  113302. * scene, // The scene containing the objects to blur according to their velocity.
  113303. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113304. * camera // The camera to apply the render pass to.
  113305. * );
  113306. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113307. */
  113308. export class MotionBlurPostProcess extends PostProcess {
  113309. /**
  113310. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113311. */
  113312. motionStrength: number;
  113313. /**
  113314. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113315. */
  113316. /**
  113317. * Sets the number of iterations to be used for motion blur quality
  113318. */
  113319. motionBlurSamples: number;
  113320. private _motionBlurSamples;
  113321. private _geometryBufferRenderer;
  113322. /**
  113323. * Creates a new instance MotionBlurPostProcess
  113324. * @param name The name of the effect.
  113325. * @param scene The scene containing the objects to blur according to their velocity.
  113326. * @param options The required width/height ratio to downsize to before computing the render pass.
  113327. * @param camera The camera to apply the render pass to.
  113328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113329. * @param engine The engine which the post process will be applied. (default: current engine)
  113330. * @param reusable If the post process can be reused on the same frame. (default: false)
  113331. * @param textureType Type of textures used when performing the post process. (default: 0)
  113332. * @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)
  113333. */
  113334. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113335. /**
  113336. * Excludes the given skinned mesh from computing bones velocities.
  113337. * 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.
  113338. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  113339. */
  113340. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  113341. /**
  113342. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  113343. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  113344. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  113345. */
  113346. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  113347. /**
  113348. * Disposes the post process.
  113349. * @param camera The camera to dispose the post process on.
  113350. */
  113351. dispose(camera?: Camera): void;
  113352. }
  113353. }
  113354. declare module BABYLON {
  113355. /** @hidden */
  113356. export var refractionPixelShader: {
  113357. name: string;
  113358. shader: string;
  113359. };
  113360. }
  113361. declare module BABYLON {
  113362. /**
  113363. * Post process which applies a refractin texture
  113364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113365. */
  113366. export class RefractionPostProcess extends PostProcess {
  113367. /** the base color of the refraction (used to taint the rendering) */
  113368. color: Color3;
  113369. /** simulated refraction depth */
  113370. depth: number;
  113371. /** the coefficient of the base color (0 to remove base color tainting) */
  113372. colorLevel: number;
  113373. private _refTexture;
  113374. private _ownRefractionTexture;
  113375. /**
  113376. * Gets or sets the refraction texture
  113377. * Please note that you are responsible for disposing the texture if you set it manually
  113378. */
  113379. refractionTexture: Texture;
  113380. /**
  113381. * Initializes the RefractionPostProcess
  113382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113383. * @param name The name of the effect.
  113384. * @param refractionTextureUrl Url of the refraction texture to use
  113385. * @param color the base color of the refraction (used to taint the rendering)
  113386. * @param depth simulated refraction depth
  113387. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113388. * @param camera The camera to apply the render pass to.
  113389. * @param options The required width/height ratio to downsize to before computing the render pass.
  113390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113391. * @param engine The engine which the post process will be applied. (default: current engine)
  113392. * @param reusable If the post process can be reused on the same frame. (default: false)
  113393. */
  113394. constructor(name: string, refractionTextureUrl: string,
  113395. /** the base color of the refraction (used to taint the rendering) */
  113396. color: Color3,
  113397. /** simulated refraction depth */
  113398. depth: number,
  113399. /** the coefficient of the base color (0 to remove base color tainting) */
  113400. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113401. /**
  113402. * Disposes of the post process
  113403. * @param camera Camera to dispose post process on
  113404. */
  113405. dispose(camera: Camera): void;
  113406. }
  113407. }
  113408. declare module BABYLON {
  113409. /** @hidden */
  113410. export var sharpenPixelShader: {
  113411. name: string;
  113412. shader: string;
  113413. };
  113414. }
  113415. declare module BABYLON {
  113416. /**
  113417. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113418. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113419. */
  113420. export class SharpenPostProcess extends PostProcess {
  113421. /**
  113422. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113423. */
  113424. colorAmount: number;
  113425. /**
  113426. * How much sharpness should be applied (default: 0.3)
  113427. */
  113428. edgeAmount: number;
  113429. /**
  113430. * Creates a new instance ConvolutionPostProcess
  113431. * @param name The name of the effect.
  113432. * @param options The required width/height ratio to downsize to before computing the render pass.
  113433. * @param camera The camera to apply the render pass to.
  113434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113435. * @param engine The engine which the post process will be applied. (default: current engine)
  113436. * @param reusable If the post process can be reused on the same frame. (default: false)
  113437. * @param textureType Type of textures used when performing the post process. (default: 0)
  113438. * @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)
  113439. */
  113440. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113441. }
  113442. }
  113443. declare module BABYLON {
  113444. /**
  113445. * PostProcessRenderPipeline
  113446. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113447. */
  113448. export class PostProcessRenderPipeline {
  113449. private engine;
  113450. private _renderEffects;
  113451. private _renderEffectsForIsolatedPass;
  113452. /**
  113453. * List of inspectable custom properties (used by the Inspector)
  113454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113455. */
  113456. inspectableCustomProperties: IInspectable[];
  113457. /**
  113458. * @hidden
  113459. */
  113460. protected _cameras: Camera[];
  113461. /** @hidden */
  113462. _name: string;
  113463. /**
  113464. * Gets pipeline name
  113465. */
  113466. readonly name: string;
  113467. /**
  113468. * Initializes a PostProcessRenderPipeline
  113469. * @param engine engine to add the pipeline to
  113470. * @param name name of the pipeline
  113471. */
  113472. constructor(engine: Engine, name: string);
  113473. /**
  113474. * Gets the class name
  113475. * @returns "PostProcessRenderPipeline"
  113476. */
  113477. getClassName(): string;
  113478. /**
  113479. * If all the render effects in the pipeline are supported
  113480. */
  113481. readonly isSupported: boolean;
  113482. /**
  113483. * Adds an effect to the pipeline
  113484. * @param renderEffect the effect to add
  113485. */
  113486. addEffect(renderEffect: PostProcessRenderEffect): void;
  113487. /** @hidden */
  113488. _rebuild(): void;
  113489. /** @hidden */
  113490. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113491. /** @hidden */
  113492. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113493. /** @hidden */
  113494. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113495. /** @hidden */
  113496. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113497. /** @hidden */
  113498. _attachCameras(cameras: Camera, unique: boolean): void;
  113499. /** @hidden */
  113500. _attachCameras(cameras: Camera[], unique: boolean): void;
  113501. /** @hidden */
  113502. _detachCameras(cameras: Camera): void;
  113503. /** @hidden */
  113504. _detachCameras(cameras: Nullable<Camera[]>): void;
  113505. /** @hidden */
  113506. _update(): void;
  113507. /** @hidden */
  113508. _reset(): void;
  113509. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113510. /**
  113511. * Disposes of the pipeline
  113512. */
  113513. dispose(): void;
  113514. }
  113515. }
  113516. declare module BABYLON {
  113517. /**
  113518. * PostProcessRenderPipelineManager class
  113519. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113520. */
  113521. export class PostProcessRenderPipelineManager {
  113522. private _renderPipelines;
  113523. /**
  113524. * Initializes a PostProcessRenderPipelineManager
  113525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113526. */
  113527. constructor();
  113528. /**
  113529. * Gets the list of supported render pipelines
  113530. */
  113531. readonly supportedPipelines: PostProcessRenderPipeline[];
  113532. /**
  113533. * Adds a pipeline to the manager
  113534. * @param renderPipeline The pipeline to add
  113535. */
  113536. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113537. /**
  113538. * Attaches a camera to the pipeline
  113539. * @param renderPipelineName The name of the pipeline to attach to
  113540. * @param cameras the camera to attach
  113541. * @param unique if the camera can be attached multiple times to the pipeline
  113542. */
  113543. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113544. /**
  113545. * Detaches a camera from the pipeline
  113546. * @param renderPipelineName The name of the pipeline to detach from
  113547. * @param cameras the camera to detach
  113548. */
  113549. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113550. /**
  113551. * Enables an effect by name on a pipeline
  113552. * @param renderPipelineName the name of the pipeline to enable the effect in
  113553. * @param renderEffectName the name of the effect to enable
  113554. * @param cameras the cameras that the effect should be enabled on
  113555. */
  113556. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113557. /**
  113558. * Disables an effect by name on a pipeline
  113559. * @param renderPipelineName the name of the pipeline to disable the effect in
  113560. * @param renderEffectName the name of the effect to disable
  113561. * @param cameras the cameras that the effect should be disabled on
  113562. */
  113563. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113564. /**
  113565. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113566. */
  113567. update(): void;
  113568. /** @hidden */
  113569. _rebuild(): void;
  113570. /**
  113571. * Disposes of the manager and pipelines
  113572. */
  113573. dispose(): void;
  113574. }
  113575. }
  113576. declare module BABYLON {
  113577. interface Scene {
  113578. /** @hidden (Backing field) */
  113579. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113580. /**
  113581. * Gets the postprocess render pipeline manager
  113582. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113583. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113584. */
  113585. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113586. }
  113587. /**
  113588. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113589. */
  113590. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113591. /**
  113592. * The component name helpfull to identify the component in the list of scene components.
  113593. */
  113594. readonly name: string;
  113595. /**
  113596. * The scene the component belongs to.
  113597. */
  113598. scene: Scene;
  113599. /**
  113600. * Creates a new instance of the component for the given scene
  113601. * @param scene Defines the scene to register the component in
  113602. */
  113603. constructor(scene: Scene);
  113604. /**
  113605. * Registers the component in a given scene
  113606. */
  113607. register(): void;
  113608. /**
  113609. * Rebuilds the elements related to this component in case of
  113610. * context lost for instance.
  113611. */
  113612. rebuild(): void;
  113613. /**
  113614. * Disposes the component and the associated ressources
  113615. */
  113616. dispose(): void;
  113617. private _gatherRenderTargets;
  113618. }
  113619. }
  113620. declare module BABYLON {
  113621. /**
  113622. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113623. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113624. */
  113625. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113626. private _scene;
  113627. private _camerasToBeAttached;
  113628. /**
  113629. * ID of the sharpen post process,
  113630. */
  113631. private readonly SharpenPostProcessId;
  113632. /**
  113633. * @ignore
  113634. * ID of the image processing post process;
  113635. */
  113636. readonly ImageProcessingPostProcessId: string;
  113637. /**
  113638. * @ignore
  113639. * ID of the Fast Approximate Anti-Aliasing post process;
  113640. */
  113641. readonly FxaaPostProcessId: string;
  113642. /**
  113643. * ID of the chromatic aberration post process,
  113644. */
  113645. private readonly ChromaticAberrationPostProcessId;
  113646. /**
  113647. * ID of the grain post process
  113648. */
  113649. private readonly GrainPostProcessId;
  113650. /**
  113651. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113652. */
  113653. sharpen: SharpenPostProcess;
  113654. private _sharpenEffect;
  113655. private bloom;
  113656. /**
  113657. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113658. */
  113659. depthOfField: DepthOfFieldEffect;
  113660. /**
  113661. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113662. */
  113663. fxaa: FxaaPostProcess;
  113664. /**
  113665. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113666. */
  113667. imageProcessing: ImageProcessingPostProcess;
  113668. /**
  113669. * Chromatic aberration post process which will shift rgb colors in the image
  113670. */
  113671. chromaticAberration: ChromaticAberrationPostProcess;
  113672. private _chromaticAberrationEffect;
  113673. /**
  113674. * Grain post process which add noise to the image
  113675. */
  113676. grain: GrainPostProcess;
  113677. private _grainEffect;
  113678. /**
  113679. * Glow post process which adds a glow to emissive areas of the image
  113680. */
  113681. private _glowLayer;
  113682. /**
  113683. * Animations which can be used to tweak settings over a period of time
  113684. */
  113685. animations: Animation[];
  113686. private _imageProcessingConfigurationObserver;
  113687. private _sharpenEnabled;
  113688. private _bloomEnabled;
  113689. private _depthOfFieldEnabled;
  113690. private _depthOfFieldBlurLevel;
  113691. private _fxaaEnabled;
  113692. private _imageProcessingEnabled;
  113693. private _defaultPipelineTextureType;
  113694. private _bloomScale;
  113695. private _chromaticAberrationEnabled;
  113696. private _grainEnabled;
  113697. private _buildAllowed;
  113698. /**
  113699. * Gets active scene
  113700. */
  113701. readonly scene: Scene;
  113702. /**
  113703. * Enable or disable the sharpen process from the pipeline
  113704. */
  113705. sharpenEnabled: boolean;
  113706. private _resizeObserver;
  113707. private _hardwareScaleLevel;
  113708. private _bloomKernel;
  113709. /**
  113710. * Specifies the size of the bloom blur kernel, relative to the final output size
  113711. */
  113712. bloomKernel: number;
  113713. /**
  113714. * Specifies the weight of the bloom in the final rendering
  113715. */
  113716. private _bloomWeight;
  113717. /**
  113718. * Specifies the luma threshold for the area that will be blurred by the bloom
  113719. */
  113720. private _bloomThreshold;
  113721. private _hdr;
  113722. /**
  113723. * The strength of the bloom.
  113724. */
  113725. bloomWeight: number;
  113726. /**
  113727. * The strength of the bloom.
  113728. */
  113729. bloomThreshold: number;
  113730. /**
  113731. * The scale of the bloom, lower value will provide better performance.
  113732. */
  113733. bloomScale: number;
  113734. /**
  113735. * Enable or disable the bloom from the pipeline
  113736. */
  113737. bloomEnabled: boolean;
  113738. private _rebuildBloom;
  113739. /**
  113740. * If the depth of field is enabled.
  113741. */
  113742. depthOfFieldEnabled: boolean;
  113743. /**
  113744. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113745. */
  113746. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113747. /**
  113748. * If the anti aliasing is enabled.
  113749. */
  113750. fxaaEnabled: boolean;
  113751. private _samples;
  113752. /**
  113753. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113754. */
  113755. samples: number;
  113756. /**
  113757. * If image processing is enabled.
  113758. */
  113759. imageProcessingEnabled: boolean;
  113760. /**
  113761. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113762. */
  113763. glowLayerEnabled: boolean;
  113764. /**
  113765. * Gets the glow layer (or null if not defined)
  113766. */
  113767. readonly glowLayer: Nullable<GlowLayer>;
  113768. /**
  113769. * Enable or disable the chromaticAberration process from the pipeline
  113770. */
  113771. chromaticAberrationEnabled: boolean;
  113772. /**
  113773. * Enable or disable the grain process from the pipeline
  113774. */
  113775. grainEnabled: boolean;
  113776. /**
  113777. * @constructor
  113778. * @param name - The rendering pipeline name (default: "")
  113779. * @param hdr - If high dynamic range textures should be used (default: true)
  113780. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113781. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113782. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113783. */
  113784. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113785. /**
  113786. * Get the class name
  113787. * @returns "DefaultRenderingPipeline"
  113788. */
  113789. getClassName(): string;
  113790. /**
  113791. * Force the compilation of the entire pipeline.
  113792. */
  113793. prepare(): void;
  113794. private _hasCleared;
  113795. private _prevPostProcess;
  113796. private _prevPrevPostProcess;
  113797. private _setAutoClearAndTextureSharing;
  113798. private _depthOfFieldSceneObserver;
  113799. private _buildPipeline;
  113800. private _disposePostProcesses;
  113801. /**
  113802. * Adds a camera to the pipeline
  113803. * @param camera the camera to be added
  113804. */
  113805. addCamera(camera: Camera): void;
  113806. /**
  113807. * Removes a camera from the pipeline
  113808. * @param camera the camera to remove
  113809. */
  113810. removeCamera(camera: Camera): void;
  113811. /**
  113812. * Dispose of the pipeline and stop all post processes
  113813. */
  113814. dispose(): void;
  113815. /**
  113816. * Serialize the rendering pipeline (Used when exporting)
  113817. * @returns the serialized object
  113818. */
  113819. serialize(): any;
  113820. /**
  113821. * Parse the serialized pipeline
  113822. * @param source Source pipeline.
  113823. * @param scene The scene to load the pipeline to.
  113824. * @param rootUrl The URL of the serialized pipeline.
  113825. * @returns An instantiated pipeline from the serialized object.
  113826. */
  113827. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113828. }
  113829. }
  113830. declare module BABYLON {
  113831. /** @hidden */
  113832. export var lensHighlightsPixelShader: {
  113833. name: string;
  113834. shader: string;
  113835. };
  113836. }
  113837. declare module BABYLON {
  113838. /** @hidden */
  113839. export var depthOfFieldPixelShader: {
  113840. name: string;
  113841. shader: string;
  113842. };
  113843. }
  113844. declare module BABYLON {
  113845. /**
  113846. * BABYLON.JS Chromatic Aberration GLSL Shader
  113847. * Author: Olivier Guyot
  113848. * Separates very slightly R, G and B colors on the edges of the screen
  113849. * Inspired by Francois Tarlier & Martins Upitis
  113850. */
  113851. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113852. /**
  113853. * @ignore
  113854. * The chromatic aberration PostProcess id in the pipeline
  113855. */
  113856. LensChromaticAberrationEffect: string;
  113857. /**
  113858. * @ignore
  113859. * The highlights enhancing PostProcess id in the pipeline
  113860. */
  113861. HighlightsEnhancingEffect: string;
  113862. /**
  113863. * @ignore
  113864. * The depth-of-field PostProcess id in the pipeline
  113865. */
  113866. LensDepthOfFieldEffect: string;
  113867. private _scene;
  113868. private _depthTexture;
  113869. private _grainTexture;
  113870. private _chromaticAberrationPostProcess;
  113871. private _highlightsPostProcess;
  113872. private _depthOfFieldPostProcess;
  113873. private _edgeBlur;
  113874. private _grainAmount;
  113875. private _chromaticAberration;
  113876. private _distortion;
  113877. private _highlightsGain;
  113878. private _highlightsThreshold;
  113879. private _dofDistance;
  113880. private _dofAperture;
  113881. private _dofDarken;
  113882. private _dofPentagon;
  113883. private _blurNoise;
  113884. /**
  113885. * @constructor
  113886. *
  113887. * Effect parameters are as follow:
  113888. * {
  113889. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113890. * edge_blur: number; // from 0 to x (1 for realism)
  113891. * distortion: number; // from 0 to x (1 for realism)
  113892. * grain_amount: number; // from 0 to 1
  113893. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113894. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113895. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113896. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113897. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113898. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113899. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113900. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113901. * }
  113902. * Note: if an effect parameter is unset, effect is disabled
  113903. *
  113904. * @param name The rendering pipeline name
  113905. * @param parameters - An object containing all parameters (see above)
  113906. * @param scene The scene linked to this pipeline
  113907. * @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)
  113908. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113909. */
  113910. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113911. /**
  113912. * Get the class name
  113913. * @returns "LensRenderingPipeline"
  113914. */
  113915. getClassName(): string;
  113916. /**
  113917. * Gets associated scene
  113918. */
  113919. readonly scene: Scene;
  113920. /**
  113921. * Gets or sets the edge blur
  113922. */
  113923. edgeBlur: number;
  113924. /**
  113925. * Gets or sets the grain amount
  113926. */
  113927. grainAmount: number;
  113928. /**
  113929. * Gets or sets the chromatic aberration amount
  113930. */
  113931. chromaticAberration: number;
  113932. /**
  113933. * Gets or sets the depth of field aperture
  113934. */
  113935. dofAperture: number;
  113936. /**
  113937. * Gets or sets the edge distortion
  113938. */
  113939. edgeDistortion: number;
  113940. /**
  113941. * Gets or sets the depth of field distortion
  113942. */
  113943. dofDistortion: number;
  113944. /**
  113945. * Gets or sets the darken out of focus amount
  113946. */
  113947. darkenOutOfFocus: number;
  113948. /**
  113949. * Gets or sets a boolean indicating if blur noise is enabled
  113950. */
  113951. blurNoise: boolean;
  113952. /**
  113953. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113954. */
  113955. pentagonBokeh: boolean;
  113956. /**
  113957. * Gets or sets the highlight grain amount
  113958. */
  113959. highlightsGain: number;
  113960. /**
  113961. * Gets or sets the highlight threshold
  113962. */
  113963. highlightsThreshold: number;
  113964. /**
  113965. * Sets the amount of blur at the edges
  113966. * @param amount blur amount
  113967. */
  113968. setEdgeBlur(amount: number): void;
  113969. /**
  113970. * Sets edge blur to 0
  113971. */
  113972. disableEdgeBlur(): void;
  113973. /**
  113974. * Sets the amout of grain
  113975. * @param amount Amount of grain
  113976. */
  113977. setGrainAmount(amount: number): void;
  113978. /**
  113979. * Set grain amount to 0
  113980. */
  113981. disableGrain(): void;
  113982. /**
  113983. * Sets the chromatic aberration amount
  113984. * @param amount amount of chromatic aberration
  113985. */
  113986. setChromaticAberration(amount: number): void;
  113987. /**
  113988. * Sets chromatic aberration amount to 0
  113989. */
  113990. disableChromaticAberration(): void;
  113991. /**
  113992. * Sets the EdgeDistortion amount
  113993. * @param amount amount of EdgeDistortion
  113994. */
  113995. setEdgeDistortion(amount: number): void;
  113996. /**
  113997. * Sets edge distortion to 0
  113998. */
  113999. disableEdgeDistortion(): void;
  114000. /**
  114001. * Sets the FocusDistance amount
  114002. * @param amount amount of FocusDistance
  114003. */
  114004. setFocusDistance(amount: number): void;
  114005. /**
  114006. * Disables depth of field
  114007. */
  114008. disableDepthOfField(): void;
  114009. /**
  114010. * Sets the Aperture amount
  114011. * @param amount amount of Aperture
  114012. */
  114013. setAperture(amount: number): void;
  114014. /**
  114015. * Sets the DarkenOutOfFocus amount
  114016. * @param amount amount of DarkenOutOfFocus
  114017. */
  114018. setDarkenOutOfFocus(amount: number): void;
  114019. private _pentagonBokehIsEnabled;
  114020. /**
  114021. * Creates a pentagon bokeh effect
  114022. */
  114023. enablePentagonBokeh(): void;
  114024. /**
  114025. * Disables the pentagon bokeh effect
  114026. */
  114027. disablePentagonBokeh(): void;
  114028. /**
  114029. * Enables noise blur
  114030. */
  114031. enableNoiseBlur(): void;
  114032. /**
  114033. * Disables noise blur
  114034. */
  114035. disableNoiseBlur(): void;
  114036. /**
  114037. * Sets the HighlightsGain amount
  114038. * @param amount amount of HighlightsGain
  114039. */
  114040. setHighlightsGain(amount: number): void;
  114041. /**
  114042. * Sets the HighlightsThreshold amount
  114043. * @param amount amount of HighlightsThreshold
  114044. */
  114045. setHighlightsThreshold(amount: number): void;
  114046. /**
  114047. * Disables highlights
  114048. */
  114049. disableHighlights(): void;
  114050. /**
  114051. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  114052. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  114053. */
  114054. dispose(disableDepthRender?: boolean): void;
  114055. private _createChromaticAberrationPostProcess;
  114056. private _createHighlightsPostProcess;
  114057. private _createDepthOfFieldPostProcess;
  114058. private _createGrainTexture;
  114059. }
  114060. }
  114061. declare module BABYLON {
  114062. /** @hidden */
  114063. export var ssao2PixelShader: {
  114064. name: string;
  114065. shader: string;
  114066. };
  114067. }
  114068. declare module BABYLON {
  114069. /** @hidden */
  114070. export var ssaoCombinePixelShader: {
  114071. name: string;
  114072. shader: string;
  114073. };
  114074. }
  114075. declare module BABYLON {
  114076. /**
  114077. * Render pipeline to produce ssao effect
  114078. */
  114079. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  114080. /**
  114081. * @ignore
  114082. * The PassPostProcess id in the pipeline that contains the original scene color
  114083. */
  114084. SSAOOriginalSceneColorEffect: string;
  114085. /**
  114086. * @ignore
  114087. * The SSAO PostProcess id in the pipeline
  114088. */
  114089. SSAORenderEffect: string;
  114090. /**
  114091. * @ignore
  114092. * The horizontal blur PostProcess id in the pipeline
  114093. */
  114094. SSAOBlurHRenderEffect: string;
  114095. /**
  114096. * @ignore
  114097. * The vertical blur PostProcess id in the pipeline
  114098. */
  114099. SSAOBlurVRenderEffect: string;
  114100. /**
  114101. * @ignore
  114102. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114103. */
  114104. SSAOCombineRenderEffect: string;
  114105. /**
  114106. * The output strength of the SSAO post-process. Default value is 1.0.
  114107. */
  114108. totalStrength: number;
  114109. /**
  114110. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  114111. */
  114112. maxZ: number;
  114113. /**
  114114. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  114115. */
  114116. minZAspect: number;
  114117. private _samples;
  114118. /**
  114119. * Number of samples used for the SSAO calculations. Default value is 8
  114120. */
  114121. samples: number;
  114122. private _textureSamples;
  114123. /**
  114124. * Number of samples to use for antialiasing
  114125. */
  114126. textureSamples: number;
  114127. /**
  114128. * Ratio object used for SSAO ratio and blur ratio
  114129. */
  114130. private _ratio;
  114131. /**
  114132. * Dynamically generated sphere sampler.
  114133. */
  114134. private _sampleSphere;
  114135. /**
  114136. * Blur filter offsets
  114137. */
  114138. private _samplerOffsets;
  114139. private _expensiveBlur;
  114140. /**
  114141. * If bilateral blur should be used
  114142. */
  114143. expensiveBlur: boolean;
  114144. /**
  114145. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  114146. */
  114147. radius: number;
  114148. /**
  114149. * The base color of the SSAO post-process
  114150. * The final result is "base + ssao" between [0, 1]
  114151. */
  114152. base: number;
  114153. /**
  114154. * Support test.
  114155. */
  114156. static readonly IsSupported: boolean;
  114157. private _scene;
  114158. private _depthTexture;
  114159. private _normalTexture;
  114160. private _randomTexture;
  114161. private _originalColorPostProcess;
  114162. private _ssaoPostProcess;
  114163. private _blurHPostProcess;
  114164. private _blurVPostProcess;
  114165. private _ssaoCombinePostProcess;
  114166. private _firstUpdate;
  114167. /**
  114168. * Gets active scene
  114169. */
  114170. readonly scene: Scene;
  114171. /**
  114172. * @constructor
  114173. * @param name The rendering pipeline name
  114174. * @param scene The scene linked to this pipeline
  114175. * @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 }
  114176. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114177. */
  114178. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114179. /**
  114180. * Get the class name
  114181. * @returns "SSAO2RenderingPipeline"
  114182. */
  114183. getClassName(): string;
  114184. /**
  114185. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114186. */
  114187. dispose(disableGeometryBufferRenderer?: boolean): void;
  114188. private _createBlurPostProcess;
  114189. /** @hidden */
  114190. _rebuild(): void;
  114191. private _bits;
  114192. private _radicalInverse_VdC;
  114193. private _hammersley;
  114194. private _hemisphereSample_uniform;
  114195. private _generateHemisphere;
  114196. private _createSSAOPostProcess;
  114197. private _createSSAOCombinePostProcess;
  114198. private _createRandomTexture;
  114199. /**
  114200. * Serialize the rendering pipeline (Used when exporting)
  114201. * @returns the serialized object
  114202. */
  114203. serialize(): any;
  114204. /**
  114205. * Parse the serialized pipeline
  114206. * @param source Source pipeline.
  114207. * @param scene The scene to load the pipeline to.
  114208. * @param rootUrl The URL of the serialized pipeline.
  114209. * @returns An instantiated pipeline from the serialized object.
  114210. */
  114211. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  114212. }
  114213. }
  114214. declare module BABYLON {
  114215. /** @hidden */
  114216. export var ssaoPixelShader: {
  114217. name: string;
  114218. shader: string;
  114219. };
  114220. }
  114221. declare module BABYLON {
  114222. /**
  114223. * Render pipeline to produce ssao effect
  114224. */
  114225. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  114226. /**
  114227. * @ignore
  114228. * The PassPostProcess id in the pipeline that contains the original scene color
  114229. */
  114230. SSAOOriginalSceneColorEffect: string;
  114231. /**
  114232. * @ignore
  114233. * The SSAO PostProcess id in the pipeline
  114234. */
  114235. SSAORenderEffect: string;
  114236. /**
  114237. * @ignore
  114238. * The horizontal blur PostProcess id in the pipeline
  114239. */
  114240. SSAOBlurHRenderEffect: string;
  114241. /**
  114242. * @ignore
  114243. * The vertical blur PostProcess id in the pipeline
  114244. */
  114245. SSAOBlurVRenderEffect: string;
  114246. /**
  114247. * @ignore
  114248. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114249. */
  114250. SSAOCombineRenderEffect: string;
  114251. /**
  114252. * The output strength of the SSAO post-process. Default value is 1.0.
  114253. */
  114254. totalStrength: number;
  114255. /**
  114256. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114257. */
  114258. radius: number;
  114259. /**
  114260. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114261. * Must not be equal to fallOff and superior to fallOff.
  114262. * Default value is 0.0075
  114263. */
  114264. area: number;
  114265. /**
  114266. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114267. * Must not be equal to area and inferior to area.
  114268. * Default value is 0.000001
  114269. */
  114270. fallOff: number;
  114271. /**
  114272. * The base color of the SSAO post-process
  114273. * The final result is "base + ssao" between [0, 1]
  114274. */
  114275. base: number;
  114276. private _scene;
  114277. private _depthTexture;
  114278. private _randomTexture;
  114279. private _originalColorPostProcess;
  114280. private _ssaoPostProcess;
  114281. private _blurHPostProcess;
  114282. private _blurVPostProcess;
  114283. private _ssaoCombinePostProcess;
  114284. private _firstUpdate;
  114285. /**
  114286. * Gets active scene
  114287. */
  114288. readonly scene: Scene;
  114289. /**
  114290. * @constructor
  114291. * @param name - The rendering pipeline name
  114292. * @param scene - The scene linked to this pipeline
  114293. * @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 }
  114294. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114295. */
  114296. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114297. /**
  114298. * Get the class name
  114299. * @returns "SSAORenderingPipeline"
  114300. */
  114301. getClassName(): string;
  114302. /**
  114303. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114304. */
  114305. dispose(disableDepthRender?: boolean): void;
  114306. private _createBlurPostProcess;
  114307. /** @hidden */
  114308. _rebuild(): void;
  114309. private _createSSAOPostProcess;
  114310. private _createSSAOCombinePostProcess;
  114311. private _createRandomTexture;
  114312. }
  114313. }
  114314. declare module BABYLON {
  114315. /** @hidden */
  114316. export var standardPixelShader: {
  114317. name: string;
  114318. shader: string;
  114319. };
  114320. }
  114321. declare module BABYLON {
  114322. /**
  114323. * Standard rendering pipeline
  114324. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114325. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114326. */
  114327. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114328. /**
  114329. * Public members
  114330. */
  114331. /**
  114332. * Post-process which contains the original scene color before the pipeline applies all the effects
  114333. */
  114334. originalPostProcess: Nullable<PostProcess>;
  114335. /**
  114336. * Post-process used to down scale an image x4
  114337. */
  114338. downSampleX4PostProcess: Nullable<PostProcess>;
  114339. /**
  114340. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114341. */
  114342. brightPassPostProcess: Nullable<PostProcess>;
  114343. /**
  114344. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114345. */
  114346. blurHPostProcesses: PostProcess[];
  114347. /**
  114348. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114349. */
  114350. blurVPostProcesses: PostProcess[];
  114351. /**
  114352. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114353. */
  114354. textureAdderPostProcess: Nullable<PostProcess>;
  114355. /**
  114356. * Post-process used to create volumetric lighting effect
  114357. */
  114358. volumetricLightPostProcess: Nullable<PostProcess>;
  114359. /**
  114360. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114361. */
  114362. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114363. /**
  114364. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114365. */
  114366. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114367. /**
  114368. * Post-process used to merge the volumetric light effect and the real scene color
  114369. */
  114370. volumetricLightMergePostProces: Nullable<PostProcess>;
  114371. /**
  114372. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114373. */
  114374. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114375. /**
  114376. * Base post-process used to calculate the average luminance of the final image for HDR
  114377. */
  114378. luminancePostProcess: Nullable<PostProcess>;
  114379. /**
  114380. * Post-processes used to create down sample post-processes in order to get
  114381. * the average luminance of the final image for HDR
  114382. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114383. */
  114384. luminanceDownSamplePostProcesses: PostProcess[];
  114385. /**
  114386. * Post-process used to create a HDR effect (light adaptation)
  114387. */
  114388. hdrPostProcess: Nullable<PostProcess>;
  114389. /**
  114390. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114391. */
  114392. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114393. /**
  114394. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114395. */
  114396. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114397. /**
  114398. * Post-process used to merge the final HDR post-process and the real scene color
  114399. */
  114400. hdrFinalPostProcess: Nullable<PostProcess>;
  114401. /**
  114402. * Post-process used to create a lens flare effect
  114403. */
  114404. lensFlarePostProcess: Nullable<PostProcess>;
  114405. /**
  114406. * Post-process that merges the result of the lens flare post-process and the real scene color
  114407. */
  114408. lensFlareComposePostProcess: Nullable<PostProcess>;
  114409. /**
  114410. * Post-process used to create a motion blur effect
  114411. */
  114412. motionBlurPostProcess: Nullable<PostProcess>;
  114413. /**
  114414. * Post-process used to create a depth of field effect
  114415. */
  114416. depthOfFieldPostProcess: Nullable<PostProcess>;
  114417. /**
  114418. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114419. */
  114420. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114421. /**
  114422. * Represents the brightness threshold in order to configure the illuminated surfaces
  114423. */
  114424. brightThreshold: number;
  114425. /**
  114426. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114427. */
  114428. blurWidth: number;
  114429. /**
  114430. * Sets if the blur for highlighted surfaces must be only horizontal
  114431. */
  114432. horizontalBlur: boolean;
  114433. /**
  114434. * Gets the overall exposure used by the pipeline
  114435. */
  114436. /**
  114437. * Sets the overall exposure used by the pipeline
  114438. */
  114439. exposure: number;
  114440. /**
  114441. * Texture used typically to simulate "dirty" on camera lens
  114442. */
  114443. lensTexture: Nullable<Texture>;
  114444. /**
  114445. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114446. */
  114447. volumetricLightCoefficient: number;
  114448. /**
  114449. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114450. */
  114451. volumetricLightPower: number;
  114452. /**
  114453. * Used the set the blur intensity to smooth the volumetric lights
  114454. */
  114455. volumetricLightBlurScale: number;
  114456. /**
  114457. * Light (spot or directional) used to generate the volumetric lights rays
  114458. * The source light must have a shadow generate so the pipeline can get its
  114459. * depth map
  114460. */
  114461. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114462. /**
  114463. * For eye adaptation, represents the minimum luminance the eye can see
  114464. */
  114465. hdrMinimumLuminance: number;
  114466. /**
  114467. * For eye adaptation, represents the decrease luminance speed
  114468. */
  114469. hdrDecreaseRate: number;
  114470. /**
  114471. * For eye adaptation, represents the increase luminance speed
  114472. */
  114473. hdrIncreaseRate: number;
  114474. /**
  114475. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114476. */
  114477. /**
  114478. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114479. */
  114480. hdrAutoExposure: boolean;
  114481. /**
  114482. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114483. */
  114484. lensColorTexture: Nullable<Texture>;
  114485. /**
  114486. * The overall strengh for the lens flare effect
  114487. */
  114488. lensFlareStrength: number;
  114489. /**
  114490. * Dispersion coefficient for lens flare ghosts
  114491. */
  114492. lensFlareGhostDispersal: number;
  114493. /**
  114494. * Main lens flare halo width
  114495. */
  114496. lensFlareHaloWidth: number;
  114497. /**
  114498. * Based on the lens distortion effect, defines how much the lens flare result
  114499. * is distorted
  114500. */
  114501. lensFlareDistortionStrength: number;
  114502. /**
  114503. * Lens star texture must be used to simulate rays on the flares and is available
  114504. * in the documentation
  114505. */
  114506. lensStarTexture: Nullable<Texture>;
  114507. /**
  114508. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114509. * flare effect by taking account of the dirt texture
  114510. */
  114511. lensFlareDirtTexture: Nullable<Texture>;
  114512. /**
  114513. * Represents the focal length for the depth of field effect
  114514. */
  114515. depthOfFieldDistance: number;
  114516. /**
  114517. * Represents the blur intensity for the blurred part of the depth of field effect
  114518. */
  114519. depthOfFieldBlurWidth: number;
  114520. /**
  114521. * For motion blur, defines how much the image is blurred by the movement
  114522. */
  114523. motionStrength: number;
  114524. /**
  114525. * List of animations for the pipeline (IAnimatable implementation)
  114526. */
  114527. animations: Animation[];
  114528. /**
  114529. * Private members
  114530. */
  114531. private _scene;
  114532. private _currentDepthOfFieldSource;
  114533. private _basePostProcess;
  114534. private _fixedExposure;
  114535. private _currentExposure;
  114536. private _hdrAutoExposure;
  114537. private _hdrCurrentLuminance;
  114538. private _floatTextureType;
  114539. private _ratio;
  114540. private _bloomEnabled;
  114541. private _depthOfFieldEnabled;
  114542. private _vlsEnabled;
  114543. private _lensFlareEnabled;
  114544. private _hdrEnabled;
  114545. private _motionBlurEnabled;
  114546. private _fxaaEnabled;
  114547. private _motionBlurSamples;
  114548. private _volumetricLightStepsCount;
  114549. private _samples;
  114550. /**
  114551. * @ignore
  114552. * Specifies if the bloom pipeline is enabled
  114553. */
  114554. BloomEnabled: boolean;
  114555. /**
  114556. * @ignore
  114557. * Specifies if the depth of field pipeline is enabed
  114558. */
  114559. DepthOfFieldEnabled: boolean;
  114560. /**
  114561. * @ignore
  114562. * Specifies if the lens flare pipeline is enabed
  114563. */
  114564. LensFlareEnabled: boolean;
  114565. /**
  114566. * @ignore
  114567. * Specifies if the HDR pipeline is enabled
  114568. */
  114569. HDREnabled: boolean;
  114570. /**
  114571. * @ignore
  114572. * Specifies if the volumetric lights scattering effect is enabled
  114573. */
  114574. VLSEnabled: boolean;
  114575. /**
  114576. * @ignore
  114577. * Specifies if the motion blur effect is enabled
  114578. */
  114579. MotionBlurEnabled: boolean;
  114580. /**
  114581. * Specifies if anti-aliasing is enabled
  114582. */
  114583. fxaaEnabled: boolean;
  114584. /**
  114585. * Specifies the number of steps used to calculate the volumetric lights
  114586. * Typically in interval [50, 200]
  114587. */
  114588. volumetricLightStepsCount: number;
  114589. /**
  114590. * Specifies the number of samples used for the motion blur effect
  114591. * Typically in interval [16, 64]
  114592. */
  114593. motionBlurSamples: number;
  114594. /**
  114595. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114596. */
  114597. samples: number;
  114598. /**
  114599. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114600. * @constructor
  114601. * @param name The rendering pipeline name
  114602. * @param scene The scene linked to this pipeline
  114603. * @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)
  114604. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114605. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114606. */
  114607. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114608. private _buildPipeline;
  114609. private _createDownSampleX4PostProcess;
  114610. private _createBrightPassPostProcess;
  114611. private _createBlurPostProcesses;
  114612. private _createTextureAdderPostProcess;
  114613. private _createVolumetricLightPostProcess;
  114614. private _createLuminancePostProcesses;
  114615. private _createHdrPostProcess;
  114616. private _createLensFlarePostProcess;
  114617. private _createDepthOfFieldPostProcess;
  114618. private _createMotionBlurPostProcess;
  114619. private _getDepthTexture;
  114620. private _disposePostProcesses;
  114621. /**
  114622. * Dispose of the pipeline and stop all post processes
  114623. */
  114624. dispose(): void;
  114625. /**
  114626. * Serialize the rendering pipeline (Used when exporting)
  114627. * @returns the serialized object
  114628. */
  114629. serialize(): any;
  114630. /**
  114631. * Parse the serialized pipeline
  114632. * @param source Source pipeline.
  114633. * @param scene The scene to load the pipeline to.
  114634. * @param rootUrl The URL of the serialized pipeline.
  114635. * @returns An instantiated pipeline from the serialized object.
  114636. */
  114637. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114638. /**
  114639. * Luminance steps
  114640. */
  114641. static LuminanceSteps: number;
  114642. }
  114643. }
  114644. declare module BABYLON {
  114645. /** @hidden */
  114646. export var tonemapPixelShader: {
  114647. name: string;
  114648. shader: string;
  114649. };
  114650. }
  114651. declare module BABYLON {
  114652. /** Defines operator used for tonemapping */
  114653. export enum TonemappingOperator {
  114654. /** Hable */
  114655. Hable = 0,
  114656. /** Reinhard */
  114657. Reinhard = 1,
  114658. /** HejiDawson */
  114659. HejiDawson = 2,
  114660. /** Photographic */
  114661. Photographic = 3
  114662. }
  114663. /**
  114664. * Defines a post process to apply tone mapping
  114665. */
  114666. export class TonemapPostProcess extends PostProcess {
  114667. private _operator;
  114668. /** Defines the required exposure adjustement */
  114669. exposureAdjustment: number;
  114670. /**
  114671. * Creates a new TonemapPostProcess
  114672. * @param name defines the name of the postprocess
  114673. * @param _operator defines the operator to use
  114674. * @param exposureAdjustment defines the required exposure adjustement
  114675. * @param camera defines the camera to use (can be null)
  114676. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114677. * @param engine defines the hosting engine (can be ignore if camera is set)
  114678. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114679. */
  114680. constructor(name: string, _operator: TonemappingOperator,
  114681. /** Defines the required exposure adjustement */
  114682. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114683. }
  114684. }
  114685. declare module BABYLON {
  114686. /** @hidden */
  114687. export var depthVertexShader: {
  114688. name: string;
  114689. shader: string;
  114690. };
  114691. }
  114692. declare module BABYLON {
  114693. /** @hidden */
  114694. export var volumetricLightScatteringPixelShader: {
  114695. name: string;
  114696. shader: string;
  114697. };
  114698. }
  114699. declare module BABYLON {
  114700. /** @hidden */
  114701. export var volumetricLightScatteringPassPixelShader: {
  114702. name: string;
  114703. shader: string;
  114704. };
  114705. }
  114706. declare module BABYLON {
  114707. /**
  114708. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114709. */
  114710. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114711. private _volumetricLightScatteringPass;
  114712. private _volumetricLightScatteringRTT;
  114713. private _viewPort;
  114714. private _screenCoordinates;
  114715. private _cachedDefines;
  114716. /**
  114717. * If not undefined, the mesh position is computed from the attached node position
  114718. */
  114719. attachedNode: {
  114720. position: Vector3;
  114721. };
  114722. /**
  114723. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114724. */
  114725. customMeshPosition: Vector3;
  114726. /**
  114727. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114728. */
  114729. useCustomMeshPosition: boolean;
  114730. /**
  114731. * If the post-process should inverse the light scattering direction
  114732. */
  114733. invert: boolean;
  114734. /**
  114735. * The internal mesh used by the post-process
  114736. */
  114737. mesh: Mesh;
  114738. /**
  114739. * @hidden
  114740. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114741. */
  114742. useDiffuseColor: boolean;
  114743. /**
  114744. * Array containing the excluded meshes not rendered in the internal pass
  114745. */
  114746. excludedMeshes: AbstractMesh[];
  114747. /**
  114748. * Controls the overall intensity of the post-process
  114749. */
  114750. exposure: number;
  114751. /**
  114752. * Dissipates each sample's contribution in range [0, 1]
  114753. */
  114754. decay: number;
  114755. /**
  114756. * Controls the overall intensity of each sample
  114757. */
  114758. weight: number;
  114759. /**
  114760. * Controls the density of each sample
  114761. */
  114762. density: number;
  114763. /**
  114764. * @constructor
  114765. * @param name The post-process name
  114766. * @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)
  114767. * @param camera The camera that the post-process will be attached to
  114768. * @param mesh The mesh used to create the light scattering
  114769. * @param samples The post-process quality, default 100
  114770. * @param samplingModeThe post-process filtering mode
  114771. * @param engine The babylon engine
  114772. * @param reusable If the post-process is reusable
  114773. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114774. */
  114775. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114776. /**
  114777. * Returns the string "VolumetricLightScatteringPostProcess"
  114778. * @returns "VolumetricLightScatteringPostProcess"
  114779. */
  114780. getClassName(): string;
  114781. private _isReady;
  114782. /**
  114783. * Sets the new light position for light scattering effect
  114784. * @param position The new custom light position
  114785. */
  114786. setCustomMeshPosition(position: Vector3): void;
  114787. /**
  114788. * Returns the light position for light scattering effect
  114789. * @return Vector3 The custom light position
  114790. */
  114791. getCustomMeshPosition(): Vector3;
  114792. /**
  114793. * Disposes the internal assets and detaches the post-process from the camera
  114794. */
  114795. dispose(camera: Camera): void;
  114796. /**
  114797. * Returns the render target texture used by the post-process
  114798. * @return the render target texture used by the post-process
  114799. */
  114800. getPass(): RenderTargetTexture;
  114801. private _meshExcluded;
  114802. private _createPass;
  114803. private _updateMeshScreenCoordinates;
  114804. /**
  114805. * Creates a default mesh for the Volumeric Light Scattering post-process
  114806. * @param name The mesh name
  114807. * @param scene The scene where to create the mesh
  114808. * @return the default mesh
  114809. */
  114810. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114811. }
  114812. }
  114813. declare module BABYLON {
  114814. interface Scene {
  114815. /** @hidden (Backing field) */
  114816. _boundingBoxRenderer: BoundingBoxRenderer;
  114817. /** @hidden (Backing field) */
  114818. _forceShowBoundingBoxes: boolean;
  114819. /**
  114820. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114821. */
  114822. forceShowBoundingBoxes: boolean;
  114823. /**
  114824. * Gets the bounding box renderer associated with the scene
  114825. * @returns a BoundingBoxRenderer
  114826. */
  114827. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114828. }
  114829. interface AbstractMesh {
  114830. /** @hidden (Backing field) */
  114831. _showBoundingBox: boolean;
  114832. /**
  114833. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114834. */
  114835. showBoundingBox: boolean;
  114836. }
  114837. /**
  114838. * Component responsible of rendering the bounding box of the meshes in a scene.
  114839. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114840. */
  114841. export class BoundingBoxRenderer implements ISceneComponent {
  114842. /**
  114843. * The component name helpfull to identify the component in the list of scene components.
  114844. */
  114845. readonly name: string;
  114846. /**
  114847. * The scene the component belongs to.
  114848. */
  114849. scene: Scene;
  114850. /**
  114851. * Color of the bounding box lines placed in front of an object
  114852. */
  114853. frontColor: Color3;
  114854. /**
  114855. * Color of the bounding box lines placed behind an object
  114856. */
  114857. backColor: Color3;
  114858. /**
  114859. * Defines if the renderer should show the back lines or not
  114860. */
  114861. showBackLines: boolean;
  114862. /**
  114863. * @hidden
  114864. */
  114865. renderList: SmartArray<BoundingBox>;
  114866. private _colorShader;
  114867. private _vertexBuffers;
  114868. private _indexBuffer;
  114869. /**
  114870. * Instantiates a new bounding box renderer in a scene.
  114871. * @param scene the scene the renderer renders in
  114872. */
  114873. constructor(scene: Scene);
  114874. /**
  114875. * Registers the component in a given scene
  114876. */
  114877. register(): void;
  114878. private _evaluateSubMesh;
  114879. private _activeMesh;
  114880. private _prepareRessources;
  114881. private _createIndexBuffer;
  114882. /**
  114883. * Rebuilds the elements related to this component in case of
  114884. * context lost for instance.
  114885. */
  114886. rebuild(): void;
  114887. /**
  114888. * @hidden
  114889. */
  114890. reset(): void;
  114891. /**
  114892. * Render the bounding boxes of a specific rendering group
  114893. * @param renderingGroupId defines the rendering group to render
  114894. */
  114895. render(renderingGroupId: number): void;
  114896. /**
  114897. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114898. * @param mesh Define the mesh to render the occlusion bounding box for
  114899. */
  114900. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114901. /**
  114902. * Dispose and release the resources attached to this renderer.
  114903. */
  114904. dispose(): void;
  114905. }
  114906. }
  114907. declare module BABYLON {
  114908. /** @hidden */
  114909. export var depthPixelShader: {
  114910. name: string;
  114911. shader: string;
  114912. };
  114913. }
  114914. declare module BABYLON {
  114915. /**
  114916. * This represents a depth renderer in Babylon.
  114917. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114918. */
  114919. export class DepthRenderer {
  114920. private _scene;
  114921. private _depthMap;
  114922. private _effect;
  114923. private _cachedDefines;
  114924. private _camera;
  114925. /**
  114926. * Specifiess that the depth renderer will only be used within
  114927. * the camera it is created for.
  114928. * This can help forcing its rendering during the camera processing.
  114929. */
  114930. useOnlyInActiveCamera: boolean;
  114931. /** @hidden */
  114932. static _SceneComponentInitialization: (scene: Scene) => void;
  114933. /**
  114934. * Instantiates a depth renderer
  114935. * @param scene The scene the renderer belongs to
  114936. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114937. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114938. */
  114939. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114940. /**
  114941. * Creates the depth rendering effect and checks if the effect is ready.
  114942. * @param subMesh The submesh to be used to render the depth map of
  114943. * @param useInstances If multiple world instances should be used
  114944. * @returns if the depth renderer is ready to render the depth map
  114945. */
  114946. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114947. /**
  114948. * Gets the texture which the depth map will be written to.
  114949. * @returns The depth map texture
  114950. */
  114951. getDepthMap(): RenderTargetTexture;
  114952. /**
  114953. * Disposes of the depth renderer.
  114954. */
  114955. dispose(): void;
  114956. }
  114957. }
  114958. declare module BABYLON {
  114959. interface Scene {
  114960. /** @hidden (Backing field) */
  114961. _depthRenderer: {
  114962. [id: string]: DepthRenderer;
  114963. };
  114964. /**
  114965. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114966. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114967. * @returns the created depth renderer
  114968. */
  114969. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114970. /**
  114971. * Disables a depth renderer for a given camera
  114972. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114973. */
  114974. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114975. }
  114976. /**
  114977. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114978. * in several rendering techniques.
  114979. */
  114980. export class DepthRendererSceneComponent implements ISceneComponent {
  114981. /**
  114982. * The component name helpfull to identify the component in the list of scene components.
  114983. */
  114984. readonly name: string;
  114985. /**
  114986. * The scene the component belongs to.
  114987. */
  114988. scene: Scene;
  114989. /**
  114990. * Creates a new instance of the component for the given scene
  114991. * @param scene Defines the scene to register the component in
  114992. */
  114993. constructor(scene: Scene);
  114994. /**
  114995. * Registers the component in a given scene
  114996. */
  114997. register(): void;
  114998. /**
  114999. * Rebuilds the elements related to this component in case of
  115000. * context lost for instance.
  115001. */
  115002. rebuild(): void;
  115003. /**
  115004. * Disposes the component and the associated ressources
  115005. */
  115006. dispose(): void;
  115007. private _gatherRenderTargets;
  115008. private _gatherActiveCameraRenderTargets;
  115009. }
  115010. }
  115011. declare module BABYLON {
  115012. /** @hidden */
  115013. export var outlinePixelShader: {
  115014. name: string;
  115015. shader: string;
  115016. };
  115017. }
  115018. declare module BABYLON {
  115019. /** @hidden */
  115020. export var outlineVertexShader: {
  115021. name: string;
  115022. shader: string;
  115023. };
  115024. }
  115025. declare module BABYLON {
  115026. interface Scene {
  115027. /** @hidden */
  115028. _outlineRenderer: OutlineRenderer;
  115029. /**
  115030. * Gets the outline renderer associated with the scene
  115031. * @returns a OutlineRenderer
  115032. */
  115033. getOutlineRenderer(): OutlineRenderer;
  115034. }
  115035. interface AbstractMesh {
  115036. /** @hidden (Backing field) */
  115037. _renderOutline: boolean;
  115038. /**
  115039. * Gets or sets a boolean indicating if the outline must be rendered as well
  115040. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  115041. */
  115042. renderOutline: boolean;
  115043. /** @hidden (Backing field) */
  115044. _renderOverlay: boolean;
  115045. /**
  115046. * Gets or sets a boolean indicating if the overlay must be rendered as well
  115047. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  115048. */
  115049. renderOverlay: boolean;
  115050. }
  115051. /**
  115052. * This class is responsible to draw bothe outline/overlay of meshes.
  115053. * It should not be used directly but through the available method on mesh.
  115054. */
  115055. export class OutlineRenderer implements ISceneComponent {
  115056. /**
  115057. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  115058. */
  115059. private static _StencilReference;
  115060. /**
  115061. * The name of the component. Each component must have a unique name.
  115062. */
  115063. name: string;
  115064. /**
  115065. * The scene the component belongs to.
  115066. */
  115067. scene: Scene;
  115068. /**
  115069. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  115070. */
  115071. zOffset: number;
  115072. private _engine;
  115073. private _effect;
  115074. private _cachedDefines;
  115075. private _savedDepthWrite;
  115076. /**
  115077. * Instantiates a new outline renderer. (There could be only one per scene).
  115078. * @param scene Defines the scene it belongs to
  115079. */
  115080. constructor(scene: Scene);
  115081. /**
  115082. * Register the component to one instance of a scene.
  115083. */
  115084. register(): void;
  115085. /**
  115086. * Rebuilds the elements related to this component in case of
  115087. * context lost for instance.
  115088. */
  115089. rebuild(): void;
  115090. /**
  115091. * Disposes the component and the associated ressources.
  115092. */
  115093. dispose(): void;
  115094. /**
  115095. * Renders the outline in the canvas.
  115096. * @param subMesh Defines the sumesh to render
  115097. * @param batch Defines the batch of meshes in case of instances
  115098. * @param useOverlay Defines if the rendering is for the overlay or the outline
  115099. */
  115100. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  115101. /**
  115102. * Returns whether or not the outline renderer is ready for a given submesh.
  115103. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  115104. * @param subMesh Defines the submesh to check readyness for
  115105. * @param useInstances Defines wheter wee are trying to render instances or not
  115106. * @returns true if ready otherwise false
  115107. */
  115108. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115109. private _beforeRenderingMesh;
  115110. private _afterRenderingMesh;
  115111. }
  115112. }
  115113. declare module BABYLON {
  115114. /**
  115115. * Defines the list of states available for a task inside a AssetsManager
  115116. */
  115117. export enum AssetTaskState {
  115118. /**
  115119. * Initialization
  115120. */
  115121. INIT = 0,
  115122. /**
  115123. * Running
  115124. */
  115125. RUNNING = 1,
  115126. /**
  115127. * Done
  115128. */
  115129. DONE = 2,
  115130. /**
  115131. * Error
  115132. */
  115133. ERROR = 3
  115134. }
  115135. /**
  115136. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  115137. */
  115138. export abstract class AbstractAssetTask {
  115139. /**
  115140. * Task name
  115141. */ name: string;
  115142. /**
  115143. * Callback called when the task is successful
  115144. */
  115145. onSuccess: (task: any) => void;
  115146. /**
  115147. * Callback called when the task is not successful
  115148. */
  115149. onError: (task: any, message?: string, exception?: any) => void;
  115150. /**
  115151. * Creates a new AssetsManager
  115152. * @param name defines the name of the task
  115153. */
  115154. constructor(
  115155. /**
  115156. * Task name
  115157. */ name: string);
  115158. private _isCompleted;
  115159. private _taskState;
  115160. private _errorObject;
  115161. /**
  115162. * Get if the task is completed
  115163. */
  115164. readonly isCompleted: boolean;
  115165. /**
  115166. * Gets the current state of the task
  115167. */
  115168. readonly taskState: AssetTaskState;
  115169. /**
  115170. * Gets the current error object (if task is in error)
  115171. */
  115172. readonly errorObject: {
  115173. message?: string;
  115174. exception?: any;
  115175. };
  115176. /**
  115177. * Internal only
  115178. * @hidden
  115179. */
  115180. _setErrorObject(message?: string, exception?: any): void;
  115181. /**
  115182. * Execute the current task
  115183. * @param scene defines the scene where you want your assets to be loaded
  115184. * @param onSuccess is a callback called when the task is successfully executed
  115185. * @param onError is a callback called if an error occurs
  115186. */
  115187. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115188. /**
  115189. * Execute the current task
  115190. * @param scene defines the scene where you want your assets to be loaded
  115191. * @param onSuccess is a callback called when the task is successfully executed
  115192. * @param onError is a callback called if an error occurs
  115193. */
  115194. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115195. /**
  115196. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  115197. * This can be used with failed tasks that have the reason for failure fixed.
  115198. */
  115199. reset(): void;
  115200. private onErrorCallback;
  115201. private onDoneCallback;
  115202. }
  115203. /**
  115204. * Define the interface used by progress events raised during assets loading
  115205. */
  115206. export interface IAssetsProgressEvent {
  115207. /**
  115208. * Defines the number of remaining tasks to process
  115209. */
  115210. remainingCount: number;
  115211. /**
  115212. * Defines the total number of tasks
  115213. */
  115214. totalCount: number;
  115215. /**
  115216. * Defines the task that was just processed
  115217. */
  115218. task: AbstractAssetTask;
  115219. }
  115220. /**
  115221. * Class used to share progress information about assets loading
  115222. */
  115223. export class AssetsProgressEvent implements IAssetsProgressEvent {
  115224. /**
  115225. * Defines the number of remaining tasks to process
  115226. */
  115227. remainingCount: number;
  115228. /**
  115229. * Defines the total number of tasks
  115230. */
  115231. totalCount: number;
  115232. /**
  115233. * Defines the task that was just processed
  115234. */
  115235. task: AbstractAssetTask;
  115236. /**
  115237. * Creates a AssetsProgressEvent
  115238. * @param remainingCount defines the number of remaining tasks to process
  115239. * @param totalCount defines the total number of tasks
  115240. * @param task defines the task that was just processed
  115241. */
  115242. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115243. }
  115244. /**
  115245. * Define a task used by AssetsManager to load meshes
  115246. */
  115247. export class MeshAssetTask extends AbstractAssetTask {
  115248. /**
  115249. * Defines the name of the task
  115250. */
  115251. name: string;
  115252. /**
  115253. * Defines the list of mesh's names you want to load
  115254. */
  115255. meshesNames: any;
  115256. /**
  115257. * Defines the root url to use as a base to load your meshes and associated resources
  115258. */
  115259. rootUrl: string;
  115260. /**
  115261. * Defines the filename of the scene to load from
  115262. */
  115263. sceneFilename: string;
  115264. /**
  115265. * Gets the list of loaded meshes
  115266. */
  115267. loadedMeshes: Array<AbstractMesh>;
  115268. /**
  115269. * Gets the list of loaded particle systems
  115270. */
  115271. loadedParticleSystems: Array<IParticleSystem>;
  115272. /**
  115273. * Gets the list of loaded skeletons
  115274. */
  115275. loadedSkeletons: Array<Skeleton>;
  115276. /**
  115277. * Gets the list of loaded animation groups
  115278. */
  115279. loadedAnimationGroups: Array<AnimationGroup>;
  115280. /**
  115281. * Callback called when the task is successful
  115282. */
  115283. onSuccess: (task: MeshAssetTask) => void;
  115284. /**
  115285. * Callback called when the task is successful
  115286. */
  115287. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115288. /**
  115289. * Creates a new MeshAssetTask
  115290. * @param name defines the name of the task
  115291. * @param meshesNames defines the list of mesh's names you want to load
  115292. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115293. * @param sceneFilename defines the filename of the scene to load from
  115294. */
  115295. constructor(
  115296. /**
  115297. * Defines the name of the task
  115298. */
  115299. name: string,
  115300. /**
  115301. * Defines the list of mesh's names you want to load
  115302. */
  115303. meshesNames: any,
  115304. /**
  115305. * Defines the root url to use as a base to load your meshes and associated resources
  115306. */
  115307. rootUrl: string,
  115308. /**
  115309. * Defines the filename of the scene to load from
  115310. */
  115311. sceneFilename: string);
  115312. /**
  115313. * Execute the current task
  115314. * @param scene defines the scene where you want your assets to be loaded
  115315. * @param onSuccess is a callback called when the task is successfully executed
  115316. * @param onError is a callback called if an error occurs
  115317. */
  115318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115319. }
  115320. /**
  115321. * Define a task used by AssetsManager to load text content
  115322. */
  115323. export class TextFileAssetTask extends AbstractAssetTask {
  115324. /**
  115325. * Defines the name of the task
  115326. */
  115327. name: string;
  115328. /**
  115329. * Defines the location of the file to load
  115330. */
  115331. url: string;
  115332. /**
  115333. * Gets the loaded text string
  115334. */
  115335. text: string;
  115336. /**
  115337. * Callback called when the task is successful
  115338. */
  115339. onSuccess: (task: TextFileAssetTask) => void;
  115340. /**
  115341. * Callback called when the task is successful
  115342. */
  115343. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115344. /**
  115345. * Creates a new TextFileAssetTask object
  115346. * @param name defines the name of the task
  115347. * @param url defines the location of the file to load
  115348. */
  115349. constructor(
  115350. /**
  115351. * Defines the name of the task
  115352. */
  115353. name: string,
  115354. /**
  115355. * Defines the location of the file to load
  115356. */
  115357. url: string);
  115358. /**
  115359. * Execute the current task
  115360. * @param scene defines the scene where you want your assets to be loaded
  115361. * @param onSuccess is a callback called when the task is successfully executed
  115362. * @param onError is a callback called if an error occurs
  115363. */
  115364. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115365. }
  115366. /**
  115367. * Define a task used by AssetsManager to load binary data
  115368. */
  115369. export class BinaryFileAssetTask extends AbstractAssetTask {
  115370. /**
  115371. * Defines the name of the task
  115372. */
  115373. name: string;
  115374. /**
  115375. * Defines the location of the file to load
  115376. */
  115377. url: string;
  115378. /**
  115379. * Gets the lodaded data (as an array buffer)
  115380. */
  115381. data: ArrayBuffer;
  115382. /**
  115383. * Callback called when the task is successful
  115384. */
  115385. onSuccess: (task: BinaryFileAssetTask) => void;
  115386. /**
  115387. * Callback called when the task is successful
  115388. */
  115389. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115390. /**
  115391. * Creates a new BinaryFileAssetTask object
  115392. * @param name defines the name of the new task
  115393. * @param url defines the location of the file to load
  115394. */
  115395. constructor(
  115396. /**
  115397. * Defines the name of the task
  115398. */
  115399. name: string,
  115400. /**
  115401. * Defines the location of the file to load
  115402. */
  115403. url: string);
  115404. /**
  115405. * Execute the current task
  115406. * @param scene defines the scene where you want your assets to be loaded
  115407. * @param onSuccess is a callback called when the task is successfully executed
  115408. * @param onError is a callback called if an error occurs
  115409. */
  115410. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115411. }
  115412. /**
  115413. * Define a task used by AssetsManager to load images
  115414. */
  115415. export class ImageAssetTask extends AbstractAssetTask {
  115416. /**
  115417. * Defines the name of the task
  115418. */
  115419. name: string;
  115420. /**
  115421. * Defines the location of the image to load
  115422. */
  115423. url: string;
  115424. /**
  115425. * Gets the loaded images
  115426. */
  115427. image: HTMLImageElement;
  115428. /**
  115429. * Callback called when the task is successful
  115430. */
  115431. onSuccess: (task: ImageAssetTask) => void;
  115432. /**
  115433. * Callback called when the task is successful
  115434. */
  115435. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115436. /**
  115437. * Creates a new ImageAssetTask
  115438. * @param name defines the name of the task
  115439. * @param url defines the location of the image to load
  115440. */
  115441. constructor(
  115442. /**
  115443. * Defines the name of the task
  115444. */
  115445. name: string,
  115446. /**
  115447. * Defines the location of the image to load
  115448. */
  115449. url: string);
  115450. /**
  115451. * Execute the current task
  115452. * @param scene defines the scene where you want your assets to be loaded
  115453. * @param onSuccess is a callback called when the task is successfully executed
  115454. * @param onError is a callback called if an error occurs
  115455. */
  115456. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115457. }
  115458. /**
  115459. * Defines the interface used by texture loading tasks
  115460. */
  115461. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115462. /**
  115463. * Gets the loaded texture
  115464. */
  115465. texture: TEX;
  115466. }
  115467. /**
  115468. * Define a task used by AssetsManager to load 2D textures
  115469. */
  115470. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115471. /**
  115472. * Defines the name of the task
  115473. */
  115474. name: string;
  115475. /**
  115476. * Defines the location of the file to load
  115477. */
  115478. url: string;
  115479. /**
  115480. * Defines if mipmap should not be generated (default is false)
  115481. */
  115482. noMipmap?: boolean | undefined;
  115483. /**
  115484. * Defines if texture must be inverted on Y axis (default is false)
  115485. */
  115486. invertY?: boolean | undefined;
  115487. /**
  115488. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115489. */
  115490. samplingMode: number;
  115491. /**
  115492. * Gets the loaded texture
  115493. */
  115494. texture: Texture;
  115495. /**
  115496. * Callback called when the task is successful
  115497. */
  115498. onSuccess: (task: TextureAssetTask) => void;
  115499. /**
  115500. * Callback called when the task is successful
  115501. */
  115502. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115503. /**
  115504. * Creates a new TextureAssetTask object
  115505. * @param name defines the name of the task
  115506. * @param url defines the location of the file to load
  115507. * @param noMipmap defines if mipmap should not be generated (default is false)
  115508. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115509. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115510. */
  115511. constructor(
  115512. /**
  115513. * Defines the name of the task
  115514. */
  115515. name: string,
  115516. /**
  115517. * Defines the location of the file to load
  115518. */
  115519. url: string,
  115520. /**
  115521. * Defines if mipmap should not be generated (default is false)
  115522. */
  115523. noMipmap?: boolean | undefined,
  115524. /**
  115525. * Defines if texture must be inverted on Y axis (default is false)
  115526. */
  115527. invertY?: boolean | undefined,
  115528. /**
  115529. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115530. */
  115531. samplingMode?: number);
  115532. /**
  115533. * Execute the current task
  115534. * @param scene defines the scene where you want your assets to be loaded
  115535. * @param onSuccess is a callback called when the task is successfully executed
  115536. * @param onError is a callback called if an error occurs
  115537. */
  115538. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115539. }
  115540. /**
  115541. * Define a task used by AssetsManager to load cube textures
  115542. */
  115543. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115544. /**
  115545. * Defines the name of the task
  115546. */
  115547. name: string;
  115548. /**
  115549. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115550. */
  115551. url: string;
  115552. /**
  115553. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115554. */
  115555. extensions?: string[] | undefined;
  115556. /**
  115557. * Defines if mipmaps should not be generated (default is false)
  115558. */
  115559. noMipmap?: boolean | undefined;
  115560. /**
  115561. * Defines the explicit list of files (undefined by default)
  115562. */
  115563. files?: string[] | undefined;
  115564. /**
  115565. * Gets the loaded texture
  115566. */
  115567. texture: CubeTexture;
  115568. /**
  115569. * Callback called when the task is successful
  115570. */
  115571. onSuccess: (task: CubeTextureAssetTask) => void;
  115572. /**
  115573. * Callback called when the task is successful
  115574. */
  115575. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115576. /**
  115577. * Creates a new CubeTextureAssetTask
  115578. * @param name defines the name of the task
  115579. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115580. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115581. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115582. * @param files defines the explicit list of files (undefined by default)
  115583. */
  115584. constructor(
  115585. /**
  115586. * Defines the name of the task
  115587. */
  115588. name: string,
  115589. /**
  115590. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115591. */
  115592. url: string,
  115593. /**
  115594. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115595. */
  115596. extensions?: string[] | undefined,
  115597. /**
  115598. * Defines if mipmaps should not be generated (default is false)
  115599. */
  115600. noMipmap?: boolean | undefined,
  115601. /**
  115602. * Defines the explicit list of files (undefined by default)
  115603. */
  115604. files?: string[] | undefined);
  115605. /**
  115606. * Execute the current task
  115607. * @param scene defines the scene where you want your assets to be loaded
  115608. * @param onSuccess is a callback called when the task is successfully executed
  115609. * @param onError is a callback called if an error occurs
  115610. */
  115611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115612. }
  115613. /**
  115614. * Define a task used by AssetsManager to load HDR cube textures
  115615. */
  115616. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115617. /**
  115618. * Defines the name of the task
  115619. */
  115620. name: string;
  115621. /**
  115622. * Defines the location of the file to load
  115623. */
  115624. url: string;
  115625. /**
  115626. * Defines the desired size (the more it increases the longer the generation will be)
  115627. */
  115628. size: number;
  115629. /**
  115630. * Defines if mipmaps should not be generated (default is false)
  115631. */
  115632. noMipmap: boolean;
  115633. /**
  115634. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115635. */
  115636. generateHarmonics: boolean;
  115637. /**
  115638. * 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)
  115639. */
  115640. gammaSpace: boolean;
  115641. /**
  115642. * Internal Use Only
  115643. */
  115644. reserved: boolean;
  115645. /**
  115646. * Gets the loaded texture
  115647. */
  115648. texture: HDRCubeTexture;
  115649. /**
  115650. * Callback called when the task is successful
  115651. */
  115652. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115653. /**
  115654. * Callback called when the task is successful
  115655. */
  115656. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115657. /**
  115658. * Creates a new HDRCubeTextureAssetTask object
  115659. * @param name defines the name of the task
  115660. * @param url defines the location of the file to load
  115661. * @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.
  115662. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115663. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115664. * @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)
  115665. * @param reserved Internal use only
  115666. */
  115667. constructor(
  115668. /**
  115669. * Defines the name of the task
  115670. */
  115671. name: string,
  115672. /**
  115673. * Defines the location of the file to load
  115674. */
  115675. url: string,
  115676. /**
  115677. * Defines the desired size (the more it increases the longer the generation will be)
  115678. */
  115679. size: number,
  115680. /**
  115681. * Defines if mipmaps should not be generated (default is false)
  115682. */
  115683. noMipmap?: boolean,
  115684. /**
  115685. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115686. */
  115687. generateHarmonics?: boolean,
  115688. /**
  115689. * 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)
  115690. */
  115691. gammaSpace?: boolean,
  115692. /**
  115693. * Internal Use Only
  115694. */
  115695. reserved?: boolean);
  115696. /**
  115697. * Execute the current task
  115698. * @param scene defines the scene where you want your assets to be loaded
  115699. * @param onSuccess is a callback called when the task is successfully executed
  115700. * @param onError is a callback called if an error occurs
  115701. */
  115702. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115703. }
  115704. /**
  115705. * Define a task used by AssetsManager to load Equirectangular cube textures
  115706. */
  115707. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115708. /**
  115709. * Defines the name of the task
  115710. */
  115711. name: string;
  115712. /**
  115713. * Defines the location of the file to load
  115714. */
  115715. url: string;
  115716. /**
  115717. * Defines the desired size (the more it increases the longer the generation will be)
  115718. */
  115719. size: number;
  115720. /**
  115721. * Defines if mipmaps should not be generated (default is false)
  115722. */
  115723. noMipmap: boolean;
  115724. /**
  115725. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115726. * but the standard material would require them in Gamma space) (default is true)
  115727. */
  115728. gammaSpace: boolean;
  115729. /**
  115730. * Gets the loaded texture
  115731. */
  115732. texture: EquiRectangularCubeTexture;
  115733. /**
  115734. * Callback called when the task is successful
  115735. */
  115736. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115737. /**
  115738. * Callback called when the task is successful
  115739. */
  115740. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115741. /**
  115742. * Creates a new EquiRectangularCubeTextureAssetTask object
  115743. * @param name defines the name of the task
  115744. * @param url defines the location of the file to load
  115745. * @param size defines the desired size (the more it increases the longer the generation will be)
  115746. * If the size is omitted this implies you are using a preprocessed cubemap.
  115747. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115748. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115749. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115750. * (default is true)
  115751. */
  115752. constructor(
  115753. /**
  115754. * Defines the name of the task
  115755. */
  115756. name: string,
  115757. /**
  115758. * Defines the location of the file to load
  115759. */
  115760. url: string,
  115761. /**
  115762. * Defines the desired size (the more it increases the longer the generation will be)
  115763. */
  115764. size: number,
  115765. /**
  115766. * Defines if mipmaps should not be generated (default is false)
  115767. */
  115768. noMipmap?: boolean,
  115769. /**
  115770. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115771. * but the standard material would require them in Gamma space) (default is true)
  115772. */
  115773. gammaSpace?: boolean);
  115774. /**
  115775. * Execute the current task
  115776. * @param scene defines the scene where you want your assets to be loaded
  115777. * @param onSuccess is a callback called when the task is successfully executed
  115778. * @param onError is a callback called if an error occurs
  115779. */
  115780. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115781. }
  115782. /**
  115783. * This class can be used to easily import assets into a scene
  115784. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115785. */
  115786. export class AssetsManager {
  115787. private _scene;
  115788. private _isLoading;
  115789. protected _tasks: AbstractAssetTask[];
  115790. protected _waitingTasksCount: number;
  115791. protected _totalTasksCount: number;
  115792. /**
  115793. * Callback called when all tasks are processed
  115794. */
  115795. onFinish: (tasks: AbstractAssetTask[]) => void;
  115796. /**
  115797. * Callback called when a task is successful
  115798. */
  115799. onTaskSuccess: (task: AbstractAssetTask) => void;
  115800. /**
  115801. * Callback called when a task had an error
  115802. */
  115803. onTaskError: (task: AbstractAssetTask) => void;
  115804. /**
  115805. * Callback called when a task is done (whatever the result is)
  115806. */
  115807. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115808. /**
  115809. * Observable called when all tasks are processed
  115810. */
  115811. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115812. /**
  115813. * Observable called when a task had an error
  115814. */
  115815. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115816. /**
  115817. * Observable called when all tasks were executed
  115818. */
  115819. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115820. /**
  115821. * Observable called when a task is done (whatever the result is)
  115822. */
  115823. onProgressObservable: Observable<IAssetsProgressEvent>;
  115824. /**
  115825. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115827. */
  115828. useDefaultLoadingScreen: boolean;
  115829. /**
  115830. * Creates a new AssetsManager
  115831. * @param scene defines the scene to work on
  115832. */
  115833. constructor(scene: Scene);
  115834. /**
  115835. * Add a MeshAssetTask to the list of active tasks
  115836. * @param taskName defines the name of the new task
  115837. * @param meshesNames defines the name of meshes to load
  115838. * @param rootUrl defines the root url to use to locate files
  115839. * @param sceneFilename defines the filename of the scene file
  115840. * @returns a new MeshAssetTask object
  115841. */
  115842. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115843. /**
  115844. * Add a TextFileAssetTask to the list of active tasks
  115845. * @param taskName defines the name of the new task
  115846. * @param url defines the url of the file to load
  115847. * @returns a new TextFileAssetTask object
  115848. */
  115849. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115850. /**
  115851. * Add a BinaryFileAssetTask to the list of active tasks
  115852. * @param taskName defines the name of the new task
  115853. * @param url defines the url of the file to load
  115854. * @returns a new BinaryFileAssetTask object
  115855. */
  115856. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115857. /**
  115858. * Add a ImageAssetTask to the list of active tasks
  115859. * @param taskName defines the name of the new task
  115860. * @param url defines the url of the file to load
  115861. * @returns a new ImageAssetTask object
  115862. */
  115863. addImageTask(taskName: string, url: string): ImageAssetTask;
  115864. /**
  115865. * Add a TextureAssetTask to the list of active tasks
  115866. * @param taskName defines the name of the new task
  115867. * @param url defines the url of the file to load
  115868. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115869. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115870. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115871. * @returns a new TextureAssetTask object
  115872. */
  115873. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115874. /**
  115875. * Add a CubeTextureAssetTask to the list of active tasks
  115876. * @param taskName defines the name of the new task
  115877. * @param url defines the url of the file to load
  115878. * @param extensions defines the extension to use to load the cube map (can be null)
  115879. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115880. * @param files defines the list of files to load (can be null)
  115881. * @returns a new CubeTextureAssetTask object
  115882. */
  115883. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115884. /**
  115885. *
  115886. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115887. * @param taskName defines the name of the new task
  115888. * @param url defines the url of the file to load
  115889. * @param size defines the size you want for the cubemap (can be null)
  115890. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115891. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115892. * @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)
  115893. * @param reserved Internal use only
  115894. * @returns a new HDRCubeTextureAssetTask object
  115895. */
  115896. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115897. /**
  115898. *
  115899. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115900. * @param taskName defines the name of the new task
  115901. * @param url defines the url of the file to load
  115902. * @param size defines the size you want for the cubemap (can be null)
  115903. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115904. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115905. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115906. * @returns a new EquiRectangularCubeTextureAssetTask object
  115907. */
  115908. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115909. /**
  115910. * Remove a task from the assets manager.
  115911. * @param task the task to remove
  115912. */
  115913. removeTask(task: AbstractAssetTask): void;
  115914. private _decreaseWaitingTasksCount;
  115915. private _runTask;
  115916. /**
  115917. * Reset the AssetsManager and remove all tasks
  115918. * @return the current instance of the AssetsManager
  115919. */
  115920. reset(): AssetsManager;
  115921. /**
  115922. * Start the loading process
  115923. * @return the current instance of the AssetsManager
  115924. */
  115925. load(): AssetsManager;
  115926. /**
  115927. * Start the loading process as an async operation
  115928. * @return a promise returning the list of failed tasks
  115929. */
  115930. loadAsync(): Promise<void>;
  115931. }
  115932. }
  115933. declare module BABYLON {
  115934. /**
  115935. * Wrapper class for promise with external resolve and reject.
  115936. */
  115937. export class Deferred<T> {
  115938. /**
  115939. * The promise associated with this deferred object.
  115940. */
  115941. readonly promise: Promise<T>;
  115942. private _resolve;
  115943. private _reject;
  115944. /**
  115945. * The resolve method of the promise associated with this deferred object.
  115946. */
  115947. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115948. /**
  115949. * The reject method of the promise associated with this deferred object.
  115950. */
  115951. readonly reject: (reason?: any) => void;
  115952. /**
  115953. * Constructor for this deferred object.
  115954. */
  115955. constructor();
  115956. }
  115957. }
  115958. declare module BABYLON {
  115959. /**
  115960. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115961. */
  115962. export class MeshExploder {
  115963. private _centerMesh;
  115964. private _meshes;
  115965. private _meshesOrigins;
  115966. private _toCenterVectors;
  115967. private _scaledDirection;
  115968. private _newPosition;
  115969. private _centerPosition;
  115970. /**
  115971. * Explodes meshes from a center mesh.
  115972. * @param meshes The meshes to explode.
  115973. * @param centerMesh The mesh to be center of explosion.
  115974. */
  115975. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115976. private _setCenterMesh;
  115977. /**
  115978. * Get class name
  115979. * @returns "MeshExploder"
  115980. */
  115981. getClassName(): string;
  115982. /**
  115983. * "Exploded meshes"
  115984. * @returns Array of meshes with the centerMesh at index 0.
  115985. */
  115986. getMeshes(): Array<Mesh>;
  115987. /**
  115988. * Explodes meshes giving a specific direction
  115989. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115990. */
  115991. explode(direction?: number): void;
  115992. }
  115993. }
  115994. declare module BABYLON {
  115995. /**
  115996. * Class used to help managing file picking and drag'n'drop
  115997. */
  115998. export class FilesInput {
  115999. /**
  116000. * List of files ready to be loaded
  116001. */
  116002. static readonly FilesToLoad: {
  116003. [key: string]: File;
  116004. };
  116005. /**
  116006. * Callback called when a file is processed
  116007. */
  116008. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  116009. private _engine;
  116010. private _currentScene;
  116011. private _sceneLoadedCallback;
  116012. private _progressCallback;
  116013. private _additionalRenderLoopLogicCallback;
  116014. private _textureLoadingCallback;
  116015. private _startingProcessingFilesCallback;
  116016. private _onReloadCallback;
  116017. private _errorCallback;
  116018. private _elementToMonitor;
  116019. private _sceneFileToLoad;
  116020. private _filesToLoad;
  116021. /**
  116022. * Creates a new FilesInput
  116023. * @param engine defines the rendering engine
  116024. * @param scene defines the hosting scene
  116025. * @param sceneLoadedCallback callback called when scene is loaded
  116026. * @param progressCallback callback called to track progress
  116027. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  116028. * @param textureLoadingCallback callback called when a texture is loading
  116029. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  116030. * @param onReloadCallback callback called when a reload is requested
  116031. * @param errorCallback callback call if an error occurs
  116032. */
  116033. 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);
  116034. private _dragEnterHandler;
  116035. private _dragOverHandler;
  116036. private _dropHandler;
  116037. /**
  116038. * Calls this function to listen to drag'n'drop events on a specific DOM element
  116039. * @param elementToMonitor defines the DOM element to track
  116040. */
  116041. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  116042. /**
  116043. * Release all associated resources
  116044. */
  116045. dispose(): void;
  116046. private renderFunction;
  116047. private drag;
  116048. private drop;
  116049. private _traverseFolder;
  116050. private _processFiles;
  116051. /**
  116052. * Load files from a drop event
  116053. * @param event defines the drop event to use as source
  116054. */
  116055. loadFiles(event: any): void;
  116056. private _processReload;
  116057. /**
  116058. * Reload the current scene from the loaded files
  116059. */
  116060. reload(): void;
  116061. }
  116062. }
  116063. declare module BABYLON {
  116064. /**
  116065. * Defines the root class used to create scene optimization to use with SceneOptimizer
  116066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116067. */
  116068. export class SceneOptimization {
  116069. /**
  116070. * Defines the priority of this optimization (0 by default which means first in the list)
  116071. */
  116072. priority: number;
  116073. /**
  116074. * Gets a string describing the action executed by the current optimization
  116075. * @returns description string
  116076. */
  116077. getDescription(): string;
  116078. /**
  116079. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116080. * @param scene defines the current scene where to apply this optimization
  116081. * @param optimizer defines the current optimizer
  116082. * @returns true if everything that can be done was applied
  116083. */
  116084. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116085. /**
  116086. * Creates the SceneOptimization object
  116087. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116088. * @param desc defines the description associated with the optimization
  116089. */
  116090. constructor(
  116091. /**
  116092. * Defines the priority of this optimization (0 by default which means first in the list)
  116093. */
  116094. priority?: number);
  116095. }
  116096. /**
  116097. * Defines an optimization used to reduce the size of render target textures
  116098. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116099. */
  116100. export class TextureOptimization extends SceneOptimization {
  116101. /**
  116102. * Defines the priority of this optimization (0 by default which means first in the list)
  116103. */
  116104. priority: number;
  116105. /**
  116106. * 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
  116107. */
  116108. maximumSize: number;
  116109. /**
  116110. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  116111. */
  116112. step: number;
  116113. /**
  116114. * Gets a string describing the action executed by the current optimization
  116115. * @returns description string
  116116. */
  116117. getDescription(): string;
  116118. /**
  116119. * Creates the TextureOptimization object
  116120. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116121. * @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
  116122. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  116123. */
  116124. constructor(
  116125. /**
  116126. * Defines the priority of this optimization (0 by default which means first in the list)
  116127. */
  116128. priority?: number,
  116129. /**
  116130. * 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
  116131. */
  116132. maximumSize?: number,
  116133. /**
  116134. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  116135. */
  116136. step?: number);
  116137. /**
  116138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116139. * @param scene defines the current scene where to apply this optimization
  116140. * @param optimizer defines the current optimizer
  116141. * @returns true if everything that can be done was applied
  116142. */
  116143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116144. }
  116145. /**
  116146. * Defines an optimization used to increase or decrease the rendering resolution
  116147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116148. */
  116149. export class HardwareScalingOptimization extends SceneOptimization {
  116150. /**
  116151. * Defines the priority of this optimization (0 by default which means first in the list)
  116152. */
  116153. priority: number;
  116154. /**
  116155. * Defines the maximum scale to use (2 by default)
  116156. */
  116157. maximumScale: number;
  116158. /**
  116159. * Defines the step to use between two passes (0.5 by default)
  116160. */
  116161. step: number;
  116162. private _currentScale;
  116163. private _directionOffset;
  116164. /**
  116165. * Gets a string describing the action executed by the current optimization
  116166. * @return description string
  116167. */
  116168. getDescription(): string;
  116169. /**
  116170. * Creates the HardwareScalingOptimization object
  116171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116172. * @param maximumScale defines the maximum scale to use (2 by default)
  116173. * @param step defines the step to use between two passes (0.5 by default)
  116174. */
  116175. constructor(
  116176. /**
  116177. * Defines the priority of this optimization (0 by default which means first in the list)
  116178. */
  116179. priority?: number,
  116180. /**
  116181. * Defines the maximum scale to use (2 by default)
  116182. */
  116183. maximumScale?: number,
  116184. /**
  116185. * Defines the step to use between two passes (0.5 by default)
  116186. */
  116187. step?: number);
  116188. /**
  116189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116190. * @param scene defines the current scene where to apply this optimization
  116191. * @param optimizer defines the current optimizer
  116192. * @returns true if everything that can be done was applied
  116193. */
  116194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116195. }
  116196. /**
  116197. * Defines an optimization used to remove shadows
  116198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116199. */
  116200. export class ShadowsOptimization extends SceneOptimization {
  116201. /**
  116202. * Gets a string describing the action executed by the current optimization
  116203. * @return description string
  116204. */
  116205. getDescription(): string;
  116206. /**
  116207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116208. * @param scene defines the current scene where to apply this optimization
  116209. * @param optimizer defines the current optimizer
  116210. * @returns true if everything that can be done was applied
  116211. */
  116212. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116213. }
  116214. /**
  116215. * Defines an optimization used to turn post-processes off
  116216. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116217. */
  116218. export class PostProcessesOptimization extends SceneOptimization {
  116219. /**
  116220. * Gets a string describing the action executed by the current optimization
  116221. * @return description string
  116222. */
  116223. getDescription(): string;
  116224. /**
  116225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116226. * @param scene defines the current scene where to apply this optimization
  116227. * @param optimizer defines the current optimizer
  116228. * @returns true if everything that can be done was applied
  116229. */
  116230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116231. }
  116232. /**
  116233. * Defines an optimization used to turn lens flares off
  116234. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116235. */
  116236. export class LensFlaresOptimization extends SceneOptimization {
  116237. /**
  116238. * Gets a string describing the action executed by the current optimization
  116239. * @return description string
  116240. */
  116241. getDescription(): string;
  116242. /**
  116243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116244. * @param scene defines the current scene where to apply this optimization
  116245. * @param optimizer defines the current optimizer
  116246. * @returns true if everything that can be done was applied
  116247. */
  116248. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116249. }
  116250. /**
  116251. * Defines an optimization based on user defined callback.
  116252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116253. */
  116254. export class CustomOptimization extends SceneOptimization {
  116255. /**
  116256. * Callback called to apply the custom optimization.
  116257. */
  116258. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116259. /**
  116260. * Callback called to get custom description
  116261. */
  116262. onGetDescription: () => string;
  116263. /**
  116264. * Gets a string describing the action executed by the current optimization
  116265. * @returns description string
  116266. */
  116267. getDescription(): string;
  116268. /**
  116269. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116270. * @param scene defines the current scene where to apply this optimization
  116271. * @param optimizer defines the current optimizer
  116272. * @returns true if everything that can be done was applied
  116273. */
  116274. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116275. }
  116276. /**
  116277. * Defines an optimization used to turn particles off
  116278. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116279. */
  116280. export class ParticlesOptimization extends SceneOptimization {
  116281. /**
  116282. * Gets a string describing the action executed by the current optimization
  116283. * @return description string
  116284. */
  116285. getDescription(): string;
  116286. /**
  116287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116288. * @param scene defines the current scene where to apply this optimization
  116289. * @param optimizer defines the current optimizer
  116290. * @returns true if everything that can be done was applied
  116291. */
  116292. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116293. }
  116294. /**
  116295. * Defines an optimization used to turn render targets off
  116296. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116297. */
  116298. export class RenderTargetsOptimization extends SceneOptimization {
  116299. /**
  116300. * Gets a string describing the action executed by the current optimization
  116301. * @return description string
  116302. */
  116303. getDescription(): string;
  116304. /**
  116305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116306. * @param scene defines the current scene where to apply this optimization
  116307. * @param optimizer defines the current optimizer
  116308. * @returns true if everything that can be done was applied
  116309. */
  116310. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116311. }
  116312. /**
  116313. * Defines an optimization used to merge meshes with compatible materials
  116314. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116315. */
  116316. export class MergeMeshesOptimization extends SceneOptimization {
  116317. private static _UpdateSelectionTree;
  116318. /**
  116319. * Gets or sets a boolean which defines if optimization octree has to be updated
  116320. */
  116321. /**
  116322. * Gets or sets a boolean which defines if optimization octree has to be updated
  116323. */
  116324. static UpdateSelectionTree: boolean;
  116325. /**
  116326. * Gets a string describing the action executed by the current optimization
  116327. * @return description string
  116328. */
  116329. getDescription(): string;
  116330. private _canBeMerged;
  116331. /**
  116332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116333. * @param scene defines the current scene where to apply this optimization
  116334. * @param optimizer defines the current optimizer
  116335. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116336. * @returns true if everything that can be done was applied
  116337. */
  116338. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116339. }
  116340. /**
  116341. * Defines a list of options used by SceneOptimizer
  116342. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116343. */
  116344. export class SceneOptimizerOptions {
  116345. /**
  116346. * Defines the target frame rate to reach (60 by default)
  116347. */
  116348. targetFrameRate: number;
  116349. /**
  116350. * Defines the interval between two checkes (2000ms by default)
  116351. */
  116352. trackerDuration: number;
  116353. /**
  116354. * Gets the list of optimizations to apply
  116355. */
  116356. optimizations: SceneOptimization[];
  116357. /**
  116358. * Creates a new list of options used by SceneOptimizer
  116359. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116360. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116361. */
  116362. constructor(
  116363. /**
  116364. * Defines the target frame rate to reach (60 by default)
  116365. */
  116366. targetFrameRate?: number,
  116367. /**
  116368. * Defines the interval between two checkes (2000ms by default)
  116369. */
  116370. trackerDuration?: number);
  116371. /**
  116372. * Add a new optimization
  116373. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116374. * @returns the current SceneOptimizerOptions
  116375. */
  116376. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116377. /**
  116378. * Add a new custom optimization
  116379. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116380. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116381. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116382. * @returns the current SceneOptimizerOptions
  116383. */
  116384. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116385. /**
  116386. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116387. * @param targetFrameRate defines the target frame rate (60 by default)
  116388. * @returns a SceneOptimizerOptions object
  116389. */
  116390. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116391. /**
  116392. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116393. * @param targetFrameRate defines the target frame rate (60 by default)
  116394. * @returns a SceneOptimizerOptions object
  116395. */
  116396. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116397. /**
  116398. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116399. * @param targetFrameRate defines the target frame rate (60 by default)
  116400. * @returns a SceneOptimizerOptions object
  116401. */
  116402. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116403. }
  116404. /**
  116405. * Class used to run optimizations in order to reach a target frame rate
  116406. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116407. */
  116408. export class SceneOptimizer implements IDisposable {
  116409. private _isRunning;
  116410. private _options;
  116411. private _scene;
  116412. private _currentPriorityLevel;
  116413. private _targetFrameRate;
  116414. private _trackerDuration;
  116415. private _currentFrameRate;
  116416. private _sceneDisposeObserver;
  116417. private _improvementMode;
  116418. /**
  116419. * Defines an observable called when the optimizer reaches the target frame rate
  116420. */
  116421. onSuccessObservable: Observable<SceneOptimizer>;
  116422. /**
  116423. * Defines an observable called when the optimizer enables an optimization
  116424. */
  116425. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116426. /**
  116427. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116428. */
  116429. onFailureObservable: Observable<SceneOptimizer>;
  116430. /**
  116431. * Gets a boolean indicating if the optimizer is in improvement mode
  116432. */
  116433. readonly isInImprovementMode: boolean;
  116434. /**
  116435. * Gets the current priority level (0 at start)
  116436. */
  116437. readonly currentPriorityLevel: number;
  116438. /**
  116439. * Gets the current frame rate checked by the SceneOptimizer
  116440. */
  116441. readonly currentFrameRate: number;
  116442. /**
  116443. * Gets or sets the current target frame rate (60 by default)
  116444. */
  116445. /**
  116446. * Gets or sets the current target frame rate (60 by default)
  116447. */
  116448. targetFrameRate: number;
  116449. /**
  116450. * Gets or sets the current interval between two checks (every 2000ms by default)
  116451. */
  116452. /**
  116453. * Gets or sets the current interval between two checks (every 2000ms by default)
  116454. */
  116455. trackerDuration: number;
  116456. /**
  116457. * Gets the list of active optimizations
  116458. */
  116459. readonly optimizations: SceneOptimization[];
  116460. /**
  116461. * Creates a new SceneOptimizer
  116462. * @param scene defines the scene to work on
  116463. * @param options defines the options to use with the SceneOptimizer
  116464. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116465. * @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)
  116466. */
  116467. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116468. /**
  116469. * Stops the current optimizer
  116470. */
  116471. stop(): void;
  116472. /**
  116473. * Reset the optimizer to initial step (current priority level = 0)
  116474. */
  116475. reset(): void;
  116476. /**
  116477. * Start the optimizer. By default it will try to reach a specific framerate
  116478. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116479. */
  116480. start(): void;
  116481. private _checkCurrentState;
  116482. /**
  116483. * Release all resources
  116484. */
  116485. dispose(): void;
  116486. /**
  116487. * Helper function to create a SceneOptimizer with one single line of code
  116488. * @param scene defines the scene to work on
  116489. * @param options defines the options to use with the SceneOptimizer
  116490. * @param onSuccess defines a callback to call on success
  116491. * @param onFailure defines a callback to call on failure
  116492. * @returns the new SceneOptimizer object
  116493. */
  116494. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116495. }
  116496. }
  116497. declare module BABYLON {
  116498. /**
  116499. * Class used to serialize a scene into a string
  116500. */
  116501. export class SceneSerializer {
  116502. /**
  116503. * Clear cache used by a previous serialization
  116504. */
  116505. static ClearCache(): void;
  116506. /**
  116507. * Serialize a scene into a JSON compatible object
  116508. * @param scene defines the scene to serialize
  116509. * @returns a JSON compatible object
  116510. */
  116511. static Serialize(scene: Scene): any;
  116512. /**
  116513. * Serialize a mesh into a JSON compatible object
  116514. * @param toSerialize defines the mesh to serialize
  116515. * @param withParents defines if parents must be serialized as well
  116516. * @param withChildren defines if children must be serialized as well
  116517. * @returns a JSON compatible object
  116518. */
  116519. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116520. }
  116521. }
  116522. declare module BABYLON {
  116523. /**
  116524. * Class used to host texture specific utilities
  116525. */
  116526. export class TextureTools {
  116527. /**
  116528. * Uses the GPU to create a copy texture rescaled at a given size
  116529. * @param texture Texture to copy from
  116530. * @param width defines the desired width
  116531. * @param height defines the desired height
  116532. * @param useBilinearMode defines if bilinear mode has to be used
  116533. * @return the generated texture
  116534. */
  116535. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116536. }
  116537. }
  116538. declare module BABYLON {
  116539. /**
  116540. * This represents the different options avilable for the video capture.
  116541. */
  116542. export interface VideoRecorderOptions {
  116543. /** Defines the mime type of the video */
  116544. mimeType: string;
  116545. /** Defines the video the video should be recorded at */
  116546. fps: number;
  116547. /** Defines the chunk size for the recording data */
  116548. recordChunckSize: number;
  116549. /** The audio tracks to attach to the record */
  116550. audioTracks?: MediaStreamTrack[];
  116551. }
  116552. /**
  116553. * This can helps recording videos from BabylonJS.
  116554. * This is based on the available WebRTC functionalities of the browser.
  116555. *
  116556. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116557. */
  116558. export class VideoRecorder {
  116559. private static readonly _defaultOptions;
  116560. /**
  116561. * Returns wehther or not the VideoRecorder is available in your browser.
  116562. * @param engine Defines the Babylon Engine to check the support for
  116563. * @returns true if supported otherwise false
  116564. */
  116565. static IsSupported(engine: Engine): boolean;
  116566. private readonly _options;
  116567. private _canvas;
  116568. private _mediaRecorder;
  116569. private _recordedChunks;
  116570. private _fileName;
  116571. private _resolve;
  116572. private _reject;
  116573. /**
  116574. * True wether a recording is already in progress.
  116575. */
  116576. readonly isRecording: boolean;
  116577. /**
  116578. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116579. * a video file.
  116580. * @param engine Defines the BabylonJS Engine you wish to record
  116581. * @param options Defines options that can be used to customized the capture
  116582. */
  116583. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116584. /**
  116585. * Stops the current recording before the default capture timeout passed in the startRecording
  116586. * functions.
  116587. */
  116588. stopRecording(): void;
  116589. /**
  116590. * Starts recording the canvas for a max duration specified in parameters.
  116591. * @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.
  116592. * @param maxDuration Defines the maximum recording time in seconds.
  116593. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116594. * @return a promise callback at the end of the recording with the video data in Blob.
  116595. */
  116596. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116597. /**
  116598. * Releases internal resources used during the recording.
  116599. */
  116600. dispose(): void;
  116601. private _handleDataAvailable;
  116602. private _handleError;
  116603. private _handleStop;
  116604. }
  116605. }
  116606. declare module BABYLON {
  116607. /**
  116608. * Class containing a set of static utilities functions for screenshots
  116609. */
  116610. export class ScreenshotTools {
  116611. /**
  116612. * Captures a screenshot of the current rendering
  116613. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116614. * @param engine defines the rendering engine
  116615. * @param camera defines the source camera
  116616. * @param size This parameter can be set to a single number or to an object with the
  116617. * following (optional) properties: precision, width, height. If a single number is passed,
  116618. * it will be used for both width and height. If an object is passed, the screenshot size
  116619. * will be derived from the parameters. The precision property is a multiplier allowing
  116620. * rendering at a higher or lower resolution
  116621. * @param successCallback defines the callback receives a single parameter which contains the
  116622. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116623. * src parameter of an <img> to display it
  116624. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116625. * Check your browser for supported MIME types
  116626. */
  116627. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116628. /**
  116629. * Generates an image screenshot from the specified camera.
  116630. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116631. * @param engine The engine to use for rendering
  116632. * @param camera The camera to use for rendering
  116633. * @param size This parameter can be set to a single number or to an object with the
  116634. * following (optional) properties: precision, width, height. If a single number is passed,
  116635. * it will be used for both width and height. If an object is passed, the screenshot size
  116636. * will be derived from the parameters. The precision property is a multiplier allowing
  116637. * rendering at a higher or lower resolution
  116638. * @param successCallback The callback receives a single parameter which contains the
  116639. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116640. * src parameter of an <img> to display it
  116641. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116642. * Check your browser for supported MIME types
  116643. * @param samples Texture samples (default: 1)
  116644. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116645. * @param fileName A name for for the downloaded file.
  116646. */
  116647. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116648. }
  116649. }
  116650. declare module BABYLON {
  116651. /**
  116652. * A cursor which tracks a point on a path
  116653. */
  116654. export class PathCursor {
  116655. private path;
  116656. /**
  116657. * Stores path cursor callbacks for when an onchange event is triggered
  116658. */
  116659. private _onchange;
  116660. /**
  116661. * The value of the path cursor
  116662. */
  116663. value: number;
  116664. /**
  116665. * The animation array of the path cursor
  116666. */
  116667. animations: Animation[];
  116668. /**
  116669. * Initializes the path cursor
  116670. * @param path The path to track
  116671. */
  116672. constructor(path: Path2);
  116673. /**
  116674. * Gets the cursor point on the path
  116675. * @returns A point on the path cursor at the cursor location
  116676. */
  116677. getPoint(): Vector3;
  116678. /**
  116679. * Moves the cursor ahead by the step amount
  116680. * @param step The amount to move the cursor forward
  116681. * @returns This path cursor
  116682. */
  116683. moveAhead(step?: number): PathCursor;
  116684. /**
  116685. * Moves the cursor behind by the step amount
  116686. * @param step The amount to move the cursor back
  116687. * @returns This path cursor
  116688. */
  116689. moveBack(step?: number): PathCursor;
  116690. /**
  116691. * Moves the cursor by the step amount
  116692. * If the step amount is greater than one, an exception is thrown
  116693. * @param step The amount to move the cursor
  116694. * @returns This path cursor
  116695. */
  116696. move(step: number): PathCursor;
  116697. /**
  116698. * Ensures that the value is limited between zero and one
  116699. * @returns This path cursor
  116700. */
  116701. private ensureLimits;
  116702. /**
  116703. * Runs onchange callbacks on change (used by the animation engine)
  116704. * @returns This path cursor
  116705. */
  116706. private raiseOnChange;
  116707. /**
  116708. * Executes a function on change
  116709. * @param f A path cursor onchange callback
  116710. * @returns This path cursor
  116711. */
  116712. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116713. }
  116714. }
  116715. declare module BABYLON {
  116716. /** @hidden */
  116717. export var blurPixelShader: {
  116718. name: string;
  116719. shader: string;
  116720. };
  116721. }
  116722. declare module BABYLON {
  116723. /** @hidden */
  116724. export var bones300Declaration: {
  116725. name: string;
  116726. shader: string;
  116727. };
  116728. }
  116729. declare module BABYLON {
  116730. /** @hidden */
  116731. export var instances300Declaration: {
  116732. name: string;
  116733. shader: string;
  116734. };
  116735. }
  116736. declare module BABYLON {
  116737. /** @hidden */
  116738. export var pointCloudVertexDeclaration: {
  116739. name: string;
  116740. shader: string;
  116741. };
  116742. }
  116743. // Mixins
  116744. interface Window {
  116745. mozIndexedDB: IDBFactory;
  116746. webkitIndexedDB: IDBFactory;
  116747. msIndexedDB: IDBFactory;
  116748. webkitURL: typeof URL;
  116749. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116750. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116751. WebGLRenderingContext: WebGLRenderingContext;
  116752. MSGesture: MSGesture;
  116753. CANNON: any;
  116754. AudioContext: AudioContext;
  116755. webkitAudioContext: AudioContext;
  116756. PointerEvent: any;
  116757. Math: Math;
  116758. Uint8Array: Uint8ArrayConstructor;
  116759. Float32Array: Float32ArrayConstructor;
  116760. mozURL: typeof URL;
  116761. msURL: typeof URL;
  116762. VRFrameData: any; // WebVR, from specs 1.1
  116763. DracoDecoderModule: any;
  116764. setImmediate(handler: (...args: any[]) => void): number;
  116765. }
  116766. interface HTMLCanvasElement {
  116767. requestPointerLock(): void;
  116768. msRequestPointerLock?(): void;
  116769. mozRequestPointerLock?(): void;
  116770. webkitRequestPointerLock?(): void;
  116771. /** Track wether a record is in progress */
  116772. isRecording: boolean;
  116773. /** Capture Stream method defined by some browsers */
  116774. captureStream(fps?: number): MediaStream;
  116775. }
  116776. interface CanvasRenderingContext2D {
  116777. msImageSmoothingEnabled: boolean;
  116778. }
  116779. interface MouseEvent {
  116780. mozMovementX: number;
  116781. mozMovementY: number;
  116782. webkitMovementX: number;
  116783. webkitMovementY: number;
  116784. msMovementX: number;
  116785. msMovementY: number;
  116786. }
  116787. interface Navigator {
  116788. mozGetVRDevices: (any: any) => any;
  116789. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116790. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116791. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116792. webkitGetGamepads(): Gamepad[];
  116793. msGetGamepads(): Gamepad[];
  116794. webkitGamepads(): Gamepad[];
  116795. }
  116796. interface HTMLVideoElement {
  116797. mozSrcObject: any;
  116798. }
  116799. interface Math {
  116800. fround(x: number): number;
  116801. imul(a: number, b: number): number;
  116802. }
  116803. interface WebGLRenderingContext {
  116804. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116805. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116806. vertexAttribDivisor(index: number, divisor: number): void;
  116807. createVertexArray(): any;
  116808. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116809. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116810. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116811. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116812. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116813. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116814. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116815. // Queries
  116816. createQuery(): WebGLQuery;
  116817. deleteQuery(query: WebGLQuery): void;
  116818. beginQuery(target: number, query: WebGLQuery): void;
  116819. endQuery(target: number): void;
  116820. getQueryParameter(query: WebGLQuery, pname: number): any;
  116821. getQuery(target: number, pname: number): any;
  116822. MAX_SAMPLES: number;
  116823. RGBA8: number;
  116824. READ_FRAMEBUFFER: number;
  116825. DRAW_FRAMEBUFFER: number;
  116826. UNIFORM_BUFFER: number;
  116827. HALF_FLOAT_OES: number;
  116828. RGBA16F: number;
  116829. RGBA32F: number;
  116830. R32F: number;
  116831. RG32F: number;
  116832. RGB32F: number;
  116833. R16F: number;
  116834. RG16F: number;
  116835. RGB16F: number;
  116836. RED: number;
  116837. RG: number;
  116838. R8: number;
  116839. RG8: number;
  116840. UNSIGNED_INT_24_8: number;
  116841. DEPTH24_STENCIL8: number;
  116842. /* Multiple Render Targets */
  116843. drawBuffers(buffers: number[]): void;
  116844. readBuffer(src: number): void;
  116845. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116846. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116847. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116848. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116849. // Occlusion Query
  116850. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116851. ANY_SAMPLES_PASSED: number;
  116852. QUERY_RESULT_AVAILABLE: number;
  116853. QUERY_RESULT: number;
  116854. }
  116855. interface WebGLProgram {
  116856. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116857. }
  116858. interface EXT_disjoint_timer_query {
  116859. QUERY_COUNTER_BITS_EXT: number;
  116860. TIME_ELAPSED_EXT: number;
  116861. TIMESTAMP_EXT: number;
  116862. GPU_DISJOINT_EXT: number;
  116863. QUERY_RESULT_EXT: number;
  116864. QUERY_RESULT_AVAILABLE_EXT: number;
  116865. queryCounterEXT(query: WebGLQuery, target: number): void;
  116866. createQueryEXT(): WebGLQuery;
  116867. beginQueryEXT(target: number, query: WebGLQuery): void;
  116868. endQueryEXT(target: number): void;
  116869. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116870. deleteQueryEXT(query: WebGLQuery): void;
  116871. }
  116872. interface WebGLUniformLocation {
  116873. _currentState: any;
  116874. }
  116875. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116876. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116877. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116878. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116879. interface WebGLRenderingContext {
  116880. readonly RASTERIZER_DISCARD: number;
  116881. readonly DEPTH_COMPONENT24: number;
  116882. readonly TEXTURE_3D: number;
  116883. readonly TEXTURE_2D_ARRAY: number;
  116884. readonly TEXTURE_COMPARE_FUNC: number;
  116885. readonly TEXTURE_COMPARE_MODE: number;
  116886. readonly COMPARE_REF_TO_TEXTURE: number;
  116887. readonly TEXTURE_WRAP_R: number;
  116888. readonly HALF_FLOAT: number;
  116889. readonly RGB8: number;
  116890. readonly RED_INTEGER: number;
  116891. readonly RG_INTEGER: number;
  116892. readonly RGB_INTEGER: number;
  116893. readonly RGBA_INTEGER: number;
  116894. readonly R8_SNORM: number;
  116895. readonly RG8_SNORM: number;
  116896. readonly RGB8_SNORM: number;
  116897. readonly RGBA8_SNORM: number;
  116898. readonly R8I: number;
  116899. readonly RG8I: number;
  116900. readonly RGB8I: number;
  116901. readonly RGBA8I: number;
  116902. readonly R8UI: number;
  116903. readonly RG8UI: number;
  116904. readonly RGB8UI: number;
  116905. readonly RGBA8UI: number;
  116906. readonly R16I: number;
  116907. readonly RG16I: number;
  116908. readonly RGB16I: number;
  116909. readonly RGBA16I: number;
  116910. readonly R16UI: number;
  116911. readonly RG16UI: number;
  116912. readonly RGB16UI: number;
  116913. readonly RGBA16UI: number;
  116914. readonly R32I: number;
  116915. readonly RG32I: number;
  116916. readonly RGB32I: number;
  116917. readonly RGBA32I: number;
  116918. readonly R32UI: number;
  116919. readonly RG32UI: number;
  116920. readonly RGB32UI: number;
  116921. readonly RGBA32UI: number;
  116922. readonly RGB10_A2UI: number;
  116923. readonly R11F_G11F_B10F: number;
  116924. readonly RGB9_E5: number;
  116925. readonly RGB10_A2: number;
  116926. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116927. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116928. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116929. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116930. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116931. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116932. 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;
  116933. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116934. readonly TRANSFORM_FEEDBACK: number;
  116935. readonly INTERLEAVED_ATTRIBS: number;
  116936. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116937. createTransformFeedback(): WebGLTransformFeedback;
  116938. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116939. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116940. beginTransformFeedback(primitiveMode: number): void;
  116941. endTransformFeedback(): void;
  116942. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116943. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116944. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116945. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116946. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116947. }
  116948. interface ImageBitmap {
  116949. readonly width: number;
  116950. readonly height: number;
  116951. close(): void;
  116952. }
  116953. interface WebGLQuery extends WebGLObject {
  116954. }
  116955. declare var WebGLQuery: {
  116956. prototype: WebGLQuery;
  116957. new(): WebGLQuery;
  116958. };
  116959. interface WebGLSampler extends WebGLObject {
  116960. }
  116961. declare var WebGLSampler: {
  116962. prototype: WebGLSampler;
  116963. new(): WebGLSampler;
  116964. };
  116965. interface WebGLSync extends WebGLObject {
  116966. }
  116967. declare var WebGLSync: {
  116968. prototype: WebGLSync;
  116969. new(): WebGLSync;
  116970. };
  116971. interface WebGLTransformFeedback extends WebGLObject {
  116972. }
  116973. declare var WebGLTransformFeedback: {
  116974. prototype: WebGLTransformFeedback;
  116975. new(): WebGLTransformFeedback;
  116976. };
  116977. interface WebGLVertexArrayObject extends WebGLObject {
  116978. }
  116979. declare var WebGLVertexArrayObject: {
  116980. prototype: WebGLVertexArrayObject;
  116981. new(): WebGLVertexArrayObject;
  116982. };
  116983. // Type definitions for WebVR API
  116984. // Project: https://w3c.github.io/webvr/
  116985. // Definitions by: six a <https://github.com/lostfictions>
  116986. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116987. interface VRDisplay extends EventTarget {
  116988. /**
  116989. * Dictionary of capabilities describing the VRDisplay.
  116990. */
  116991. readonly capabilities: VRDisplayCapabilities;
  116992. /**
  116993. * z-depth defining the far plane of the eye view frustum
  116994. * enables mapping of values in the render target depth
  116995. * attachment to scene coordinates. Initially set to 10000.0.
  116996. */
  116997. depthFar: number;
  116998. /**
  116999. * z-depth defining the near plane of the eye view frustum
  117000. * enables mapping of values in the render target depth
  117001. * attachment to scene coordinates. Initially set to 0.01.
  117002. */
  117003. depthNear: number;
  117004. /**
  117005. * An identifier for this distinct VRDisplay. Used as an
  117006. * association point in the Gamepad API.
  117007. */
  117008. readonly displayId: number;
  117009. /**
  117010. * A display name, a user-readable name identifying it.
  117011. */
  117012. readonly displayName: string;
  117013. readonly isConnected: boolean;
  117014. readonly isPresenting: boolean;
  117015. /**
  117016. * If this VRDisplay supports room-scale experiences, the optional
  117017. * stage attribute contains details on the room-scale parameters.
  117018. */
  117019. readonly stageParameters: VRStageParameters | null;
  117020. /**
  117021. * Passing the value returned by `requestAnimationFrame` to
  117022. * `cancelAnimationFrame` will unregister the callback.
  117023. * @param handle Define the hanle of the request to cancel
  117024. */
  117025. cancelAnimationFrame(handle: number): void;
  117026. /**
  117027. * Stops presenting to the VRDisplay.
  117028. * @returns a promise to know when it stopped
  117029. */
  117030. exitPresent(): Promise<void>;
  117031. /**
  117032. * Return the current VREyeParameters for the given eye.
  117033. * @param whichEye Define the eye we want the parameter for
  117034. * @returns the eye parameters
  117035. */
  117036. getEyeParameters(whichEye: string): VREyeParameters;
  117037. /**
  117038. * Populates the passed VRFrameData with the information required to render
  117039. * the current frame.
  117040. * @param frameData Define the data structure to populate
  117041. * @returns true if ok otherwise false
  117042. */
  117043. getFrameData(frameData: VRFrameData): boolean;
  117044. /**
  117045. * Get the layers currently being presented.
  117046. * @returns the list of VR layers
  117047. */
  117048. getLayers(): VRLayer[];
  117049. /**
  117050. * Return a VRPose containing the future predicted pose of the VRDisplay
  117051. * when the current frame will be presented. The value returned will not
  117052. * change until JavaScript has returned control to the browser.
  117053. *
  117054. * The VRPose will contain the position, orientation, velocity,
  117055. * and acceleration of each of these properties.
  117056. * @returns the pose object
  117057. */
  117058. getPose(): VRPose;
  117059. /**
  117060. * Return the current instantaneous pose of the VRDisplay, with no
  117061. * prediction applied.
  117062. * @returns the current instantaneous pose
  117063. */
  117064. getImmediatePose(): VRPose;
  117065. /**
  117066. * The callback passed to `requestAnimationFrame` will be called
  117067. * any time a new frame should be rendered. When the VRDisplay is
  117068. * presenting the callback will be called at the native refresh
  117069. * rate of the HMD. When not presenting this function acts
  117070. * identically to how window.requestAnimationFrame acts. Content should
  117071. * make no assumptions of frame rate or vsync behavior as the HMD runs
  117072. * asynchronously from other displays and at differing refresh rates.
  117073. * @param callback Define the eaction to run next frame
  117074. * @returns the request handle it
  117075. */
  117076. requestAnimationFrame(callback: FrameRequestCallback): number;
  117077. /**
  117078. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  117079. * Repeat calls while already presenting will update the VRLayers being displayed.
  117080. * @param layers Define the list of layer to present
  117081. * @returns a promise to know when the request has been fulfilled
  117082. */
  117083. requestPresent(layers: VRLayer[]): Promise<void>;
  117084. /**
  117085. * Reset the pose for this display, treating its current position and
  117086. * orientation as the "origin/zero" values. VRPose.position,
  117087. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  117088. * updated when calling resetPose(). This should be called in only
  117089. * sitting-space experiences.
  117090. */
  117091. resetPose(): void;
  117092. /**
  117093. * The VRLayer provided to the VRDisplay will be captured and presented
  117094. * in the HMD. Calling this function has the same effect on the source
  117095. * canvas as any other operation that uses its source image, and canvases
  117096. * created without preserveDrawingBuffer set to true will be cleared.
  117097. * @param pose Define the pose to submit
  117098. */
  117099. submitFrame(pose?: VRPose): void;
  117100. }
  117101. declare var VRDisplay: {
  117102. prototype: VRDisplay;
  117103. new(): VRDisplay;
  117104. };
  117105. interface VRLayer {
  117106. leftBounds?: number[] | Float32Array | null;
  117107. rightBounds?: number[] | Float32Array | null;
  117108. source?: HTMLCanvasElement | null;
  117109. }
  117110. interface VRDisplayCapabilities {
  117111. readonly canPresent: boolean;
  117112. readonly hasExternalDisplay: boolean;
  117113. readonly hasOrientation: boolean;
  117114. readonly hasPosition: boolean;
  117115. readonly maxLayers: number;
  117116. }
  117117. interface VREyeParameters {
  117118. /** @deprecated */
  117119. readonly fieldOfView: VRFieldOfView;
  117120. readonly offset: Float32Array;
  117121. readonly renderHeight: number;
  117122. readonly renderWidth: number;
  117123. }
  117124. interface VRFieldOfView {
  117125. readonly downDegrees: number;
  117126. readonly leftDegrees: number;
  117127. readonly rightDegrees: number;
  117128. readonly upDegrees: number;
  117129. }
  117130. interface VRFrameData {
  117131. readonly leftProjectionMatrix: Float32Array;
  117132. readonly leftViewMatrix: Float32Array;
  117133. readonly pose: VRPose;
  117134. readonly rightProjectionMatrix: Float32Array;
  117135. readonly rightViewMatrix: Float32Array;
  117136. readonly timestamp: number;
  117137. }
  117138. interface VRPose {
  117139. readonly angularAcceleration: Float32Array | null;
  117140. readonly angularVelocity: Float32Array | null;
  117141. readonly linearAcceleration: Float32Array | null;
  117142. readonly linearVelocity: Float32Array | null;
  117143. readonly orientation: Float32Array | null;
  117144. readonly position: Float32Array | null;
  117145. readonly timestamp: number;
  117146. }
  117147. interface VRStageParameters {
  117148. sittingToStandingTransform?: Float32Array;
  117149. sizeX?: number;
  117150. sizeY?: number;
  117151. }
  117152. interface Navigator {
  117153. getVRDisplays(): Promise<VRDisplay[]>;
  117154. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  117155. }
  117156. interface Window {
  117157. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  117158. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  117159. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  117160. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  117161. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  117162. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  117163. }
  117164. interface Gamepad {
  117165. readonly displayId: number;
  117166. }
  117167. interface XRDevice {
  117168. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  117169. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  117170. }
  117171. interface XRSession {
  117172. getInputSources(): Array<any>;
  117173. baseLayer: XRWebGLLayer;
  117174. requestFrameOfReference(type: string): Promise<void>;
  117175. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  117176. end(): Promise<void>;
  117177. requestAnimationFrame: Function;
  117178. addEventListener: Function;
  117179. }
  117180. interface XRSessionCreationOptions {
  117181. outputContext?: WebGLRenderingContext | null;
  117182. immersive?: boolean;
  117183. environmentIntegration?: boolean;
  117184. }
  117185. interface XRLayer {
  117186. getViewport: Function;
  117187. framebufferWidth: number;
  117188. framebufferHeight: number;
  117189. }
  117190. interface XRView {
  117191. projectionMatrix: Float32Array;
  117192. }
  117193. interface XRFrame {
  117194. getDevicePose: Function;
  117195. getInputPose: Function;
  117196. views: Array<XRView>;
  117197. baseLayer: XRLayer;
  117198. }
  117199. interface XRFrameOfReference {
  117200. }
  117201. interface XRWebGLLayer extends XRLayer {
  117202. framebuffer: WebGLFramebuffer;
  117203. }
  117204. declare var XRWebGLLayer: {
  117205. prototype: XRWebGLLayer;
  117206. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  117207. };